diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-11-03 15:44:46 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-11-03 15:44:46 -0400 |
commit | 3cd520a52d50b9e901d33d0164d847d12a278f1b (patch) | |
tree | 7ba6f48f7245871f2572a4f209b23f0c284bf626 /src | |
parent | 3bb49c011006d042f8a3f802d7abb3e9da51b15b (diff) | |
parent | 7a45ef5a4706aab57abcf170c10080811223175e (diff) | |
download | tor-3cd520a52d50b9e901d33d0164d847d12a278f1b.tar.gz tor-3cd520a52d50b9e901d33d0164d847d12a278f1b.zip |
Merge branch 'maint-0.2.8' into maint-0.2.9
Diffstat (limited to 'src')
-rw-r--r-- | src/or/connection_edge.c | 9 | ||||
-rw-r--r-- | src/or/main.c | 31 | ||||
-rw-r--r-- | src/or/main.h | 2 |
3 files changed, 34 insertions, 8 deletions
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index 24842e4107..7b9c315a11 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -937,6 +937,15 @@ connection_ap_mark_as_pending_circuit_(entry_connection_t *entry_conn, untried_pending_connections = 1; smartlist_add(pending_entry_connections, entry_conn); + + /* Work-around for bug 19969: we handle pending_entry_connections at + * the end of run_main_loop_once(), but in many cases that function will + * take a very long time, if ever, to finish its call to event_base_loop(). + * + * So the fix is to tell it right now that it ought to finish its loop at + * its next available opportunity. + */ + tell_event_loop_to_finish(); } /** Mark <b>entry_conn</b> as no longer waiting for a circuit. */ diff --git a/src/or/main.c b/src/or/main.c index 013e301aff..66a8571901 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -591,6 +591,19 @@ connection_should_read_from_linked_conn(connection_t *conn) return 0; } +/** If we called event_base_loop() and told it to never stop until it + * runs out of events, now we've changed our mind: tell it we want it to + * finish. */ +void +tell_event_loop_to_finish(void) +{ + if (!called_loop_once) { + struct timeval tv = { 0, 0 }; + tor_event_base_loopexit(tor_libevent_get_base(), &tv); + called_loop_once = 1; /* hack to avoid adding more exit events */ + } +} + /** Helper: Tell the main loop to begin reading bytes into <b>conn</b> from * its linked connection, if it is not doing so already. Called by * connection_start_reading and connection_start_writing as appropriate. */ @@ -603,14 +616,10 @@ connection_start_reading_from_linked_conn(connection_t *conn) if (!conn->active_on_link) { conn->active_on_link = 1; smartlist_add(active_linked_connection_lst, conn); - if (!called_loop_once) { - /* This is the first event on the list; we won't be in LOOP_ONCE mode, - * so we need to make sure that the event_base_loop() actually exits at - * the end of its run through the current connections and lets us - * activate read events for linked connections. */ - struct timeval tv = { 0, 0 }; - tor_event_base_loopexit(tor_libevent_get_base(), &tv); - } + /* make sure that the event_base_loop() function exits at + * the end of its run through the current connections, so we can + * activate read events for linked connections. */ + tell_event_loop_to_finish(); } else { tor_assert(smartlist_contains(active_linked_connection_lst, conn)); } @@ -1373,6 +1382,12 @@ run_scheduled_events(time_t now) circuit_expire_old_circs_as_needed(now); } + if (!net_is_disabled()) { + /* This is usually redundant with circuit_build_needed_circs() above, + * but it is very fast when there is no work to do. */ + connection_ap_attach_pending(0); + } + /* 5. We do housekeeping for each connection... */ connection_or_set_bad_connections(NULL, 0); int i; diff --git a/src/or/main.h b/src/or/main.h index 0220ae3c57..07b22598b1 100644 --- a/src/or/main.h +++ b/src/or/main.h @@ -45,6 +45,8 @@ int connection_is_writing(connection_t *conn); MOCK_DECL(void,connection_stop_writing,(connection_t *conn)); MOCK_DECL(void,connection_start_writing,(connection_t *conn)); +void tell_event_loop_to_finish(void); + void connection_stop_reading_from_linked_conn(connection_t *conn); MOCK_DECL(int, connection_count_moribund, (void)); |