[tor-commits] [tor/maint-0.4.2] When initializing pthreads, always set the main thread.

ahf at torproject.org ahf at torproject.org
Tue Jun 30 13:39:11 UTC 2020


commit 4f6901d7cc827e5bfa98467b7a568f725ce7fa9f
Author: Nick Mathewson <nickm at torproject.org>
Date:   Mon Jan 6 09:37:12 2020 -0500

    When initializing pthreads, always set the main thread.
    
    Fixes bug 32884.  This is a bugfix on 0.3.3.1-alpha, when we started
    allowing restart-in-process with tor_api.h.
---
 changes/bug32884                 | 5 +++++
 src/lib/thread/compat_pthreads.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/changes/bug32884 b/changes/bug32884
new file mode 100644
index 000000000..9ab1d2446
--- /dev/null
+++ b/changes/bug32884
@@ -0,0 +1,5 @@
+  o Minor bugfixes (embedded Tor):
+    - When starting Tor any time after the first time in a process, register
+      the thread in which it is running as the main thread.  Previously, we
+      only did this on Windows, which could lead to bugs like 23081 on
+      non-Windows platforms.  Fixes bug 32884; bugfix on 0.3.3.1-alpha.
diff --git a/src/lib/thread/compat_pthreads.c b/src/lib/thread/compat_pthreads.c
index 05efe9cfd..6f7ecd17d 100644
--- a/src/lib/thread/compat_pthreads.c
+++ b/src/lib/thread/compat_pthreads.c
@@ -265,6 +265,6 @@ tor_threads_init(void)
       pthread_attr_setdetachstate(&attr_detached, PTHREAD_CREATE_DETACHED);
     tor_assert(ret2 == 0);
     threads_initialized = 1;
-    set_main_thread();
   }
+  set_main_thread();
 }





More information about the tor-commits mailing list