crypto: store thread id as pointer-sized value
authorBert Belder <bertbelder@gmail.com>
Tue, 9 Dec 2014 16:44:37 +0000 (17:44 +0100)
committerBert Belder <bertbelder@gmail.com>
Tue, 9 Dec 2014 16:57:06 +0000 (17:57 +0100)
uv_thread_t is a HANDLE (void pointer) on Windows, which means that
on 64-bit windows it cannot be stored with CRYPTO_THREADID_set_numeric
without potential data loss.

PR-URL: https://github.com/iojs/io.js/pull/124
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
src/node_crypto.cc

index 0665128..eec8b56 100644 (file)
@@ -150,7 +150,9 @@ template int SSLWrap<TLSCallbacks>::TLSExtStatusCallback(SSL* s, void* arg);
 
 
 static void crypto_threadid_cb(CRYPTO_THREADID* tid) {
-  CRYPTO_THREADID_set_numeric(tid, uv_thread_self());
+  static_assert(sizeof(uv_thread_t) <= sizeof(void*),
+                "uv_thread_t does not fit in a pointer");
+  CRYPTO_THREADID_set_pointer(tid, reinterpret_cast<void*>(uv_thread_self()));
 }