Skip to content

Commit 8b5af3d

Browse files
committed
net: fMsgProcWake use LOCK instead of lock_guard
1 parent de7c5f4 commit 8b5af3d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/net.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,7 @@ void CConnman::ThreadSocketHandler()
14541454
void CConnman::WakeMessageHandler()
14551455
{
14561456
{
1457-
std::lock_guard<std::mutex> lock(mutexMsgProc);
1457+
LOCK(mutexMsgProc);
14581458
fMsgProcWake = true;
14591459
}
14601460
condMsgProc.notify_one();
@@ -2057,7 +2057,7 @@ void CConnman::ThreadMessageHandler()
20572057

20582058
WAIT_LOCK(mutexMsgProc, lock);
20592059
if (!fMoreWork) {
2060-
condMsgProc.wait_until(lock, std::chrono::steady_clock::now() + std::chrono::milliseconds(100), [this] { return fMsgProcWake; });
2060+
condMsgProc.wait_until(lock, std::chrono::steady_clock::now() + std::chrono::milliseconds(100), [this]() EXCLUSIVE_LOCKS_REQUIRED(mutexMsgProc) { return fMsgProcWake; });
20612061
}
20622062
fMsgProcWake = false;
20632063
}
@@ -2366,7 +2366,7 @@ static CNetCleanup instance_of_cnetcleanup;
23662366
void CConnman::Interrupt()
23672367
{
23682368
{
2369-
std::lock_guard<std::mutex> lock(mutexMsgProc);
2369+
LOCK(mutexMsgProc);
23702370
flagInterruptMsgProc = true;
23712371
}
23722372
condMsgProc.notify_all();

src/net.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ class CConnman
451451
const uint64_t nSeed0, nSeed1;
452452

453453
/** flag for waking the message processor. */
454-
bool fMsgProcWake;
454+
bool fMsgProcWake GUARDED_BY(mutexMsgProc);
455455

456456
std::condition_variable condMsgProc;
457457
Mutex mutexMsgProc;

0 commit comments

Comments
 (0)