diff options
author | Roger Dingledine <arma@torproject.org> | 2003-02-06 08:00:49 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2003-02-06 08:00:49 +0000 |
commit | ceafe12ed67528ce4dd656f43bccb7c7a9f7317f (patch) | |
tree | 8f95a57e7fc71d62c919057fedb25dad33fcc424 /src/or/connection_ap.c | |
parent | c35373a2cfae66d41e4120469096acde10cea050 (diff) | |
download | tor-ceafe12ed67528ce4dd656f43bccb7c7a9f7317f.tar.gz tor-ceafe12ed67528ce4dd656f43bccb7c7a9f7317f.zip |
make reusing circuits work (and be the default)
performance is better, but not by much. not sure why yet.
svn:r153
Diffstat (limited to 'src/or/connection_ap.c')
-rw-r--r-- | src/or/connection_ap.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/or/connection_ap.c b/src/or/connection_ap.c index 978a9dd029..a47fb44360 100644 --- a/src/or/connection_ap.c +++ b/src/or/connection_ap.c @@ -123,20 +123,24 @@ int ap_handshake_process_socks(connection_t *conn) { } /* find the circuit that we should use, if there is one. */ - circ = NULL; /* FIXME don't reuse circs, at least for me. */ + circ = circuit_get_by_edge_type(EDGE_AP); /* now we're all ready to make an onion or send a begin */ - if(circ) { - if(circ->state == CIRCUIT_STATE_OPEN) { - if(ap_handshake_send_begin(conn, circ) < 0) { - circuit_close(circ); - return -1; - } + if(circ && circ->state == CIRCUIT_STATE_OPEN) { + /* add it into the linked list of topics on this circuit */ + log(LOG_DEBUG,"ap_handshake_process_socks(): attaching new conn to circ. n_aci %d.", circ->n_aci); + conn->next_topic = circ->p_conn; + circ->p_conn = conn; + + if(ap_handshake_send_begin(conn, circ) < 0) { + circuit_close(circ); + return -1; } } else { if(ap_handshake_create_onion(conn) < 0) { - circuit_close(circ); + if(circ) + circuit_close(circ); return -1; } } @@ -370,6 +374,7 @@ int connection_ap_process_data_cell(cell_t *cell, circuit_t *circ) { connection_t *conn; int topic_command; int topic_id; + static int num_seen=0; /* an incoming data cell has arrived */ @@ -379,6 +384,9 @@ int connection_ap_process_data_cell(cell_t *cell, circuit_t *circ) { *cell->payload = 0; topic_id = *(uint32_t *)cell->payload; log(LOG_DEBUG,"connection_ap_process_data_cell(): command %d topic %d", topic_command, topic_id); + num_seen++; + log(LOG_DEBUG,"connection_exit_process_data_cell(): Now seen %d data cells here.", num_seen); + circuit_consider_sending_sendme(circ, EDGE_AP); |