diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-03-02 03:13:05 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-03-02 03:13:05 +0000 |
commit | e14f812a67e2816dc3fb9b8fcc2bf83fb8d93559 (patch) | |
tree | 27a0f5a623e8b51f2b69d4e90aaf1e991d86849d /src/or | |
parent | b0b396a7ce77fd68ef900e5a3096ee1961389327 (diff) | |
download | tor-e14f812a67e2816dc3fb9b8fcc2bf83fb8d93559.tar.gz tor-e14f812a67e2816dc3fb9b8fcc2bf83fb8d93559.zip |
Still more code to make sure we send the right number and kind of RELAY END cells
svn:r3723
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/circuitlist.c | 6 | ||||
-rw-r--r-- | src/or/connection_edge.c | 4 | ||||
-rw-r--r-- | src/or/main.c | 2 | ||||
-rw-r--r-- | src/or/relay.c | 24 |
4 files changed, 26 insertions, 10 deletions
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c index 0153297b86..03a9951500 100644 --- a/src/or/circuitlist.c +++ b/src/or/circuitlist.c @@ -396,8 +396,12 @@ int _circuit_mark_for_close(circuit_t *circ) { while (circ->resolving_streams) { conn = circ->resolving_streams; circ->resolving_streams = conn->next_stream; - if (!conn->marked_for_close) + if (!conn->marked_for_close) { + /* The other side will see a DESTROY, and infer that the connections + * are closing because the circuit is getting torn down. No need + * to send an end cell*/ connection_mark_for_close(conn); + } } if (circ->p_conn) connection_send_destroy(circ->p_circ_id, circ->p_conn); diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index c30fd5285c..f0a9fbde26 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -78,8 +78,7 @@ int connection_edge_process_inbuf(connection_t *conn, int package_partial) { case AP_CONN_STATE_OPEN: case EXIT_CONN_STATE_OPEN: if (connection_edge_package_raw_inbuf(conn, package_partial) < 0) { - /* XXXX We can't tell *why* package failed. -NM */ - connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer); + /* (We already sent an end cell if possible) */ connection_mark_for_close(conn); return -1; } @@ -275,6 +274,7 @@ void connection_ap_expire_beginning(void) { if (!circ) { /* it's vanished? */ log_fn(LOG_INFO,"Conn is waiting (address %s), but lost its circ.", conn->socks_request->address); + conn->has_sent_end = 1; /* No circuit to receive end cell. */ connection_mark_for_close(conn); continue; } diff --git a/src/or/main.c b/src/or/main.c index 3a1984d768..83bd105301 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -358,6 +358,8 @@ conn_read_callback(int fd, short event, void *_conn) tor_assert(0); #endif #endif + if (CONN_IS_EDGE(conn)) + connection_edge_end_errno(conn, conn->cpath_layer); connection_mark_for_close(conn); } } diff --git a/src/or/relay.c b/src/or/relay.c index 8a6ba88057..3df76804e4 100644 --- a/src/or/relay.c +++ b/src/or/relay.c @@ -683,8 +683,7 @@ connection_edge_process_relay_cell_not_open( conn->socks_request->has_finished = 1; /* handle anything that might have queued */ if (connection_edge_package_raw_inbuf(conn, 1) < 0) { - /* XXXX we can't tell why package failed. -NM */ - connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer); + /* (We already sent an end cell if possible) */ connection_mark_for_close(conn); return 0; } @@ -903,7 +902,12 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, conn->package_window += STREAMWINDOW_INCREMENT; log_fn(LOG_DEBUG,"stream-level sendme, packagewindow now %d.", conn->package_window); connection_start_reading(conn); - connection_edge_package_raw_inbuf(conn, 1); /* handle whatever might still be on the inbuf */ + /* handle whatever might still be on the inbuf */ + if (connection_edge_package_raw_inbuf(conn, 1) < 0) { + /* (We already sent an end cell if possible) */ + connection_mark_for_close(conn); + return 0; + } return 0; case RELAY_COMMAND_RESOLVE: if (layer_hint) { @@ -952,7 +956,8 @@ uint64_t stats_n_data_bytes_received = 0; * and the appropriate package windows aren't empty, grab a cell * and send it down the circuit. * - * Return -1 if conn should be marked for close, else return 0. + * Return -1 (and send a RELAY_END cell if necessary) if conn should + * be marked for close, else return 0. */ int connection_edge_package_raw_inbuf(connection_t *conn, int package_partial) { size_t amount_to_process, length; @@ -966,7 +971,7 @@ repeat_connection_edge_package_raw_inbuf: circ = circuit_get_by_conn(conn); if (!circ) { - log_fn(LOG_INFO,"conn has no circuits! Closing."); + log_fn(LOG_INFO,"conn has no circuit! Closing."); return -1; } @@ -1006,7 +1011,8 @@ repeat_connection_edge_package_raw_inbuf: if (connection_edge_send_command(conn, circ, RELAY_COMMAND_DATA, payload, length, conn->cpath_layer) < 0) - return 0; /* circuit is closed, don't continue */ + /* circuit got marked for close, don't continue, don't need to mark conn */ + return 0; if (!conn->cpath_layer) { /* non-rendezvous exit */ tor_assert(circ->package_window > 0); @@ -1089,7 +1095,11 @@ circuit_resume_edge_reading_helper(connection_t *conn, (layer_hint && conn->package_window > 0 && conn->cpath_layer == layer_hint)) { connection_start_reading(conn); /* handle whatever might still be on the inbuf */ - connection_edge_package_raw_inbuf(conn, 1); + if (connection_edge_package_raw_inbuf(conn, 1)<0) { + /* (We already sent an end cell if possible) */ + connection_mark_for_close(conn); + continue; + } /* If the circuit won't accept any more data, return without looking * at any more of the streams. Any connections that should be stopped |