Make sure pthread_once() succeeds.
It can fail on FreeBSD when library is not linked against either threading library and results in init routine not being executed at all, leading to errors in other parts of the code. Change-Id: I1063f6940e381e6470593c063fbfecf3f47991cd Signed-off-by: Piotr Sikora <piotrsikora@google.com> Reviewed-on: https://boringssl-review.googlesource.com/6522 Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
parent
9361243065
commit
c324f1783e
@ -17,6 +17,7 @@
|
|||||||
#if !defined(OPENSSL_WINDOWS) && !defined(OPENSSL_NO_THREADS)
|
#if !defined(OPENSSL_WINDOWS) && !defined(OPENSSL_NO_THREADS)
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -74,7 +75,11 @@ void CRYPTO_STATIC_MUTEX_unlock(struct CRYPTO_STATIC_MUTEX *lock) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CRYPTO_once(CRYPTO_once_t *once, void (*init)(void)) {
|
void CRYPTO_once(CRYPTO_once_t *once, void (*init)(void)) {
|
||||||
pthread_once(once, init);
|
if (pthread_once(once, init) != 0) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"pthread_once failed. Did you link against a threading library?\n");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static pthread_mutex_t g_destructors_lock = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t g_destructors_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
Loading…
Reference in New Issue
Block a user