cleanup so connection_ap_handshake_attach_chosen_circuit() always

gets open circs.


svn:r3856
This commit is contained in:
Roger Dingledine 2005-03-24 06:18:59 +00:00
parent 13fdf51bc1
commit 09ef2b7e41
2 changed files with 5 additions and 3 deletions

View File

@ -991,9 +991,7 @@ connection_ap_handshake_attach_chosen_circuit(connection_t *conn,
conn->state == AP_CONN_STATE_CONTROLLER_WAIT); conn->state == AP_CONN_STATE_CONTROLLER_WAIT);
tor_assert(conn->socks_request); tor_assert(conn->socks_request);
tor_assert(circ); tor_assert(circ);
tor_assert(circ->state == CIRCUIT_STATE_OPEN);
if (circ->state != CIRCUIT_STATE_OPEN)
return 0;
conn->state = AP_CONN_STATE_CIRCUIT_WAIT; conn->state = AP_CONN_STATE_CIRCUIT_WAIT;

View File

@ -745,6 +745,10 @@ static int handle_control_attachstream(connection_t *conn, uint32_t len,
send_control_error(conn, ERR_NO_CIRC, "No circuit found with given ID"); send_control_error(conn, ERR_NO_CIRC, "No circuit found with given ID");
return 0; return 0;
} }
if (circ->state != CIRCUIT_STATE_OPEN) {
send_control_error(conn, ERR_INTERNAL, "Refuse to attach stream to non-open circ.");
return 0;
}
if (connection_ap_handshake_attach_chosen_circuit(ap_conn, circ) != 1) { if (connection_ap_handshake_attach_chosen_circuit(ap_conn, circ) != 1) {
send_control_error(conn, ERR_INTERNAL, "Unable to attach stream."); send_control_error(conn, ERR_INTERNAL, "Unable to attach stream.");
return 0; return 0;