diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-12-05 19:15:27 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-12-05 19:15:27 +0000 |
commit | b03e8733f35b8a61cb0c7d5c68b5532db2b796a8 (patch) | |
tree | 9c0796b75f900d74fae9e87e55a23ff3b9c141f2 /src | |
parent | f0abb1a74b3946930a4a0df2dfb314bd44e64151 (diff) | |
download | tor-b03e8733f35b8a61cb0c7d5c68b5532db2b796a8.tar tor-b03e8733f35b8a61cb0c7d5c68b5532db2b796a8.tar.gz |
Change how OR conns get removed from the identity map; fix some warnings on shutdown.
svn:r5509
Diffstat (limited to 'src')
-rw-r--r-- | src/or/connection.c | 6 | ||||
-rw-r--r-- | src/or/connection_or.c | 21 | ||||
-rw-r--r-- | src/or/or.h | 1 |
3 files changed, 28 insertions, 0 deletions
diff --git a/src/or/connection.c b/src/or/connection.c index 176608090..953158341 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -257,6 +257,9 @@ connection_free(connection_t *conn) if (connection_speaks_cells(conn)) { if (conn->state == OR_CONN_STATE_OPEN) directory_set_dirty(); + if (!tor_digest_is_zero(conn->identity_digest)) { + connection_or_remove_from_identity_map(conn); + } } if (conn->type == CONN_TYPE_CONTROL) { conn->event_mask = 0; @@ -288,6 +291,9 @@ connection_free_all(void) carray[i]->event_mask = 0; control_update_global_event_mask(); + /* Unlink everything from the identity map. */ + connection_or_clear_identity_map(); + for (i=0;i<n;i++) _connection_free(carray[i]); diff --git a/src/or/connection_or.c b/src/or/connection_or.c index a092d3c9e..78a999615 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -59,6 +59,27 @@ connection_or_remove_from_identity_map(connection_t *conn) conn->next_with_same_id = NULL; } +/** Remove all entries from the identity-to-orconn map, and clear + * all identities in OR conns.*/ +void +connection_or_clear_identity_map(void) +{ + int i, n; + connection_t **carray; + + get_connection_array(&carray,&n); + for (i = 0; i < n; ++i) { + connection_t* conn = carray[i]; + if (conn->type == CONN_TYPE_OR) { + memset(conn->identity_digest, 0, DIGEST_LEN); + conn->next_with_same_id = NULL; + } + } + + digestmap_free(orconn_identity_map, NULL); + orconn_identity_map = NULL; +} + /** Change conn->identity_digest to digest, and add conn into * orconn_digest_map. */ static void diff --git a/src/or/or.h b/src/or/or.h index 9812ba237..e80ed71e1 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1663,6 +1663,7 @@ hostname_type_t parse_extended_hostname(char *address); /********************************* connection_or.c ***************************/ void connection_or_remove_from_identity_map(connection_t *conn); +void connection_or_clear_identity_map(void); connection_t *connection_or_get_by_identity_digest(const char *digest); int connection_or_reached_eof(connection_t *conn); |