From 48b4bace5d49953b0e2049468f42408e4b441b51 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Fri, 5 Jul 2019 23:28:24 +0200 Subject: [PATCH 1/2] Fixed spinlock for windows --- src/misc/spin_lock.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/misc/spin_lock.h b/src/misc/spin_lock.h index b223abf..c2b390f 100644 --- a/src/misc/spin_lock.h +++ b/src/misc/spin_lock.h @@ -9,7 +9,12 @@ class spin_lock { inline void lock() { uint8_t round = 0; while (locked.test_and_set(std::memory_order_acquire)) { - while(locked._M_i) { /* waiting 'till its zero so we can try an exchanged again; Atomic exchanges have a huge bug overhead to deal with! */ + /* waiting 'till its zero so we can try an exchanged again; Atomic exchanges have a huge bug overhead to deal with! */ +#ifdef WIN32 + while(locked._My_flag > 0) { +#else + while(locked._M_i) { +#endif //Yield when we're using this lock for a longer time, which we usually not doing if(round++ % 8 == 0) std::this_thread::yield(); From 6b02d4a9d86fcd4d1a54ab87e30922cfa7374283 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sat, 6 Jul 2019 15:02:09 +0200 Subject: [PATCH 2/2] Fixed static access --- src/protocol/CryptionHandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/protocol/CryptionHandler.cpp b/src/protocol/CryptionHandler.cpp index d04d913..815faba 100644 --- a/src/protocol/CryptionHandler.cpp +++ b/src/protocol/CryptionHandler.cpp @@ -174,8 +174,8 @@ bool CryptionHandler::generate_key_nonce( uint8_t (& nonce)[16] ) { if (this->useDefaultChipherKeyNonce || use_default) { - memcpy(key, this->default_key, 16); - memcpy(nonce, this->default_nonce, 16); + memcpy(key, CryptionHandler::default_key, 16); + memcpy(nonce, CryptionHandler::default_nonce, 16); return true; }