diff options
author | Roger Dingledine <arma@torproject.org> | 2004-10-11 22:19:12 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2004-10-11 22:19:12 +0000 |
commit | 24f9946db160f9c2a0a769073013507f30e8346c (patch) | |
tree | 11c52adc4995d90b38796c7e80f125b696a8e747 | |
parent | 5c53c63aa0f9e98e5aec61311a898bb76df3849a (diff) | |
download | tor-24f9946db160f9c2a0a769073013507f30e8346c.tar tor-24f9946db160f9c2a0a769073013507f30e8346c.tar.gz |
fix paul gardner's assert bug.
sometimes circuit_get_open_circ_or_launch() can return 0 but not
return a circuit, e.g. because too many circuits have failed recently
so the new one didn't launch. we need to tolerate that.
svn:r2438
-rw-r--r-- | src/or/circuituse.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/or/circuituse.c b/src/or/circuituse.c index 70eb0363f..057a2a85a 100644 --- a/src/or/circuituse.c +++ b/src/or/circuituse.c @@ -775,6 +775,7 @@ int connection_ap_handshake_attach_circuit(connection_t *conn) { return retval; /* We have found a suitable circuit for our conn. Hurray. */ + tor_assert(circ); log_fn(LOG_DEBUG,"Attaching apconn to general circ %d (stream %d sec old).", circ->n_circ_id, conn_age); @@ -801,9 +802,9 @@ int connection_ap_handshake_attach_circuit(connection_t *conn) { retval = circuit_get_open_circ_or_launch(conn, CIRCUIT_PURPOSE_C_REND_JOINED, &rendcirc); if(retval < 0) return -1; /* failed */ - tor_assert(rendcirc); if(retval > 0) { + tor_assert(rendcirc); /* one is already established, attach */ log_fn(LOG_INFO,"rend joined circ %d already here. attaching. (stream %d sec old)", rendcirc->n_circ_id, conn_age); @@ -813,7 +814,7 @@ int connection_ap_handshake_attach_circuit(connection_t *conn) { return 1; } - if(rendcirc->purpose == CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED) { + if(rendcirc && rendcirc->purpose == CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED) { log_fn(LOG_INFO,"pending-join circ %d already here, with intro ack. Stalling. (stream %d sec old)", rendcirc->n_circ_id, conn_age); return 0; } @@ -821,21 +822,20 @@ int connection_ap_handshake_attach_circuit(connection_t *conn) { /* it's on its way. find an intro circ. */ retval = circuit_get_open_circ_or_launch(conn, CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT, &introcirc); if(retval < 0) return -1; /* failed */ - tor_assert(introcirc); if(retval > 0) { /* one has already sent the intro. keep waiting. */ + tor_assert(introcirc); log_fn(LOG_INFO,"Intro circ %d present and awaiting ack (rend %d). Stalling. (stream %d sec old)", - introcirc->n_circ_id, rendcirc->n_circ_id, conn_age); + introcirc->n_circ_id, rendcirc ? rendcirc->n_circ_id : 0, conn_age); return 0; } - /* now both rendcirc and introcirc are defined, and neither is finished */ + /* now rendcirc and introcirc are each either undefined or not finished */ - if(rendcirc->purpose == CIRCUIT_PURPOSE_C_REND_READY) { + if(rendcirc && introcirc && rendcirc->purpose == CIRCUIT_PURPOSE_C_REND_READY) { log_fn(LOG_INFO,"ready rend circ %d already here (no intro-ack yet on intro %d). (stream %d sec old)", rendcirc->n_circ_id, introcirc->n_circ_id, conn_age); - /* look around for any new intro circs that should introduce */ tor_assert(introcirc->purpose == CIRCUIT_PURPOSE_C_INTRODUCING); if(introcirc->state == CIRCUIT_STATE_OPEN) { @@ -853,7 +853,9 @@ int connection_ap_handshake_attach_circuit(connection_t *conn) { } } - log_fn(LOG_INFO,"Intro (%d) and rend (%d) circs are not both ready. Stalling conn. (%d sec old)", introcirc->n_circ_id, rendcirc->n_circ_id, conn_age); + log_fn(LOG_INFO,"Intro (%d) and rend (%d) circs are not both ready. Stalling conn. (%d sec old)", + introcirc ? introcirc->n_circ_id : 0, + rendcirc ? rendcirc->n_circ_id : 0, conn_age); return 0; } } |