Skip to content

Commit

Permalink
Merge bitcoin#21775: p2p: Limit m_block_inv_mutex
Browse files Browse the repository at this point in the history
fac96d0 p2p: Limit m_block_inv_mutex (MarcoFalke)

Pull request description:

  Keeping the lock longer than needed is confusing to reviewers and thread analysis. For example, keeping the lock while appending tx-invs, which requires the mempool lock, will tell thread analysis tools an incorrect lock order of `(1) m_block_inv_mutex, (2) pool.cs`.

ACKs for top commit:
  Crypt-iQ:
    crACK fac96d0
  jnewbery:
    utACK fac96d0
  theStack:
    Code-Review ACK fac96d0

Tree-SHA512: fcfac0f1f8b16df7522513abf716b2eed3d2fc9153f231c8cb61f451e342f29c984a5c872deca6bab3e601e5d651874cc229146c9370e46811b4520747a21f2b
  • Loading branch information
MarcoFalke committed May 3, 2021
2 parents 320e518 + fac96d0 commit b859361
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4449,8 +4449,9 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
}
}
peer->m_blocks_for_inv_relay.clear();
}

if (pto->m_tx_relay != nullptr) {
if (pto->m_tx_relay != nullptr) {
LOCK(pto->m_tx_relay->cs_tx_inventory);
// Check whether periodic sends should happen
bool fSendTrickle = pto->HasPermission(PF_NOBAN);
Expand Down Expand Up @@ -4578,7 +4579,6 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
}
}
}
}
}
if (!vInv.empty())
m_connman.PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv));
Expand Down

0 comments on commit b859361

Please sign in to comment.