Commit 349d1cfd authored by DK's avatar DK Committed by Rich Salz
Browse files

Fixed deadlock in CRYPTO_THREAD_run_once for Windows



Fixed deadlock in CRYPTO_THREAD_run_once() if call to init() is causing
a recursive call to CRYPTO_THREAD_run_once() again that is causing a hot
deadloop inside do { } while (result == ONCE_ININIT); section.

CLA: trivial
Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1913)
parent af5883fe
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -78,8 +78,8 @@ int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
    do {
        result = InterlockedCompareExchange(lock, ONCE_ININIT, ONCE_UNINITED);
        if (result == ONCE_UNINITED) {
            init();
            *lock = ONCE_DONE;
            init();
            return 1;
        }
    } while (result == ONCE_ININIT);