aboutsummaryrefslogtreecommitdiff
path: root/src/or/main.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-03-11 10:50:36 -0500
committerNick Mathewson <nickm@torproject.org>2016-03-11 10:50:36 -0500
commit91d7cf50c6cb6eb1e2dc2b4a8eab489c10a759a6 (patch)
tree475bfe0606953e8a58327e01980d05104dce9190 /src/or/main.c
parente79da62645925f3286deb21740bbe91de9dafacc (diff)
downloadtor-91d7cf50c6cb6eb1e2dc2b4a8eab489c10a759a6.tar.gz
tor-91d7cf50c6cb6eb1e2dc2b4a8eab489c10a759a6.zip
Change behavior on missing/present event to warn instead of asserting.
Add a changes file.
Diffstat (limited to 'src/or/main.c')
-rw-r--r--src/or/main.c49
1 files changed, 37 insertions, 12 deletions
diff --git a/src/or/main.c b/src/or/main.c
index 3fb80e1759..f91049b80f 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -567,6 +567,35 @@ connection_is_reading(connection_t *conn)
(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. */
MOCK_IMPL(void,
connection_stop_reading,(connection_t *conn))
@@ -578,14 +607,10 @@ connection_stop_reading,(connection_t *conn))
return;
});
- /* if dummy conn then no socket and no event, nothing to do here */
- if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) {
- tor_assert(!conn->read_event);
+ if (connection_check_event(conn, conn->read_event) < 0) {
return;
}
- tor_assert(conn->read_event);
-
if (conn->linked) {
conn->reading_from_linked_conn = 0;
connection_stop_reading_from_linked_conn(conn);
@@ -609,14 +634,10 @@ connection_start_reading,(connection_t *conn))
return;
});
- /* if dummy conn then no socket and no event, nothing to do here */
- if (conn->type == CONN_TYPE_AP && TO_EDGE_CONN(conn)->is_dns_request) {
- tor_assert(!conn->read_event);
+ if (connection_check_event(conn, conn->read_event) < 0) {
return;
}
- tor_assert(conn->read_event);
-
if (conn->linked) {
conn->reading_from_linked_conn = 1;
if (connection_should_read_from_linked_conn(conn))
@@ -655,7 +676,9 @@ connection_stop_writing,(connection_t *conn))
return;
});
- tor_assert(conn->write_event);
+ if (connection_check_event(conn, conn->write_event) < 0) {
+ return;
+ }
if (conn->linked) {
conn->writing_to_linked_conn = 0;
@@ -681,7 +704,9 @@ connection_start_writing,(connection_t *conn))
return;
});
- tor_assert(conn->write_event);
+ if (connection_check_event(conn, conn->write_event) < 0) {
+ return;
+ }
if (conn->linked) {
conn->writing_to_linked_conn = 1;