From 88ba670ce9c90091f58cf9ef5bff2d86c9a0499e Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Sun, 5 Jan 2020 15:31:37 +0900 Subject: [PATCH] Fix usage of atomic_bool "keysSet" --- src/UDPConnection.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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);