From b03e8733f35b8a61cb0c7d5c68b5532db2b796a8 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 5 Dec 2005 19:15:27 +0000 Subject: [PATCH] Change how OR conns get removed from the identity map; fix some warnings on shutdown. svn:r5509 --- src/or/connection.c | 6 ++++++ src/or/connection_or.c | 21 +++++++++++++++++++++ src/or/or.h | 1 + 3 files changed, 28 insertions(+) diff --git a/src/or/connection.c b/src/or/connection.c index 1766080904..9531583413 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;inext_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 9812ba237d..e80ed71e11 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);