openssl: Only use CRYPTO_set_id_callback on OpenSSL < 1.0.0

Message ID 1320574383-37973-1-git-send-email-martin@martin.st
State Committed
Commit 246128463020b9831addadc621f61e2551a30a4a
Headers show

Commit Message

Martin Storsjö Nov. 6, 2011, 10:13 a.m.
Since 1.0.0, this function is deprecated. A new function,
CRYPTO_THREADID_set_callback is available, but if not set at all,
it uses the address of errno as thread id, which should be
sufficient for most systems.

On windows, it never was necessary to use this function even
before 1.0.0, it used the right win32 API function for this
by default.
---
 libavformat/network.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Comments

Anton Khirnov Nov. 6, 2011, 12:04 p.m. | #1
On Sun,  6 Nov 2011 12:13:03 +0200, Martin Storsjö <martin@martin.st> wrote:
> Since 1.0.0, this function is deprecated. A new function,
> CRYPTO_THREADID_set_callback is available, but if not set at all,
> it uses the address of errno as thread id, which should be
> sufficient for most systems.
> 
> On windows, it never was necessary to use this function even
> before 1.0.0, it used the right win32 API function for this
> by default.
> ---

LGTM.

Patch

diff --git a/libavformat/network.c b/libavformat/network.c
index d50e1e7..d84dcaf 100644
--- a/libavformat/network.c
+++ b/libavformat/network.c
@@ -45,7 +45,7 @@  static void openssl_lock(int mode, int type, const char *file, int line)
     else
         pthread_mutex_unlock(&openssl_mutexes[type]);
 }
-#ifndef WIN32
+#if !defined(WIN32) && OPENSSL_VERSION_NUMBER < 0x10000000
 static unsigned long openssl_thread_id(void)
 {
     return (intptr_t) pthread_self();
@@ -78,7 +78,7 @@  void ff_tls_init(void)
             for (i = 0; i < CRYPTO_num_locks(); i++)
                 pthread_mutex_init(&openssl_mutexes[i], NULL);
             CRYPTO_set_locking_callback(openssl_lock);
-#ifndef WIN32
+#if !defined(WIN32) && OPENSSL_VERSION_NUMBER < 0x10000000
             CRYPTO_set_id_callback(openssl_thread_id);
 #endif
         }