[or-cvs] Now we allow writing to the buffer even when the stream if ...

Roger Dingledine arma at seul.org
Sat Dec 4 07:13:39 UTC 2004


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

Modified Files:
	connection.c connection_edge.c 
Log Message:
Now we allow writing to the buffer even when the stream if marked for
close, if we're planning to wait to flush it.

This is important because we were sending a socks reject back if we're
closing and hadn't already sent one, but it wasn't actually getting
written since the conn was already marked-for-close.


Index: connection.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.307
retrieving revision 1.308
diff -u -d -r1.307 -r1.308
--- connection.c	1 Dec 2004 04:13:15 -0000	1.307
+++ connection.c	4 Dec 2004 07:13:37 -0000	1.308
@@ -235,9 +235,9 @@
     case CONN_TYPE_AP:
       if (conn->socks_request->has_finished == 0) {
         log_fn(LOG_INFO,"Cleaning up AP -- sending socks reject.");
+        conn->hold_open_until_flushed = 1;
         connection_ap_handshake_socks_reply(conn, NULL, 0, -1);
         conn->socks_request->has_finished = 1;
-        conn->hold_open_until_flushed = 1;
       } else {
         control_event_stream_status(conn, STREAM_EVENT_CLOSED);
       }
@@ -1105,7 +1105,10 @@
  */
 void connection_write_to_buf(const char *string, size_t len, connection_t *conn) {
 
-  if (!len || conn->marked_for_close)
+  if (!len)
+    return;
+  /* if it's marked for close, only allow write if we mean to flush it */
+  if (conn->marked_for_close && !conn->hold_open_until_flushed)
     return;
 
   if (write_to_buf(string, len, conn->outbuf) < 0) {

Index: connection_edge.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/connection_edge.c,v
retrieving revision 1.254
retrieving revision 1.255
diff -u -d -r1.254 -r1.255
--- connection_edge.c	4 Dec 2004 03:26:35 -0000	1.254
+++ connection_edge.c	4 Dec 2004 07:13:37 -0000	1.255
@@ -71,7 +71,7 @@
       if (connection_ap_handshake_process_socks(conn) < 0) {
         conn->has_sent_end = 1; /* no circ yet */
         connection_mark_for_close(conn);
-        conn->hold_open_until_flushed = 1;
+        conn->hold_open_until_flushed = 1; /* redundant but shouldn't hurt */
         return -1;
       }
       return 0;



More information about the tor-commits mailing list