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

[or-cvs] fix an assert trigger: when we have the rare case of accept...



Update of /home2/or/cvsroot/tor/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/tor/src/or

Modified Files:
	connection.c cpuworker.c main.c or.h 
Log Message:
fix an assert trigger: when we have the rare case of accepting
a conn on 0.0.0.0:0, then when we look through the connection array,
we'll find any of the workers. this is no good.


Index: connection.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.355
retrieving revision 1.356
diff -u -d -r1.355 -r1.356
--- connection.c	6 Apr 2005 06:43:21 -0000	1.355
+++ connection.c	6 Apr 2005 15:19:32 -0000	1.356
@@ -440,7 +440,7 @@
 #ifndef MS_WINDOWS
   /* REUSEADDR on normal places means you can rebind to the port
    * right after somebody else has let it go. But REUSEADDR on win32
-   * means to let you bind to the port _even when somebody else
+   * means you can bind to the port _even when somebody else
    * already has it bound_. So, don't do that on Win32. */
   setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (void*) &one, sizeof(one));
 #endif
@@ -1223,7 +1223,7 @@
 
 /** Return the conn to addr/port that has the most recent
  * timestamp_created, or NULL if no such conn exists. */
-connection_t *connection_exact_get_by_addr_port(uint32_t addr, uint16_t port) {
+connection_t *connection_or_exact_get_by_addr_port(uint32_t addr, uint16_t port) {
   int i, n;
   connection_t *conn, *best=NULL;
   connection_t **carray;
@@ -1231,7 +1231,10 @@
   get_connection_array(&carray,&n);
   for (i=0;i<n;i++) {
     conn = carray[i];
-    if (conn->addr == addr && conn->port == port && !conn->marked_for_close &&
+    if (conn->type == CONN_TYPE_OR &&
+        conn->addr == addr &&
+        conn->port == port &&
+        !conn->marked_for_close &&
         (!best || best->timestamp_created < conn->timestamp_created))
       best = conn;
   }

Index: cpuworker.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/cpuworker.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- cpuworker.c	6 Apr 2005 05:33:32 -0000	1.71
+++ cpuworker.c	6 Apr 2005 15:19:32 -0000	1.72
@@ -141,10 +141,10 @@
     /* parse out the circ it was talking about */
     tag_unpack(buf, &addr, &port, &circ_id);
     circ = NULL;
-    /* (Here we use connection_exact_get_by_addr_port rather than
+    /* (Here we use connection_or_exact_get_by_addr_port rather than
      * get_by_identity_digest: we want a specific port here in
      * case there are multiple connections.) */
-    p_conn = connection_exact_get_by_addr_port(addr,port);
+    p_conn = connection_or_exact_get_by_addr_port(addr,port);
     if (p_conn)
       circ = circuit_get_by_circid_orconn(circ_id, p_conn);
 
@@ -356,8 +356,8 @@
     log_fn(LOG_WARN,"assign_to_cpuworker failed. Ignoring.");
 }
 
-/** if cpuworker is defined, assert that he's idle, and use him. else,
- * look for an idle cpuworker and use him. if none idle, queue task onto
+/** If cpuworker is defined, assert that he's idle, and use him. Else,
+ * look for an idle cpuworker and use him. If none idle, queue task onto
  * the pending onion list and return.
  * If question_type is CPUWORKER_TASK_ONION then task is a circ.
  * No other question_types are allowed.

Index: main.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.482
retrieving revision 1.483
diff -u -d -r1.482 -r1.483
--- main.c	2 Apr 2005 22:11:24 -0000	1.482
+++ main.c	6 Apr 2005 15:19:32 -0000	1.483
@@ -838,17 +838,6 @@
 
   current_second = now.tv_sec; /* remember which second it is, for next time */
 
-#if 0
-  for (i=0;i<nfds;i++) {
-    conn = connection_array[i];
-    if (connection_has_pending_tls_data(conn) &&
-        connection_is_reading(conn)) {
-      log_fn(LOG_DEBUG,"sock %d has pending bytes.",conn->s);
-      return; /* has pending bytes to read; don't let poll wait. */
-    }
-  }
-#endif
-
   if (evtimer_add(timeout_event, &one_second))
     log_fn(LOG_ERR,
            "Error from libevent when setting one-second timeout event");

Index: or.h
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.587
retrieving revision 1.588
diff -u -d -r1.587 -r1.588
--- or.h	6 Apr 2005 06:43:21 -0000	1.587
+++ or.h	6 Apr 2005 15:19:32 -0000	1.588
@@ -1286,7 +1286,7 @@
 int connection_handle_write(connection_t *conn);
 void connection_write_to_buf(const char *string, size_t len, connection_t *conn);
 
-connection_t *connection_exact_get_by_addr_port(uint32_t addr, uint16_t port);
+connection_t *connection_or_exact_get_by_addr_port(uint32_t addr, uint16_t port);
 connection_t *connection_get_by_identity_digest(const char *digest, int type);
 connection_t *connection_get_by_global_id(uint32_t id);