[or-cvs] avoid racing the mark-for-close when the client hangs up on...

Roger Dingledine arma at seul.org
Sat Aug 7 02:19:51 UTC 2004


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	connection_edge.c relay.c 
Log Message:
avoid racing the mark-for-close when the client hangs up on us
at the same time we get an end relay cell.
(thanks to wmf for reminding me)


Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.204
retrieving revision 1.205
diff -u -d -r1.204 -r1.205
--- connection_edge.c	7 Aug 2004 00:19:14 -0000	1.204
+++ connection_edge.c	7 Aug 2004 02:19:49 -0000	1.205
@@ -54,7 +54,11 @@
     /* 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: relay.c
===================================================================
RCS file: /home/or/cvsroot/src/or/relay.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- relay.c	5 Aug 2004 00:39:23 -0000	1.8
+++ relay.c	7 Aug 2004 02:19:49 -0000	1.9
@@ -694,7 +694,11 @@
 #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;



More information about the tor-commits mailing list