aboutsummaryrefslogtreecommitdiff
path: root/src/common/compat_winthreads.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2015-08-18 08:37:15 -0400
committerNick Mathewson <nickm@torproject.org>2015-08-18 08:56:24 -0400
commit087cf882c6a9ef6b9617d21ef26c19c47a4fc660 (patch)
treef2652152a3a4e9421c17502cb3c8e82506f4bb3b /src/common/compat_winthreads.c
parent3d9952a3b14e83d265a09de9071dc3609e3a4cc9 (diff)
downloadtor-087cf882c6a9ef6b9617d21ef26c19c47a4fc660.tar.gz
tor-087cf882c6a9ef6b9617d21ef26c19c47a4fc660.zip
Log meaningful messages before failing on windows with threadlocal.
Diffstat (limited to 'src/common/compat_winthreads.c')
-rw-r--r--src/common/compat_winthreads.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/common/compat_winthreads.c b/src/common/compat_winthreads.c
index 3d9e236d8b..381e338877 100644
--- a/src/common/compat_winthreads.c
+++ b/src/common/compat_winthreads.c
@@ -139,14 +139,30 @@ tor_threadlocal_destroy(tor_threadlocal_t *threadlocal)
void *
tor_threadlocal_get(tor_threadlocal_t *threadlocal)
{
- return TlsGetValue(threadlocal->index);
+ void *value = TlsGetValue(threadlocal->index);
+ if (value == NULL) {
+ DWORD err = GetLastError();
+ if (err != ERROR_SUCCESS) {
+ char *msg = format_win32_error(err);
+ log_err(LD_GENERAL, "Error retrieving thread-local value: %s", msg);
+ tor_free(msg);
+ tor_assert(err == ERROR_SUCCESS);
+ }
+ }
+ return value;
}
void
tor_threadlocal_set(tor_threadlocal_t *threadlocal, void *value)
{
BOOL ok = TlsSetValue(threadlocal->index, value);
- tor_assert(ok);
+ if (!ok) {
+ DWORD err = GetLastError();
+ char *msg = format_win32_error(err);
+ log_err(LD_GENERAL, "Error adjusting thread-local value: %s", msg);
+ tor_free(msg);
+ tor_assert(ok);
+ }
}
int