[or-cvs] close immediately when write() fails too, else things will ...

Roger Dingledine arma at seul.org
Wed Mar 3 07:26:36 UTC 2004


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

Modified Files:
	connection.c 
Log Message:
close immediately when write() fails too, else things will turn bad


Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.172
retrieving revision 1.173
diff -u -d -r1.172 -r1.173
--- connection.c	3 Mar 2004 06:26:34 -0000	1.172
+++ connection.c	3 Mar 2004 07:26:34 -0000	1.173
@@ -568,7 +568,12 @@
       conn->state != OR_CONN_STATE_CONNECTING) {
     if (conn->state == OR_CONN_STATE_HANDSHAKING) {
       connection_stop_writing(conn);
-      return connection_tls_continue_handshake(conn);
+      if(connection_tls_continue_handshake(conn) < 0) {
+        connection_close_immediate(conn); /* Don't flush; connection is dead. */
+        connection_mark_for_close(conn, 0);
+        return -1;
+      }
+      return 0;
     }
 
     /* else open, or closing */
@@ -576,6 +581,7 @@
       case TOR_TLS_ERROR:
       case TOR_TLS_CLOSE:
         log_fn(LOG_INFO,"tls error. breaking.");
+        connection_close_immediate(conn); /* Don't flush; connection is dead. */
         connection_mark_for_close(conn, 0);
         return -1; /* XXX deal with close better */
       case TOR_TLS_WANTWRITE:
@@ -601,6 +607,7 @@
     }
   } else {
     if (flush_buf(conn->s, conn->outbuf, &conn->outbuf_flushlen) < 0) {
+      connection_close_immediate(conn); /* Don't flush; connection is dead. */
       connection_mark_for_close(conn, END_STREAM_REASON_MISC);
       return -1;
     }



More information about the tor-commits mailing list