From aa29530d920f1f00632a97ee9bb10d4b5bff031d Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Fri, 13 Nov 2020 00:17:27 +0100 Subject: [PATCH] fix identification & check thread issue with atomic bool --- src/Network/Auth.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Network/Auth.cpp b/src/Network/Auth.cpp index 19f11e4..4357b87 100644 --- a/src/Network/Auth.cpp +++ b/src/Network/Auth.cpp @@ -78,10 +78,10 @@ std::string GetRole(const std::string& DID) { } return ""; } -void Check(SOCKET TCPSock, std::reference_wrapper ok) { +void Check(SOCKET TCPSock, std::shared_ptr ok) { DebugPrintTID(); size_t accum = 0; - while (!ok.get()) { + while (!*ok) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); accum += 100; if (accum >= 5000) { @@ -136,8 +136,8 @@ std::string GenerateM(RSA* key) { void Identification(SOCKET TCPSock, RSA* Skey) { DebugPrintTID(); Assert(Skey); - std::atomic_bool ok { false }; - std::thread Timeout(Check, TCPSock, std::ref(ok)); + std::shared_ptr ok = std::make_shared(false); + std::thread Timeout(Check, TCPSock, ok); Timeout.detach(); std::string Name, DID, Role; if (!Send(TCPSock, GenerateM(Skey))) { @@ -155,7 +155,7 @@ void Identification(SOCKET TCPSock, RSA* Skey) { std::string Res = Rcv(TCPSock); std::string Ver = Rcv(TCPSock); - ok = true; + *ok = true; Ver = RSA_D(Ver, Skey); if (Ver.size() > 3 && Ver.substr(0, 2) == Sec("VC")) { Ver = Ver.substr(2);