Page MenuHomePhabricator

D9433.diff
No OneTemporary

D9433.diff

diff --git a/src/net.h b/src/net.h
--- a/src/net.h
+++ b/src/net.h
@@ -959,7 +959,7 @@
// There is no final sorting before sending, as they are always sent
// immediately and in the order requested.
std::vector<BlockHash> vInventoryBlockToSend GUARDED_BY(cs_inventory);
- RecursiveMutex cs_inventory;
+ Mutex cs_inventory;
struct TxRelay {
mutable RecursiveMutex cs_filter;
@@ -1161,16 +1161,6 @@
}
}
- void PushBlockInventory(const BlockHash &blockhash) {
- LOCK(cs_inventory);
- vInventoryBlockToSend.push_back(blockhash);
- }
-
- void PushBlockHash(const BlockHash &hash) {
- LOCK(cs_inventory);
- vBlockHashesToAnnounce.push_back(hash);
- }
-
void CloseSocketDisconnect();
void copyStats(CNodeStats &stats, const std::vector<bool> &m_asmap);
diff --git a/src/net.cpp b/src/net.cpp
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -1214,12 +1214,9 @@
if (pnode->GetRefCount() <= 0) {
bool fDelete = false;
{
- TRY_LOCK(pnode->cs_inventory, lockInv);
- if (lockInv) {
- TRY_LOCK(pnode->cs_vSend, lockSend);
- if (lockSend) {
- fDelete = true;
- }
+ TRY_LOCK(pnode->cs_vSend, lockSend);
+ if (lockSend) {
+ fDelete = true;
}
}
if (fDelete) {
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -1654,11 +1654,12 @@
// Relay inventory, but don't relay old inventory during initial block
// download.
m_connman.ForEachNode([nNewHeight, &vHashes](CNode *pnode) {
+ LOCK(pnode->cs_inventory);
if (nNewHeight > (pnode->nStartingHeight != -1
? pnode->nStartingHeight - 2000
: 0)) {
for (const BlockHash &hash : reverse_iterate(vHashes)) {
- pnode->PushBlockHash(hash);
+ pnode->vBlockHashesToAnnounce.push_back(hash);
}
}
});
@@ -1961,7 +1962,7 @@
// Trigger the peer node to send a getblocks request for the next batch
// of inventory.
if (hash == pfrom.hashContinue) {
- // Bypass PushBlockInventory, this must send even if redundant, and
+ // Send immediately. This must send even if redundant, and
// we want it right after the last block so they don't wait for
// other stuff first.
std::vector<CInv> vInv;
@@ -3230,7 +3231,8 @@
pindex->nHeight, pindex->GetBlockHash().ToString());
break;
}
- pfrom.PushBlockInventory(pindex->GetBlockHash());
+ WITH_LOCK(pfrom.cs_inventory, pfrom.vInventoryBlockToSend.push_back(
+ pindex->GetBlockHash()));
if (--nLimit <= 0) {
// When this block is requested, we'll send an inv that'll
// trigger the peer to getblocks the next batch of inventory.
@@ -5131,7 +5133,7 @@
// If the peer's chain has this block, don't inv it back.
if (!PeerHasHeader(&state, pindex)) {
- pto->PushBlockInventory(hashToAnnounce);
+ pto->vInventoryBlockToSend.push_back(hashToAnnounce);
LogPrint(BCLog::NET,
"%s: sending inv peer=%d hash=%s\n", __func__,
pto->GetId(), hashToAnnounce.ToString());

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 1, 12:41 (3 m, 20 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187877
Default Alt Text
D9433.diff (3 KB)

Event Timeline