From: Stephen Seo Date: Sun, 5 Jan 2020 06:31:37 +0000 (+0900) Subject: Fix usage of atomic_bool "keysSet" X-Git-Tag: 1.0~90 X-Git-Url: https://git.seodisparate.com/stephenseo/img/favicon.ico?a=commitdiff_plain;h=88ba670ce9c90091f58cf9ef5bff2d86c9a0499e;p=UDPConnection Fix usage of atomic_bool "keysSet" --- diff --git a/src/UDPConnection.cpp b/src/UDPConnection.cpp index cf0731a..4f39d6d 100644 --- a/src/UDPConnection.cpp +++ b/src/UDPConnection.cpp @@ -288,7 +288,7 @@ void UDPC::Context::update_impl() { { unsigned char *sk = nullptr; unsigned char *pk = nullptr; - if(keysSet.load(std::memory_order_relaxed)) { + if(keysSet.load()) { sk = this->sk; pk = this->pk; } @@ -1206,7 +1206,7 @@ void UDPC::Context::update_impl() { } unsigned char *sk = nullptr; unsigned char *pk = nullptr; - if(keysSet.load(std::memory_order_relaxed)) { + if(keysSet.load()) { sk = this->sk; pk = this->pk; } @@ -2303,7 +2303,6 @@ int UDPC_set_libsodium_keys(UDPC_HContext ctx, unsigned char *sk, unsigned char return 0; } - std::lock_guard lock(c->conMapMutex); std::memcpy(c->sk, sk, crypto_sign_SECRETKEYBYTES); std::memcpy(c->pk, pk, crypto_sign_PUBLICKEYBYTES); c->keysSet.store(true); @@ -2324,7 +2323,6 @@ int UDPC_unset_libsodium_keys(UDPC_HContext ctx) { return 0; } - std::lock_guard lock(c->conMapMutex); c->keysSet.store(false); std::memset(c->pk, 0, crypto_sign_PUBLICKEYBYTES); std::memset(c->sk, 0, crypto_sign_SECRETKEYBYTES);