]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Merge remote-tracking branch 'tor-github/pr/1303' into maint-0.4.1
authorNick Mathewson <nickm@torproject.org>
Tue, 22 Oct 2019 16:15:06 +0000 (12:15 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 22 Oct 2019 16:15:06 +0000 (12:15 -0400)
1  2 
src/lib/err/backtrace.c
src/lib/err/torerr.h
src/lib/log/log.c
src/lib/log/log.h
src/lib/log/util_bug.c

Simple merge
Simple merge
index 6667c26864c1a40ac08d4256fb4347e4095d5d3e,4adcc5cf57de779ff7430698187fda56f4a8b67d..ec7c2fa24e86d0c0bff9858703ba638ffdafc290
@@@ -806,12 -831,33 +832,36 @@@ logs_free_all(void
    }
  
    /* We _could_ destroy the log mutex here, but that would screw up any logs
 -   * that happened between here and the end of execution. */
 +   * that happened between here and the end of execution.
 +   * If tor is re-initialized, log_mutex_initialized will still be 1. So we
 +   * won't trigger any undefined behaviour by trying to re-initialize the
 +   * log mutex. */
  }
  
+ /** Close signal-safe log files.
+  * Closing the log files makes the process and OS flush log buffers.
+  *
+  * This function is safe to call from a signal handler. It should only be
+  * called when shutting down the log or err modules. It is currenly called
+  * by the err module, when terminating the process on an abnormal condition.
+  */
+ void
+ logs_close_sigsafe(void)
+ {
+   logfile_t *victim, *next;
+   /* We can't LOCK_LOGS() in a signal handler, because it may call
+    * signal-unsafe functions. And we can't deallocate memory, either. */
+   next = logfiles;
+   logfiles = NULL;
+   while (next) {
+     victim = next;
+     next = next->next;
+     if (victim->needs_close) {
+       close_log_sigsafe(victim);
+     }
+   }
+ }
  /** Remove and free the log entry <b>victim</b> from the linked-list
   * logfiles (it is probably present, but it might not be due to thread
   * racing issues). After this function is called, the caller shouldn't
Simple merge
Simple merge