Use pthread_once(3) to initialize openssl/libressl just once.
Fixes openssl initialization concurrently by multiple threads. Close #167
This commit is contained in:
parent
2434b90d6e
commit
228a89d51e
3
NEWS
3
NEWS
@ -1,5 +1,8 @@
|
|||||||
xbps-0.52 (???):
|
xbps-0.52 (???):
|
||||||
|
|
||||||
|
* xbps-query(1): fix segfault in -Ro with HTTPS repositories.
|
||||||
|
Fixes #167. See https://github.com/voidlinux/xbps/issues/167
|
||||||
|
|
||||||
* xbps-uhelper: the 'arch' target now supports the XBPS_ARCH
|
* xbps-uhelper: the 'arch' target now supports the XBPS_ARCH
|
||||||
and XBPS_TARGET_ARCH environmental variables to override the
|
and XBPS_TARGET_ARCH environmental variables to override the
|
||||||
resulting architecture.
|
resulting architecture.
|
||||||
|
@ -934,8 +934,22 @@ fetch_ssl_cb_verify_crt(int verified, X509_STORE_CTX *ctx)
|
|||||||
return (verified);
|
return (verified);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
static pthread_once_t ssl_init_once = PTHREAD_ONCE_INIT;
|
||||||
|
|
||||||
|
static void
|
||||||
|
ssl_init(void)
|
||||||
|
{
|
||||||
|
/* Init the SSL library and context */
|
||||||
|
if (!SSL_library_init()){
|
||||||
|
fprintf(stderr, "SSL library init failed\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Enable SSL on a connection.
|
* Enable SSL on a connection.
|
||||||
*/
|
*/
|
||||||
@ -948,11 +962,7 @@ fetch_ssl(conn_t *conn, const struct url *URL, int verbose)
|
|||||||
X509_NAME *name;
|
X509_NAME *name;
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
/* Init the SSL library and context */
|
(void)pthread_once(&ssl_init_once, ssl_init);
|
||||||
if (!SSL_library_init()){
|
|
||||||
fprintf(stderr, "SSL library init failed\n");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
SSL_load_error_strings();
|
SSL_load_error_strings();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user