[tor-commits] [tor/maint-0.4.2] Merge remote-tracking branch 'tor-github/pr/1303' into maint-0.4.1

nickm at torproject.org nickm at torproject.org
Tue Oct 22 16:15:43 UTC 2019


commit 9769df89fe5bd8ccd802064273cca09efddc2b02
Merge: c1bf4260b ebce7059f
Author: Nick Mathewson <nickm at torproject.org>
Date:   Tue Oct 22 12:15:06 2019 -0400

    Merge remote-tracking branch 'tor-github/pr/1303' into maint-0.4.1

 changes/bug31594            |  5 +++
 src/lib/err/backtrace.c     |  2 +-
 src/lib/err/torerr.c        | 64 +++++++++++++++++++++++++++++++---
 src/lib/err/torerr.h        |  7 ++--
 src/lib/err/torerr_sys.c    |  5 ++-
 src/lib/log/log.c           | 85 +++++++++++++++++++++++++++++++++++++++------
 src/lib/log/log.h           |  1 +
 src/lib/log/util_bug.c      | 11 +++---
 src/trunnel/trunnel-local.h |  1 +
 9 files changed, 158 insertions(+), 23 deletions(-)

diff --cc src/lib/log/log.c
index 6667c2686,4adcc5cf5..ec7c2fa24
--- a/src/lib/log/log.c
+++ b/src/lib/log/log.c
@@@ -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





More information about the tor-commits mailing list