diff options
author | Roger Dingledine <arma@torproject.org> | 2004-02-28 23:56:50 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2004-02-28 23:56:50 +0000 |
commit | 62d3df8633ff5e00eddc76dc690fe6696f1c583b (patch) | |
tree | b74bdf707e6fbb3c159f1fe8bc8fbd6f01cd6528 | |
parent | ae67c488054affc618cd4dadbda51000cdbd866a (diff) | |
download | tor-62d3df8633ff5e00eddc76dc690fe6696f1c583b.tar tor-62d3df8633ff5e00eddc76dc690fe6696f1c583b.tar.gz |
bugfix: when we time out on a stream and detach, send an end first
svn:r1175
-rw-r--r-- | src/or/connection_edge.c | 13 | ||||
-rw-r--r-- | src/or/or.h | 3 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index 2bba8f6ad..b159c194b 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -104,6 +104,7 @@ static char *connection_edge_end_reason(char *payload, uint16_t length) { case END_STREAM_REASON_EXITPOLICY: return "exit policy failed"; case END_STREAM_REASON_DESTROY: return "destroyed"; case END_STREAM_REASON_DONE: return "closed normally"; + case END_STREAM_REASON_TIMEOUT: return "gave up (timeout)"; } assert(0); return ""; @@ -531,6 +532,10 @@ void connection_ap_expire_beginning(void) { if (now - conn->timestamp_lastread >= 15) { log_fn(LOG_WARN,"Stream is %d seconds late. Retrying.", (int)(now - conn->timestamp_lastread)); + /* send an end down the circuit */ + connection_edge_end(conn, END_STREAM_REASON_TIMEOUT, conn->cpath_layer); + /* un-mark it as ending, since we're going to reuse it */ + conn->has_sent_end = 0; /* move it back into 'pending' state. It's possible it will * reattach to this same circuit, but that's good enough for now. */ @@ -540,11 +545,7 @@ void connection_ap_expire_beginning(void) { conn->timestamp_lastread += 15; if(connection_ap_handshake_attach_circuit(conn)<0) { /* it will never work */ - /* Don't need to send end -- why? */ -/* XXX you're right, there's a bug. we should send an end cell - * above, right before circuit_detach_stream. But if attach_circuit() - * fails, then in fact we should mark without sending an end, because - * we're not connected to anything. -RD */ + /* Don't need to send end -- we're not connected */ connection_mark_for_close(conn, 0); } } @@ -567,7 +568,7 @@ void connection_ap_attach_pending(void) continue; if(connection_ap_handshake_attach_circuit(conn) < 0) { /* -1 means it will never work */ - /* Don't send end; there is no 'other end' of the stream */ + /* Don't send end; there is no 'other side' yet */ connection_mark_for_close(conn,0); } } diff --git a/src/or/or.h b/src/or/or.h index 411dfadfc..c8433bdf4 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -196,7 +196,8 @@ #define END_STREAM_REASON_EXITPOLICY 4 #define END_STREAM_REASON_DESTROY 5 #define END_STREAM_REASON_DONE 6 -#define _MAX_END_STREAM_REASON 6 +#define END_STREAM_REASON_TIMEOUT 7 +#define _MAX_END_STREAM_REASON 7 /* default cipher function */ #define DEFAULT_CIPHER CRYPTO_CIPHER_AES_CTR |