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.
This commit is contained in:
Pieter Wuille 2012-04-17 18:50:45 +02:00
parent 7a5452ffb3
commit c581cc16bb

View File

@ -2807,8 +2807,8 @@ bool ProcessMessages(CNode* pfrom)
bool SendMessages(CNode* pto, bool fSendTrickle) bool SendMessages(CNode* pto, bool fSendTrickle)
{ {
{ TRY_LOCK(cs_main, lockMain);
LOCK(cs_main); if (lockMain) {
// Don't send anything until we get their version message // Don't send anything until we get their version message
if (pto->nVersion == 0) if (pto->nVersion == 0)
return true; return true;