Skip to content

Commit bd02bdd

Browse files
committed
Release cs_main before processing cmpctblock as header
1 parent 680b0c0 commit bd02bdd

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/net_processing.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,6 +1789,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
17891789
bool fProcessBLOCKTXN = false;
17901790
CDataStream blockTxnMsg(SER_NETWORK, PROTOCOL_VERSION);
17911791

1792+
// If we end up treating this as a plain headers message, call that as well
1793+
// without cs_main.
1794+
bool fRevertToHeaderProcessing = false;
1795+
CDataStream vHeadersMsg(SER_NETWORK, PROTOCOL_VERSION);
1796+
17921797
// Keep a CBlock for "optimistic" compactblock reconstructions (see
17931798
// below)
17941799
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>();
@@ -1913,16 +1918,18 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
19131918
// Dirty hack to process as if it were just a headers message (TODO: move message handling into their own functions)
19141919
std::vector<CBlock> headers;
19151920
headers.push_back(cmpctblock.header);
1916-
CDataStream vHeadersMsg(SER_NETWORK, PROTOCOL_VERSION);
19171921
vHeadersMsg << headers;
1918-
return ProcessMessage(pfrom, NetMsgType::HEADERS, vHeadersMsg, nTimeReceived, chainparams, connman);
1922+
fRevertToHeaderProcessing = true;
19191923
}
19201924
}
19211925
} // cs_main
19221926

19231927
if (fProcessBLOCKTXN)
19241928
return ProcessMessage(pfrom, NetMsgType::BLOCKTXN, blockTxnMsg, nTimeReceived, chainparams, connman);
19251929

1930+
if (fRevertToHeaderProcessing)
1931+
return ProcessMessage(pfrom, NetMsgType::HEADERS, vHeadersMsg, nTimeReceived, chainparams, connman);
1932+
19261933
if (fBlockReconstructed) {
19271934
// If we got here, we were able to optimistically reconstruct a
19281935
// block that is in flight from some other peer.

0 commit comments

Comments
 (0)