[or-cvs] log correctly if decoding onion failed

Roger Dingledine arma at seul.org
Sun Apr 25 04:49:13 UTC 2004


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

Modified Files:
	connection.c cpuworker.c 
Log Message:
log correctly if decoding onion failed


Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.196
retrieving revision 1.197
diff -u -d -r1.196 -r1.197
--- connection.c	24 Apr 2004 22:17:50 -0000	1.196
+++ connection.c	25 Apr 2004 04:49:11 -0000	1.197
@@ -774,18 +774,20 @@
   }
 }
 
+/* get the conn to addr/port that has the most recent timestamp_created */
 connection_t *connection_exact_get_by_addr_port(uint32_t addr, uint16_t port) {
   int i, n;
-  connection_t *conn;
+  connection_t *conn, *best=NULL;
   connection_t **carray;
 
   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)
-      return conn;
+    if(conn->addr == addr && conn->port == port && !conn->marked_for_close &&
+       (!best || best->timestamp_created < conn->timestamp_created))
+      best = conn;
   }
-  return NULL;
+  return best;
 }
 
 connection_t *connection_twin_get_by_addr_port(uint32_t addr, uint16_t port) {

Index: cpuworker.c
===================================================================
RCS file: /home/or/cvsroot/src/or/cpuworker.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- cpuworker.c	24 Apr 2004 22:17:50 -0000	1.29
+++ cpuworker.c	25 Apr 2004 04:49:11 -0000	1.30
@@ -102,16 +102,17 @@
     if(p_conn)
       circ = circuit_get_by_circ_id_conn(circ_id, p_conn);
 
+    if(success == 0) {
+      log_fn(LOG_WARN,"decoding onionskin failed. Closing.");
+      if(circ)
+        circuit_mark_for_close(circ);
+      goto done_processing;
+    }
     if(!circ) {
       log_fn(LOG_INFO,"processed onion for a circ that's gone. Dropping.");
       goto done_processing;
     }
     assert(circ->p_conn);
-    if(success == 0) {
-      log_fn(LOG_WARN,"decoding onionskin failed. Closing.");
-      circuit_mark_for_close(circ);
-      goto done_processing;
-    }
     if(onionskin_answer(circ, buf+TAG_LEN, buf+TAG_LEN+ONIONSKIN_REPLY_LEN) < 0) {
       log_fn(LOG_WARN,"onionskin_answer failed. Closing.");
       circuit_mark_for_close(circ);



More information about the tor-commits mailing list