[or-cvs] bugfix on the bugfix
Roger Dingledine
arma at seul.org
Thu Sep 23 04:59:04 UTC 2004
Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/common
Modified Files:
log.c
Log Message:
bugfix on the bugfix
actually unlink the log entry.
ok, that wasn't cleverly hidden enough. let's try again.
Index: log.c
===================================================================
RCS file: /home/or/cvsroot/src/common/log.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- log.c 23 Sep 2004 03:51:45 -0000 1.51
+++ log.c 23 Sep 2004 04:59:02 -0000 1.52
@@ -51,7 +51,10 @@
/** Linked list of logfile_t. */
static logfile_t *logfiles = NULL;
-static INLINE size_t _log_prefix(char *buf, size_t buf_len, int severity)
+static void delete_log(logfile_t *victim);
+
+static INLINE size_t
+_log_prefix(char *buf, size_t buf_len, int severity)
{
time_t t;
struct timeval now;
@@ -159,10 +162,7 @@
/* don't log the error! Blow away this log entry and continue. */
logfile_t *victim = lf;
lf = victim->next;
- if(victim == logfiles)
- logfiles = lf;
- tor_free(victim->filename);
- tor_free(victim);
+ delete_log(victim);
} else {
lf = lf->next;
}
@@ -212,10 +212,7 @@
/* error. don't log it. delete the log entry and continue. */
logfile_t *victim = lf;
lf = victim->next;
- if(victim == logfiles)
- logfiles = lf;
- tor_free(victim->filename);
- tor_free(victim);
+ delete_log(victim);
continue;
} else {
log_tor_version(lf, 1);
@@ -225,6 +222,24 @@
}
}
+/** Remove and free the log entry <b>victim</b> from the linked-list
+ * logfiles (it must be present in the list when this function is
+ * called). After this function is called, the caller shouldn't refer
+ * to <b>victim</b> anymore.
+ */
+static void delete_log(logfile_t *victim) {
+ logfile_t *tmpl;
+ if(victim == logfiles)
+ logfiles = victim->next;
+ else {
+ for(tmpl = logfiles; tmpl && tmpl->next != victim; tmpl=tmpl->next) ;
+ tor_assert(tmpl->next == victim);
+ tmpl->next = victim->next;
+ }
+ tor_free(victim->filename);
+ tor_free(victim);
+}
+
/** Add a log handler to send all messages of severity <b>loglevel</b>
* or higher to <b>stream</b>. */
void add_stream_log(int loglevelMin, int loglevelMax, const char *name, FILE *stream)
More information about the tor-commits
mailing list