]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
log: explain why it is safe to leave the log mutex initialized
authorteor <teor@torproject.org>
Thu, 26 Sep 2019 02:18:23 +0000 (12:18 +1000)
committerteor <teor@torproject.org>
Thu, 26 Sep 2019 02:22:34 +0000 (12:22 +1000)
The log mutex is dynamically initialized, guarded by log_mutex_initialized.
We don't want to destroy it, because after it is destroyed, we won't see
any more logs.

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.

Part of 31736, but committed in this branch to avoid merge conflicts.

src/lib/log/log.c

index a9ad38fb25faf089f0dda711b627e2e68c50e0ea..eacd413a534eedb9f07a95267fd6a4b44f120434 100644 (file)
@@ -804,7 +804,10 @@ 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. */
 }
 
 /** Remove and free the log entry <b>victim</b> from the linked-list