mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-13 22:53:44 +01:00
Change behavior on missing/present event to warn instead of asserting.
Add a changes file.
This commit is contained in:
parent
650c03127a
commit
457d38a6e9
8
changes/bug16248
Normal file
8
changes/bug16248
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
o Major bugfixes (dns proxy mode, crash):
|
||||||
|
- Avoid crashing when running as a DNS proxy. Closes bug 16248; bugfix on
|
||||||
|
0.2.0.1-alpha. Patch from 'cypherpunks'.
|
||||||
|
|
||||||
|
o Minor features (bug-resistance):
|
||||||
|
- Make Tor survive errors involving connections without a corresponding
|
||||||
|
event object. Previously we'd fail with an assertion; now we produce a
|
||||||
|
log message. Related to bug 16248.
|
@ -506,6 +506,35 @@ connection_is_reading(connection_t *conn)
|
|||||||
(conn->read_event && event_pending(conn->read_event, EV_READ, NULL));
|
(conn->read_event && event_pending(conn->read_event, EV_READ, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
connection_check_event(connection_t *conn, struct event *ev)
|
||||||
|
{
|
||||||
|
int bad;
|
||||||
|
|
||||||
|
if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) {
|
||||||
|
bad = ev != NULL;
|
||||||
|
} else {
|
||||||
|
bad = ev == NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bad) {
|
||||||
|
log_warn(LD_BUG, "Event missing on connection %p [%s;%s]. "
|
||||||
|
"socket=%d. linked=%d. "
|
||||||
|
"is_dns_request=%d. Marked_for_close=%s:%d",
|
||||||
|
conn,
|
||||||
|
conn_type_to_string(conn->type),
|
||||||
|
conn_state_to_string(conn->type, conn->state),
|
||||||
|
(int)conn->s, (int)conn->linked,
|
||||||
|
(conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request),
|
||||||
|
conn->marked_for_close_file ? conn->marked_for_close_file : "-",
|
||||||
|
conn->marked_for_close
|
||||||
|
);
|
||||||
|
log_backtrace(LOG_WARN, LD_BUG, "Backtrace attached.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/** Tell the main loop to stop notifying <b>conn</b> of any read events. */
|
/** Tell the main loop to stop notifying <b>conn</b> of any read events. */
|
||||||
void
|
void
|
||||||
connection_stop_reading(connection_t *conn)
|
connection_stop_reading(connection_t *conn)
|
||||||
@ -517,14 +546,10 @@ connection_stop_reading(connection_t *conn)
|
|||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|
||||||
/* if dummy conn then no socket and no event, nothing to do here */
|
if (connection_check_event(conn, conn->read_event) < 0) {
|
||||||
if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) {
|
|
||||||
tor_assert(!conn->read_event);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tor_assert(conn->read_event);
|
|
||||||
|
|
||||||
if (conn->linked) {
|
if (conn->linked) {
|
||||||
conn->reading_from_linked_conn = 0;
|
conn->reading_from_linked_conn = 0;
|
||||||
connection_stop_reading_from_linked_conn(conn);
|
connection_stop_reading_from_linked_conn(conn);
|
||||||
@ -548,14 +573,10 @@ connection_start_reading(connection_t *conn)
|
|||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|
||||||
/* if dummy conn then no socket and no event, nothing to do here */
|
if (connection_check_event(conn, conn->read_event) < 0) {
|
||||||
if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) {
|
|
||||||
tor_assert(!conn->read_event);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tor_assert(conn->read_event);
|
|
||||||
|
|
||||||
if (conn->linked) {
|
if (conn->linked) {
|
||||||
conn->reading_from_linked_conn = 1;
|
conn->reading_from_linked_conn = 1;
|
||||||
if (connection_should_read_from_linked_conn(conn))
|
if (connection_should_read_from_linked_conn(conn))
|
||||||
@ -594,7 +615,9 @@ connection_stop_writing(connection_t *conn)
|
|||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|
||||||
tor_assert(conn->write_event);
|
if (connection_check_event(conn, conn->write_event) < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (conn->linked) {
|
if (conn->linked) {
|
||||||
conn->writing_to_linked_conn = 0;
|
conn->writing_to_linked_conn = 0;
|
||||||
@ -620,7 +643,9 @@ connection_start_writing(connection_t *conn)
|
|||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|
||||||
tor_assert(conn->write_event);
|
if (connection_check_event(conn, conn->write_event) < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (conn->linked) {
|
if (conn->linked) {
|
||||||
conn->writing_to_linked_conn = 1;
|
conn->writing_to_linked_conn = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user