[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Change how OR conns get removed from the identity map; fix ...



Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv11897/src/or

Modified Files:
	connection.c connection_or.c or.h 
Log Message:
Change how OR conns get removed from the identity map; fix some warnings on shutdown.

Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.424
retrieving revision 1.425
diff -u -d -r1.424 -r1.425
--- connection.c	30 Nov 2005 04:28:41 -0000	1.424
+++ connection.c	5 Dec 2005 19:15:27 -0000	1.425
@@ -257,6 +257,9 @@
   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 @@
       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]);
 

Index: connection_or.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection_or.c,v
retrieving revision 1.199
retrieving revision 1.200
diff -u -d -r1.199 -r1.200
--- connection_or.c	30 Nov 2005 06:27:59 -0000	1.199
+++ connection_or.c	5 Dec 2005 19:15:27 -0000	1.200
@@ -59,6 +59,27 @@
   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

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.747
retrieving revision 1.748
diff -u -d -r1.747 -r1.748
--- or.h	3 Dec 2005 02:12:37 -0000	1.747
+++ or.h	5 Dec 2005 19:15:27 -0000	1.748
@@ -1663,6 +1663,7 @@
 /********************************* 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);