aboutsummaryrefslogtreecommitdiff
path: root/src/or/control.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-05-29 10:18:50 -0400
committerNick Mathewson <nickm@torproject.org>2009-05-30 18:16:24 -0400
commitfd992deeea769721dc95bacb40ea360ef42f76dd (patch)
tree70e77957df737e808fd295696fb5b7ddce14fd11 /src/or/control.c
parentd66c3797650698778bd098bbaf9d3bbeebfa9fcf (diff)
downloadtor-fd992deeea769721dc95bacb40ea360ef42f76dd.tar
tor-fd992deeea769721dc95bacb40ea360ef42f76dd.tar.gz
Don't attempt to log messages to a controller from a worker thread.
This patch adds a function to determine whether we're in the main thread, and changes control_event_logmsg() to return immediately if we're in a subthread. This is necessary because otherwise we will call connection_write_to_buf, which modifies non-locked data structures. Bugfix on 0.2.0.x; fix for at least one of the things currently called "bug 977".
Diffstat (limited to 'src/or/control.c')
-rw-r--r--src/or/control.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/or/control.c b/src/or/control.c
index 8ded31574..486ccc4c7 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -3367,6 +3367,11 @@ control_event_logmsg(int severity, uint32_t domain, const char *msg)
{
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;