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

[or-cvs] r10395: An even better workaround for the probably-already-fixed bug (in tor/trunk: . src/common)



Author: nickm
Date: 2007-05-29 14:21:00 -0400 (Tue, 29 May 2007)
New Revision: 10395

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/common/log.c
Log:
 r13054@catbus:  nickm | 2007-05-29 14:20:50 -0400
 An even better workaround for the probably-already-fixed bug 222.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r13054] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-05-29 18:20:56 UTC (rev 10394)
+++ tor/trunk/ChangeLog	2007-05-29 18:21:00 UTC (rev 10395)
@@ -135,6 +135,11 @@
     - When we are reporting the DirServer line we just parsed, we were
       logging the second stanza of the key fingerprint, not the first.
 
+  o Minor bugfixes (logging):
+    - When we hit an EOF on a log (probably because we're shutting down),
+      don't try to remove the log from the list: just mark it as
+      unusable.  (Bulletproofs against bug 222.)
+
   o Minor bugfixes (other):
     - Stop allowing hibernating servers to be "stable" or "fast".
     - Check return values from pthread_mutex functions.

Modified: tor/trunk/src/common/log.c
===================================================================
--- tor/trunk/src/common/log.c	2007-05-29 18:20:56 UTC (rev 10394)
+++ tor/trunk/src/common/log.c	2007-05-29 18:21:00 UTC (rev 10395)
@@ -35,6 +35,7 @@
   struct logfile_t *next; /**< Next logfile_t in the linked list. */
   char *filename; /**< Filename to open. */
   FILE *file; /**< Stream to receive log messages. */
+  int seems_dead; /**< Boolean: true if the stream seems to be kaput. */
   int needs_close; /**< Boolean: true if the stream gets closed on shutdown. */
   int min_loglevel; /**< Lowest severity level to send to this stream. */
   int max_loglevel; /**< Highest severity level to send to this stream. */
@@ -247,6 +248,10 @@
       lf = lf->next;
       continue;
     }
+    if (lf->seems_dead) {
+      lf = lf->next;
+      continue;
+    }
 
     if (!formatted) {
       end_of_prefix =
@@ -268,13 +273,11 @@
     }
     if (fputs(buf, lf->file) == EOF ||
         fflush(lf->file) == EOF) { /* error */
-      /* don't log the error! Blow away this log entry and continue. */
-      logfile_t *victim = lf;
-      lf = victim->next;
-      delete_log(victim);
-    } else {
-      lf = lf->next;
+      /* don't log the error! mark this log entry to be blown away, and
+       * continue. */
+      lf->seems_dead = 1;
     }
+    lf = lf->next;
   }
 }