crypto: use CRYPTO_THREADID_set_callback()
authorBen Noordhuis <info@bnoordhuis.nl>
Thu, 30 Aug 2012 22:37:45 +0000 (00:37 +0200)
committerBen Noordhuis <info@bnoordhuis.nl>
Thu, 30 Aug 2012 22:40:18 +0000 (00:40 +0200)
Don't use CRYPTO_set_id_callback(), it's deprecated.

src/node_crypto.cc

index d1dd84d..7a06fae 100644 (file)
@@ -90,12 +90,16 @@ static Persistent<FunctionTemplate> secure_context_constructor;
 static uv_rwlock_t* locks;
 
 
-static unsigned long crypto_id_cb(void) {
+static void crypto_threadid_cb(CRYPTO_THREADID* tid) {
+  unsigned long val;
+
 #ifdef _WIN32
-  return (unsigned long) GetCurrentThreadId();
-#else /* !_WIN32 */
-  return (unsigned long) pthread_self();
-#endif /* !_WIN32 */
+  val = static_cast<unsigned long>(GetCurrentThreadId());
+#else
+  val = static_cast<unsigned long>(pthread_self());
+#endif
+
+  CRYPTO_THREADID_set_numeric(tid, val);
 }
 
 
@@ -4498,7 +4502,7 @@ void InitCrypto(Handle<Object> target) {
 
   crypto_lock_init();
   CRYPTO_set_locking_callback(crypto_lock_cb);
-  CRYPTO_set_id_callback(crypto_id_cb);
+  CRYPTO_THREADID_set_callback(crypto_threadid_cb);
 
   // Turn off compression. Saves memory - do it in userland.
 #if !defined(OPENSSL_NO_COMP)