From: Pieter Wuille Date: Tue, 17 Apr 2012 16:50:45 +0000 (+0200) Subject: Fix potential deadlock X-Git-Tag: v0.4.0-unstable~129^2~1^2^2~2^2^2~22 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=dc588faf5922d8ca449dea61bbe899532497c914 Fix potential deadlock Conflict: * cs_main in ProcessMessages() (before calling ProcessMessages) * cs_vSend in CNode::BeginMessage versus: * cs_vSend in ThreadMessageHandler2 (before calling SendMessages) * cs_main in SendMessages Even though cs_vSend is a try_lock, if it succeeds simultaneously with the locking of cs_main in ProcessMessages(), it could cause a deadlock. --- diff --git a/src/main.cpp b/src/main.cpp index 76e0783..e6f9421 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2618,7 +2618,7 @@ bool ProcessMessages(CNode* pfrom) bool SendMessages(CNode* pto, bool fSendTrickle) { - CRITICAL_BLOCK(cs_main) + TRY_CRITICAL_BLOCK(cs_main) { // Don't send anything until we get their version message if (pto->nVersion == 0)