]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
avoid racing the mark-for-close when the client hangs up on us
authorRoger Dingledine <arma@torproject.org>
Sat, 7 Aug 2004 02:19:49 +0000 (02:19 +0000)
committerRoger Dingledine <arma@torproject.org>
Sat, 7 Aug 2004 02:19:49 +0000 (02:19 +0000)
at the same time we get an end relay cell.
(thanks to wmf for reminding me)

svn:r2181

src/or/connection_edge.c
src/or/relay.c

index f8cdbe139b052f3b08cbba55a3b2fa396352244a..6dec49e9fe86ada78cd230b0acf8e516c1f04b1e 100644 (file)
@@ -54,7 +54,11 @@ int connection_edge_process_inbuf(connection_t *conn) {
     /* eof reached, kill it. */
     log_fn(LOG_INFO,"conn (fd %d) reached eof. Closing.", conn->s);
     connection_edge_end(conn, END_STREAM_REASON_DONE, conn->cpath_layer);
-    connection_mark_for_close(conn);
+    if(!conn->marked_for_close) {
+      /* only mark it if not already marked. it's possible to
+       * get the 'end' right around when the client hangs up on us. */
+      connection_mark_for_close(conn);
+    }
     conn->hold_open_until_flushed = 1; /* just because we shouldn't read
                                           doesn't mean we shouldn't write */
     return 0;
index e95235f89b65237b3e071e83dc613f49625e9318..b74a3401b644c2a68d6a67862e368428734cdab9 100644 (file)
@@ -694,7 +694,11 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
 #else
       /* We just *got* an end; no reason to send one. */
       conn->has_sent_end = 1;
-      connection_mark_for_close(conn);
+      if(!conn->marked_for_close) {
+        /* only mark it if not already marked. it's possible to
+         * get the 'end' right around when the client hangs up on us. */
+        connection_mark_for_close(conn);
+      }
       conn->hold_open_until_flushed = 1;
 #endif
       return 0;