diff options
author | Roger Dingledine <arma@torproject.org> | 2004-04-25 04:49:11 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2004-04-25 04:49:11 +0000 |
commit | e355ed0e154ef34122f6c4be0a0f243d8173a56c (patch) | |
tree | d5eefdebf107c04a8922991a23e62da24d1625ae /src/or | |
parent | 6a45028ccbb8ff18aa07e7853e12a04a1102fb3e (diff) | |
download | tor-e355ed0e154ef34122f6c4be0a0f243d8173a56c.tar tor-e355ed0e154ef34122f6c4be0a0f243d8173a56c.tar.gz |
log correctly if decoding onion failed
svn:r1690
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/connection.c | 10 | ||||
-rw-r--r-- | src/or/cpuworker.c | 11 |
2 files changed, 12 insertions, 9 deletions
diff --git a/src/or/connection.c b/src/or/connection.c index 299d0d2d8..66046a5a8 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -774,18 +774,20 @@ void connection_write_to_buf(const char *string, int len, connection_t *conn) { } } +/* 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) { diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c index 8f6d67a5c..09b8c1e72 100644 --- a/src/or/cpuworker.c +++ b/src/or/cpuworker.c @@ -102,16 +102,17 @@ int connection_cpu_process_inbuf(connection_t *conn) { 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); |