diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-02-13 22:32:25 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-02-13 22:32:25 +0000 |
commit | aac97a3c6a6971bebabbfe8f2779cda99438194c (patch) | |
tree | e72aa5777fd6b8725aeb374b0e2edd44b3e30ac1 /src/common/compat.c | |
parent | 427e246a10a6dbfa153adb6f5edf284e09f05c82 (diff) | |
download | tor-aac97a3c6a6971bebabbfe8f2779cda99438194c.tar tor-aac97a3c6a6971bebabbfe8f2779cda99438194c.tar.gz |
Tell openssl how to use locks and how to find thread ids -- this may prevent race conditions surrounding the error queue.
svn:r3622
Diffstat (limited to 'src/common/compat.c')
-rw-r--r-- | src/common/compat.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/common/compat.c b/src/common/compat.c index c4e949a6e..6f9e68803 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -72,6 +72,10 @@ const char compat_c_id[] = "$Id$"; #include "log.h" #include "util.h" +#ifdef TOR_IS_MULTITHREADED +#include <openssl/crypto.h> +#endif + /* Inline the strl functions if the platform doesn't have them. */ #ifndef HAVE_STRLCPY #include "strlcpy.c" @@ -774,6 +778,11 @@ void tor_mutex_release(tor_mutex_t *m) log_fn(LOG_WARN, "Failed to release mutex: %d", GetLastError()); } } +unsigned long +tor_get_thread_id(void) +{ + return (unsigned long)GetCurrentThreadId(); +} #elif defined(USE_PTHREADS) struct tor_mutex_t { pthread_mutex_t mutex; @@ -800,6 +809,11 @@ void tor_mutex_free(tor_mutex_t *m) pthread_mutex_destroy(&m->mutex); tor_free(m); } +unsigned long +tor_get_thread_id(void) +{ + return (unsigned long)pthread_self(); +} #else struct tor_mutex_t { int _unused; @@ -808,6 +822,7 @@ tor_mutex_t *tor_mutex_new(void) { return NULL; } void tor_mutex_acquire(tor_mutex_t *m) { } void tor_mutex_release(tor_mutex_t *m) { } void tor_mutex_free(tor_mutex_t *m) { } +unsigned long tor_get_thread_id(void) { return 1; } #endif /** |