diff options
author | Roger Dingledine <arma@torproject.org> | 2005-04-06 15:19:32 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2005-04-06 15:19:32 +0000 |
commit | 9cbaf4603d56a521b9d6e82489cd5aea624a395b (patch) | |
tree | 2f16eecbcba87929a4910556c4c04f5b85919aae /src | |
parent | 88dc243bb53d8e3a320d04ce525452e692df4fb6 (diff) | |
download | tor-9cbaf4603d56a521b9d6e82489cd5aea624a395b.tar.gz tor-9cbaf4603d56a521b9d6e82489cd5aea624a395b.zip |
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.
svn:r4027
Diffstat (limited to 'src')
-rw-r--r-- | src/or/connection.c | 9 | ||||
-rw-r--r-- | src/or/cpuworker.c | 8 | ||||
-rw-r--r-- | src/or/main.c | 11 | ||||
-rw-r--r-- | src/or/or.h | 2 |
4 files changed, 11 insertions, 19 deletions
diff --git a/src/or/connection.c b/src/or/connection.c index 39ebf2870e..270deb9dc7 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -440,7 +440,7 @@ static int connection_create_listener(const char *bindaddress, uint16_t bindport #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 @@ void connection_write_to_buf(const char *string, size_t len, connection_t *conn) /** 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 @@ connection_t *connection_exact_get_by_addr_port(uint32_t addr, uint16_t port) { 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; } diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c index e820f939be..c2a7fe4f5b 100644 --- a/src/or/cpuworker.c +++ b/src/or/cpuworker.c @@ -141,10 +141,10 @@ int connection_cpu_process_inbuf(connection_t *conn) { /* 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 @@ static void process_pending_task(connection_t *cpuworker) { 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. diff --git a/src/or/main.c b/src/or/main.c index ec07e0fcce..e4d1d24398 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -838,17 +838,6 @@ static void second_elapsed_callback(int fd, short event, void *args) 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"); diff --git a/src/or/or.h b/src/or/or.h index 6dbe98b350..6d1467e79a 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1286,7 +1286,7 @@ int connection_outbuf_too_full(connection_t *conn); 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); |