diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-03-24 06:05:14 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-03-24 06:05:14 +0000 |
commit | 13fdf51bc18428b5cf5e504d61a44f08204d0e22 (patch) | |
tree | c8af585601dec841236632a26554bd796501052e /src/or/circuituse.c | |
parent | 8fc1061b8484390c856e46db0017e759705a7017 (diff) | |
download | tor-13fdf51bc18428b5cf5e504d61a44f08204d0e22.tar tor-13fdf51bc18428b5cf5e504d61a44f08204d0e22.tar.gz |
Bulletproof connection_ap_handshake_attach_chosen_circuit
svn:r3855
Diffstat (limited to 'src/or/circuituse.c')
-rw-r--r-- | src/or/circuituse.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/or/circuituse.c b/src/or/circuituse.c index 669d96e94..e9c20f59a 100644 --- a/src/or/circuituse.c +++ b/src/or/circuituse.c @@ -979,8 +979,8 @@ consider_recording_trackhost(connection_t *conn, circuit_t *circ) { } /** Attempt to attach the connection <b>conn</b> to <b>circ</b>, and - * send a begin or resolve cell as appropriate. Return values for - * connection_ap_handshake_attach_chosen_circuit. */ + * send a begin or resolve cell as appropriate. Return values are as + * for connection_ap_handshake_attach_circuit. */ int connection_ap_handshake_attach_chosen_circuit(connection_t *conn, circuit_t *circ) @@ -992,6 +992,9 @@ connection_ap_handshake_attach_chosen_circuit(connection_t *conn, tor_assert(conn->socks_request); tor_assert(circ); + if (circ->state != CIRCUIT_STATE_OPEN) + return 0; + conn->state = AP_CONN_STATE_CIRCUIT_WAIT; if (!circ->timestamp_dirty) @@ -1001,9 +1004,11 @@ connection_ap_handshake_attach_chosen_circuit(connection_t *conn, tor_assert(conn->socks_request); if (conn->socks_request->command == SOCKS_COMMAND_CONNECT) { consider_recording_trackhost(conn, circ); - connection_ap_handshake_send_begin(conn, circ); + if (connection_ap_handshake_send_begin(conn, circ)<0) + return -1; } else { - connection_ap_handshake_send_resolve(conn, circ); + if (connection_ap_handshake_send_resolve(conn, circ)<0) + return -1; } return 1; |