summaryrefslogtreecommitdiff
path: root/src/or/circuit.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-05-06 11:08:04 +0000
committerRoger Dingledine <arma@torproject.org>2004-05-06 11:08:04 +0000
commit9bf9ca4d094926acfc0b0a50f6fd12fcbb310d0d (patch)
treeaf07d3a5db87ababc75159fca2804f76ab01655c /src/or/circuit.c
parente6477a8e168ad4d9f367172785e1fcca14d46f0d (diff)
downloadtor-9bf9ca4d094926acfc0b0a50f6fd12fcbb310d0d.tar.gz
tor-9bf9ca4d094926acfc0b0a50f6fd12fcbb310d0d.zip
bugfix: add a circ->resolving_streams field, and make dns resolving streams not actually in the connection_array until they're done resolving.
bugfix: actually complain if we duplicate mark-for-close a circuit add more logging for relay ends that claim dns resolve failed, so we can find out why they're not being retried. svn:r1798
Diffstat (limited to 'src/or/circuit.c')
-rw-r--r--src/or/circuit.c51
1 files changed, 45 insertions, 6 deletions
diff --git a/src/or/circuit.c b/src/or/circuit.c
index 5987019488..7643f15df0 100644
--- a/src/or/circuit.c
+++ b/src/or/circuit.c
@@ -227,6 +227,10 @@ circuit_t *circuit_get_by_circ_id_conn(uint16_t circ_id, connection_t *conn) {
if(tmpconn == conn)
return circ;
}
+ for(tmpconn = circ->resolving_streams; tmpconn; tmpconn = tmpconn->next_stream) {
+ if(tmpconn == conn)
+ return circ;
+ }
}
}
return NULL;
@@ -250,6 +254,9 @@ circuit_t *circuit_get_by_conn(connection_t *conn) {
for(tmpconn = circ->n_streams; tmpconn; tmpconn=tmpconn->next_stream)
if(tmpconn == conn)
return circ;
+ for(tmpconn = circ->resolving_streams; tmpconn; tmpconn=tmpconn->next_stream)
+ if(tmpconn == conn)
+ return circ;
}
return NULL;
}
@@ -905,6 +912,12 @@ relay_lookup_conn(circuit_t *circ, cell_t *cell, int cell_direction)
return tmpconn;
}
}
+ for(tmpconn = circ->resolving_streams; tmpconn; tmpconn=tmpconn->next_stream) {
+ if(rh.stream_id == tmpconn->stream_id) {
+ log_fn(LOG_DEBUG,"found conn for stream %d.", rh.stream_id);
+ return tmpconn;
+ }
+ }
return NULL; /* probably a begin relay cell */
}
@@ -985,7 +998,7 @@ int _circuit_mark_for_close(circuit_t *circ) {
connection_t *conn;
assert_circuit_ok(circ);
- if (circ->marked_for_close < 0)
+ if (circ->marked_for_close)
return -1;
if(circ->state == CIRCUIT_STATE_ONIONSKIN_PENDING) {
@@ -1010,14 +1023,18 @@ int _circuit_mark_for_close(circuit_t *circ) {
if(circ->n_conn)
connection_send_destroy(circ->n_circ_id, circ->n_conn);
- for(conn=circ->n_streams; conn; conn=conn->next_stream) {
+ for(conn=circ->n_streams; conn; conn=conn->next_stream)
connection_edge_destroy(circ->n_circ_id, conn);
+ while(circ->resolving_streams) {
+ conn = circ->resolving_streams;
+ circ->resolving_streams = conn->next_stream;
+ log_fn(LOG_INFO,"Freeing resolving-conn.");
+ connection_free(conn);
}
if(circ->p_conn)
connection_send_destroy(circ->p_circ_id, circ->p_conn);
- for(conn=circ->p_streams; conn; conn=conn->next_stream) {
+ for(conn=circ->p_streams; conn; conn=conn->next_stream)
connection_edge_destroy(circ->p_circ_id, conn);
- }
circ->marked_for_close = 1;
@@ -1042,16 +1059,38 @@ void circuit_detach_stream(circuit_t *circ, connection_t *conn) {
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(conn == circ->resolving_streams) {
+ circ->resolving_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) ;
+
+ 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;
}
+
+ for(prevconn = circ->resolving_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?");
tor_assert(0); /* should never get here */
}