]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Log meaningful messages before failing on windows with threadlocal.
authorNick Mathewson <nickm@torproject.org>
Tue, 18 Aug 2015 12:37:15 +0000 (08:37 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 18 Aug 2015 12:56:24 +0000 (08:56 -0400)
src/common/compat_winthreads.c

index 3d9e236d8b71c3222a461d572081b94d6f4e5513..381e338877a7e9a395b446f243c41ce21357432e 100644 (file)
@@ -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