diff options
author | Roger Dingledine <arma@torproject.org> | 2004-02-18 01:21:20 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2004-02-18 01:21:20 +0000 |
commit | 3456adec3150858ed0a83c734fc4179a25cbae24 (patch) | |
tree | 8ba860106acec1eb0fd09af126997a3f97a0f73a /src/or/circuit.c | |
parent | 39efb0ed523aa956cca56f616d08391bcfdad14a (diff) | |
download | tor-3456adec3150858ed0a83c734fc4179a25cbae24.tar tor-3456adec3150858ed0a83c734fc4179a25cbae24.tar.gz |
adding the reattach-after-timeout feature wasn't so easy after all.
maybe it works now.
svn:r1101
Diffstat (limited to 'src/or/circuit.c')
-rw-r--r-- | src/or/circuit.c | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/src/or/circuit.c b/src/or/circuit.c index 67c79fcbc..4b156bb33 100644 --- a/src/or/circuit.c +++ b/src/or/circuit.c @@ -677,13 +677,40 @@ void circuit_close(circuit_t *circ) { circuit_free(circ); } +void circuit_detach_stream(circuit_t *circ, connection_t *conn) { + connection_t *prevconn; + + assert(circ); + assert(conn); + + if(conn == circ->p_streams) { + circ->p_streams = conn->next_stream; + return; + } + if(conn == circ->n_streams) { + circ->n_streams = conn->next_stream; + return; + } + for(prevconn = circ->p_streams; prevconn && prevconn->next_stream && prevconn->next_stream != conn; prevconn = prevconn->next_stream) ; + if(prevconn && prevconn->next_stream) { + prevconn->next_stream = conn->next_stream; + return; + } + for(prevconn = circ->n_streams; prevconn && prevconn->next_stream && prevconn->next_stream != conn; prevconn = prevconn->next_stream) ; + if(prevconn && prevconn->next_stream) { + prevconn->next_stream = conn->next_stream; + return; + } + log_fn(LOG_ERR,"edge conn not in circuit's list?"); + assert(0); /* should never get here */ +} + void circuit_about_to_close_connection(connection_t *conn) { /* send destroys for all circuits using conn */ /* currently, we assume it's too late to flush conn's buf here. * down the road, maybe we'll consider that eof doesn't mean can't-write */ circuit_t *circ; - connection_t *prevconn; switch(conn->type) { case CONN_TYPE_OR: @@ -714,26 +741,8 @@ void circuit_about_to_close_connection(connection_t *conn) { log_fn(LOG_WARN,"1: I called connection_edge_end redundantly."); } - if(conn == circ->p_streams) { - circ->p_streams = conn->next_stream; - return; - } - if(conn == circ->n_streams) { - circ->n_streams = conn->next_stream; - return; - } - for(prevconn = circ->p_streams; prevconn && prevconn->next_stream && prevconn->next_stream != conn; prevconn = prevconn->next_stream) ; - if(prevconn && prevconn->next_stream) { - prevconn->next_stream = conn->next_stream; - return; - } - for(prevconn = circ->n_streams; prevconn && prevconn->next_stream && prevconn->next_stream != conn; prevconn = prevconn->next_stream) ; - if(prevconn && prevconn->next_stream) { - prevconn->next_stream = conn->next_stream; - return; - } - log_fn(LOG_ERR,"edge conn not in circuit's list?"); - assert(0); /* should never get here */ + circuit_detach_stream(circ, conn); + } /* end switch */ } |