Commit 27b35f97 authored by Nick Mathewson's avatar Nick Mathewson 🐘
Browse files

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


svn:r5509
parent 97c8ab74
Loading
Loading
Loading
Loading
+6 −0
Changes for trunk/src/or/connection.c: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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]);

+21 −0
Changes for trunk/src/or/connection_or.c: 21 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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
+1 −0
Changes for trunk/src/or/or.h: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -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);