mirror of
https://github.com/jedisct1/libsodium.git
synced 2024-12-23 20:15:19 -07:00
sodium_init() is not thread-safe. Roll your own locks if you need that.
This commit is contained in:
parent
48d4b5ab1e
commit
05f45575bb
@ -77,6 +77,9 @@ Before doing anything else with the library, call:
|
||||
|
||||
sodium_init();
|
||||
|
||||
This function is not thread-safe. No other Sodium functions should be
|
||||
called until it successfully returns.
|
||||
|
||||
And if you need to release memory and other resources possibly
|
||||
allocated by the library, call:
|
||||
|
||||
|
@ -2,14 +2,15 @@
|
||||
#include "core.h"
|
||||
#include "crypto_onetimeauth.h"
|
||||
|
||||
static char initialized;
|
||||
static _Bool initialized;
|
||||
|
||||
int
|
||||
sodium_init(void)
|
||||
{
|
||||
if (__sync_lock_test_and_set(&initialized, 1) != 0) {
|
||||
if (initialized != 0) {
|
||||
return 1;
|
||||
}
|
||||
initialized = 1;
|
||||
if (crypto_onetimeauth_pick_best_implementation() == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user