From d37fae2f4edb03095f943577f78b518f75f6ca71 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Tue, 9 Sep 2008 06:25:39 +0000 Subject: Catch and report a few more bootstrapping failure cases when Tor fails to establish a TCP connection. Cleanup on 0.2.1.x. svn:r16803 --- src/or/connection_or.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src/or/connection_or.c') diff --git a/src/or/connection_or.c b/src/or/connection_or.c index 96b2074c40..5797e5ea16 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -492,6 +492,21 @@ connection_or_get_by_identity_digest(const char *digest) return best; } +/** conn is in the 'connecting' state, and it failed to complete + * a TCP connection. Send notifications appropriately. + * + * reason specifies the or_conn_end_reason for the failure; + * msg specifies the strerror-style error message. + */ +void +connection_or_connect_failed(or_connection_t *conn, + int reason, const char *msg) +{ + control_event_or_conn_status(conn, OR_CONN_EVENT_FAILED, reason); + if (!authdir_mode_tests_reachability(get_options())) + control_event_bootstrap_problem(msg, reason); +} + /** Launch a new OR connection to addr:port and expect to * handshake with an OR with identity digest id_digest. * @@ -548,11 +563,9 @@ connection_or_connect(const tor_addr_t *_addr, uint16_t port, time(NULL)); router_set_status(conn->identity_digest, 0); } - control_event_or_conn_status(conn, OR_CONN_EVENT_FAILED, - errno_to_orconn_end_reason(socket_error)); - if (!authdir_mode_tests_reachability(options)) - control_event_bootstrap_problem(tor_socket_strerror(socket_error), - errno_to_orconn_end_reason(socket_error)); + connection_or_connect_failed(conn, + errno_to_orconn_end_reason(socket_error), + tor_socket_strerror(socket_error)); connection_free(TO_CONN(conn)); return NULL; case 0: -- cgit v1.2.3-54-g00ecf