[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] calling flush_buf and not checking for return value is bad



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

Modified Files:
	main.c 
Log Message:
calling flush_buf and not checking for return value is bad


Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.263
retrieving revision 1.264
diff -u -d -r1.263 -r1.264
--- main.c	11 May 2004 01:55:32 -0000	1.263
+++ main.c	12 May 2004 18:41:32 -0000	1.264
@@ -351,15 +351,21 @@
   if(conn->type == CONN_TYPE_DIR &&
      !conn->marked_for_close &&
      conn->timestamp_lastwritten + 5*60 < now) {
-    log_fn(LOG_WARN,"Expiring wedged directory conn (purpose %d)", conn->purpose);
+    log_fn(LOG_WARN,"Expiring wedged directory conn (fd %d, purpose %d)", conn->s, conn->purpose);
     /* XXXX This next check may help isolate where the pesky EPIPE bug
      * really occurs. */
     if (connection_wants_to_flush(conn)) {
-      flush_buf(conn->s, conn->outbuf, &conn->outbuf_flushlen);
+      if(flush_buf(conn->s, conn->outbuf, &conn->outbuf_flushlen) < 0) {
+        log_fn(LOG_WARN,"flushing expired directory conn failed.");
+        connection_close_immediate(conn);
+        connection_mark_for_close(conn,0);
+        /*  */
+      } else {
+        /* XXXX Does this next part make sense, really? */
+        connection_mark_for_close(conn,0);
+        conn->hold_open_until_flushed = 1; /* give it a last chance */
+      }
     }
-    connection_mark_for_close(conn,0);
-    /* XXXX Does this next part make sense, really? */
-    conn->hold_open_until_flushed = 1; /* give it a last chance */
     return;
   }