aboutsummaryrefslogtreecommitdiff
path: root/src/or/circuit.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-02-27 22:00:26 +0000
committerNick Mathewson <nickm@torproject.org>2004-02-27 22:00:26 +0000
commitc5bbb571d2a27d0b81bfe7a1d374ba965497f267 (patch)
tree81bf23633d8fe4a1da845f097bd52a6ae83340ae /src/or/circuit.c
parent58a7bfab81eeb707b1251df8e525e5b7b7365272 (diff)
downloadtor-c5bbb571d2a27d0b81bfe7a1d374ba965497f267.tar
tor-c5bbb571d2a27d0b81bfe7a1d374ba965497f267.tar.gz
Refactor mark_for_close, connection_edge_end and friends. Now, everybody
who wants to shut down a connection calls connection_mark_for_close instead of setting marked_for_close to 1. This automatically removes the connection from the DNS cache if needed, sends a RELAY END cell if appropriate, and can be changed to do whatever else is needed. Still to do: - The same for circuits, maybe. - Add some kind of hold_connection_open_until_flushed flag, maybe. - Change stuff that closes connections with return -1 to use mark_for_close, maybe. svn:r1145
Diffstat (limited to 'src/or/circuit.c')
-rw-r--r--src/or/circuit.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/or/circuit.c b/src/or/circuit.c
index d16a08d5f..f0729b9f1 100644
--- a/src/or/circuit.c
+++ b/src/or/circuit.c
@@ -64,6 +64,8 @@ circuit_t *circuit_new(uint16_t p_circ_id, connection_t *p_conn) {
circ->timestamp_created = time(NULL);
+ circ->marked_for_close = 0;
+
circ->p_circ_id = p_circ_id;
circ->p_conn = p_conn;
@@ -739,9 +741,8 @@ void circuit_about_to_close_connection(connection_t *conn) {
return;
if(!conn->has_sent_end) {
- log_fn(LOG_INFO,"Edge connection hasn't sent end yet? Bug.");
- if(connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer) < 0)
- log_fn(LOG_WARN,"1: I called connection_edge_end redundantly.");
+ log_fn(LOG_WARN,"Edge connection hasn't sent end yet? Bug.");
+ connection_mark_for_close(conn, END_STREAM_REASON_MISC);
}
circuit_detach_stream(circ, conn);
@@ -1160,8 +1161,8 @@ int circuit_truncated(circuit_t *circ, crypt_path_t *layer) {
/* no need to send 'end' relay cells,
* because the other side's already dead
*/
- stream->marked_for_close = 1;
stream->has_sent_end = 1;
+ connection_mark_for_close(stream,0);
}
}