Skip to content

Commit

Permalink
fix cs_mapRelay deadlock (when both ProcessGetData and Broadcast try …
Browse files Browse the repository at this point in the history
…to lock cs_mapRelay and cs_vSend)
  • Loading branch information
dimxy committed Sep 11, 2021
1 parent 069a095 commit 91dfbd6
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7446,10 +7446,18 @@ void static ProcessGetData(CNode* pfrom)
// Send stream from relay memory
bool pushed = false;
{
LOCK(cs_mapRelay);
map<CInv, CDataStream>::iterator mi = mapRelay.find(inv);
if (mi != mapRelay.end()) {
pfrom->PushMessage(inv.GetCommand(), (*mi).second);
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
bool found = false;
{
LOCK(cs_mapRelay);
map<CInv, CDataStream>::iterator mi = mapRelay.find(inv);
if (mi != mapRelay.end()) {
ss = ((*mi).second);
found = true;
}
}
if (found) {
pfrom->PushMessage(inv.GetCommand(), ss);
pushed = true;
}
}
Expand Down

0 comments on commit 91dfbd6

Please sign in to comment.