Change how OR conns get removed from the identity map; fix some warnings on shutdown.

svn:r5509
This commit is contained in:
Nick Mathewson 2005-12-05 19:15:27 +00:00
parent f0abb1a74b
commit b03e8733f3
3 changed files with 28 additions and 0 deletions

View File

@ -257,6 +257,9 @@ connection_free(connection_t *conn)
if (connection_speaks_cells(conn)) { if (connection_speaks_cells(conn)) {
if (conn->state == OR_CONN_STATE_OPEN) if (conn->state == OR_CONN_STATE_OPEN)
directory_set_dirty(); directory_set_dirty();
if (!tor_digest_is_zero(conn->identity_digest)) {
connection_or_remove_from_identity_map(conn);
}
} }
if (conn->type == CONN_TYPE_CONTROL) { if (conn->type == CONN_TYPE_CONTROL) {
conn->event_mask = 0; conn->event_mask = 0;
@ -288,6 +291,9 @@ connection_free_all(void)
carray[i]->event_mask = 0; carray[i]->event_mask = 0;
control_update_global_event_mask(); control_update_global_event_mask();
/* Unlink everything from the identity map. */
connection_or_clear_identity_map();
for (i=0;i<n;i++) for (i=0;i<n;i++)
_connection_free(carray[i]); _connection_free(carray[i]);

View File

@ -59,6 +59,27 @@ connection_or_remove_from_identity_map(connection_t *conn)
conn->next_with_same_id = NULL; 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 /** Change conn->identity_digest to digest, and add conn into
* orconn_digest_map. */ * orconn_digest_map. */
static void static void

View File

@ -1663,6 +1663,7 @@ hostname_type_t parse_extended_hostname(char *address);
/********************************* connection_or.c ***************************/ /********************************* connection_or.c ***************************/
void connection_or_remove_from_identity_map(connection_t *conn); 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); connection_t *connection_or_get_by_identity_digest(const char *digest);
int connection_or_reached_eof(connection_t *conn); int connection_or_reached_eof(connection_t *conn);