diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2017-12-01 11:27:15 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-01 11:27:15 +0000 |
commit | 344b4ead60da5fc3514f602a8e1a6af15173cc31 (patch) | |
tree | d8b2b71fa5685f6d70bfa0f67801aa2249bb00ad | |
parent | 494a2f235fd13de5f927ad64db0b3597569f02b9 (diff) | |
parent | 2d2e70f8ca7ceb12481f4a10c5c81829ea31b11a (diff) | |
download | libgit2-344b4ead60da5fc3514f602a8e1a6af15173cc31.tar.gz |
Merge pull request #4427 from pks-t/pks/openssl-threadid
openssl: fix thread-safety on non-glibc POSIX systems
-rw-r--r-- | src/streams/openssl.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/streams/openssl.c b/src/streams/openssl.c index 56164bf25..2b246002f 100644 --- a/src/streams/openssl.c +++ b/src/streams/openssl.c @@ -150,11 +150,20 @@ int git_openssl_stream_global_init(void) return 0; } +#if defined(GIT_THREADS) +static void threadid_cb(CRYPTO_THREADID *threadid) +{ + CRYPTO_THREADID_set_numeric(threadid, git_thread_currentid()); +} +#endif + int git_openssl_set_locking(void) { #if defined(GIT_THREADS) && OPENSSL_VERSION_NUMBER < 0x10100000L int num_locks, i; + CRYPTO_THREADID_set_callback(threadid_cb); + num_locks = CRYPTO_num_locks(); openssl_locks = git__calloc(num_locks, sizeof(git_mutex)); GITERR_CHECK_ALLOC(openssl_locks); |