diff options
author | George Kadianakis <desnacked@gmail.com> | 2011-08-13 20:29:22 +0200 |
---|---|---|
committer | George Kadianakis <desnacked@gmail.com> | 2011-08-13 20:29:22 +0200 |
commit | a5fd07d178d1260ec7073c6ea0db185b8527fc68 (patch) | |
tree | 3fb5781bbaee83ceff27a14e3e046d768e880c1a /src/or/connection.c | |
parent | 10d9bcb2a2fe4e49afd88251fe92181c2ffbc231 (diff) | |
download | tor-a5fd07d178d1260ec7073c6ea0db185b8527fc68.tar.gz tor-a5fd07d178d1260ec7073c6ea0db185b8527fc68.zip |
Move connection_free_all() to the bottom of connection.c to enjoy maximum visibility.
Diffstat (limited to 'src/or/connection.c')
-rw-r--r-- | src/or/connection.c | 69 |
1 files changed, 34 insertions, 35 deletions
diff --git a/src/or/connection.c b/src/or/connection.c index b885d094cc..67e9442a9c 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -561,41 +561,6 @@ connection_free(connection_t *conn) _connection_free(conn); } -/** Call _connection_free() on every connection in our array, and release all - * storage held by connection.c. This is used by cpuworkers and dnsworkers - * when they fork, so they don't keep resources held open (especially - * sockets). - * - * Don't do the checks in connection_free(), because they will - * fail. - */ -void -connection_free_all(void) -{ - smartlist_t *conns = get_connection_array(); - - /* We don't want to log any messages to controllers. */ - SMARTLIST_FOREACH(conns, connection_t *, conn, - if (conn->type == CONN_TYPE_CONTROL) - TO_CONTROL_CONN(conn)->event_mask = 0); - - control_update_global_event_mask(); - - /* Unlink everything from the identity map. */ - connection_or_clear_identity_map(); - - /* Clear out our list of broken connections */ - clear_broken_connection_map(0); - - SMARTLIST_FOREACH(conns, connection_t *, conn, _connection_free(conn)); - - if (outgoing_addrs) { - SMARTLIST_FOREACH(outgoing_addrs, void*, addr, tor_free(addr)); - smartlist_free(outgoing_addrs); - outgoing_addrs = NULL; - } -} - /** * Called when we're about to finally unlink and free a connection: * perform necessary accounting and cleanup @@ -4163,3 +4128,37 @@ proxy_type_to_string(int proxy_type) return NULL; /*Unreached*/ } +/** Call _connection_free() on every connection in our array, and release all + * storage held by connection.c. This is used by cpuworkers and dnsworkers + * when they fork, so they don't keep resources held open (especially + * sockets). + * + * Don't do the checks in connection_free(), because they will + * fail. + */ +void +connection_free_all(void) +{ + smartlist_t *conns = get_connection_array(); + + /* We don't want to log any messages to controllers. */ + SMARTLIST_FOREACH(conns, connection_t *, conn, + if (conn->type == CONN_TYPE_CONTROL) + TO_CONTROL_CONN(conn)->event_mask = 0); + + control_update_global_event_mask(); + + /* Unlink everything from the identity map. */ + connection_or_clear_identity_map(); + + /* Clear out our list of broken connections */ + clear_broken_connection_map(0); + + SMARTLIST_FOREACH(conns, connection_t *, conn, _connection_free(conn)); + + if (outgoing_addrs) { + SMARTLIST_FOREACH(outgoing_addrs, void*, addr, tor_free(addr)); + smartlist_free(outgoing_addrs); + outgoing_addrs = NULL; + } +} |