- Don't warn users about low port and hibernation mix when they
provide a *ListenAddress directive to fix that. Bugfix on
0.2.1.15-rc.
+ - Fix a race condition that could cause crashes or memory
+ corruption when running as a server with a controller listening
+ for log messages.
o Minor bugfixes (on 0.2.1.x):
- When switching back and forth between bridge mode, do not start
pthread_mutexattr_init(&attr_reentrant);
pthread_mutexattr_settype(&attr_reentrant, PTHREAD_MUTEX_RECURSIVE);
threads_initialized = 1;
+ set_main_thread();
}
}
#elif defined(USE_WIN32_THREADS)
#if 0
cond_event_tls_index = TlsAlloc();
#endif
+ set_main_thread();
}
#endif
+/** Identity of the "main" thread */
+static unsigned long main_thread_id = -1;
+
+/** Start considering the current thread to be the 'main thread'. This has
+ * no effect on anything besides in_main_thread(). */
+void
+set_main_thread(void)
+{
+ main_thread_id = tor_get_thread_id();
+}
+/** Return true iff called from the main thread. */
+int
+in_main_thread(void)
+{
+ return main_thread_id == tor_get_thread_id();
+}
+
/**
* On Windows, WSAEWOULDBLOCK is not always correct: when you see it,
* you need to ask the socket for its actual errno. Also, you need to
#define tor_threads_init() STMT_NIL
#endif
+void set_main_thread(void);
+int in_main_thread(void);
+
#ifdef TOR_IS_MULTITHREADED
#if 0
typedef struct tor_cond_t tor_cond_t;
{
int event;
+ /* Don't even think of trying to add stuff to a buffer from a cpuworker
+ * thread. */
+ if (! in_main_thread())
+ return;
+
if (disable_log_messages)
return;