Merge #19178: Make mininode_lock non-reentrant
62068381a3[tests] Make mininode_lock non-reentrant (John Newbery)c67c1f2c03[tests] Don't call super twice in P2PTxInvStore.on_inv() (John Newbery)9d80762fa0[tests] Don't acquire mininode_lock twice in wait_for_broadcast() (John Newbery)edae6075aa[tests] Only acquire lock once in p2p_compactblocks.py (John Newbery) Pull request description: There's no need for mininode_lock to be reentrant. Use a simpler non-recursive lock. ACKs for top commit: MarcoFalke: ACK62068381a3😃 jonatack: ACK62068381a3Tree-SHA512: dcbc19e6c986970051705789be0ff7bec70c69cf76d5b468c2ba4cb732883ad512b1de5c3206c2eca41fa3f1c4806999df4cabbf67fc3c463bb817458e59a19c
This commit is contained in:
2 files changed
+5
-8
No files matched your search
@@ -305,10 +305,9 @@ class CompactBlocksTest(BitcoinTestFramework):
|
|||||||
self.check_compactblock_construction_from_block(version, header_and_shortids, block_hash, block)
|
self.check_compactblock_construction_from_block(version, header_and_shortids, block_hash, block)
|
||||||
|
|
||||||
# Now fetch the compact block using a normal non-announce getdata
|
# Now fetch the compact block using a normal non-announce getdata
|
||||||
with mininode_lock:
|
test_node.clear_block_announcement()
|
||||||
test_node.clear_block_announcement()
|
inv = CInv(MSG_CMPCT_BLOCK, block_hash)
|
||||||
inv = CInv(MSG_CMPCT_BLOCK, block_hash)
|
test_node.send_message(msg_getdata([inv]))
|
||||||
test_node.send_message(msg_getdata([inv]))
|
|
||||||
|
|
||||||
wait_until(test_node.received_block_announcement, timeout=30, lock=mininode_lock)
|
wait_until(test_node.received_block_announcement, timeout=30, lock=mininode_lock)
|
||||||
|
|
||||||
|
|||||||
@@ -492,7 +492,7 @@ class P2PInterface(P2PConnection):
|
|||||||
# P2PConnection acquires this lock whenever delivering a message to a P2PInterface.
|
# P2PConnection acquires this lock whenever delivering a message to a P2PInterface.
|
||||||
# This lock should be acquired in the thread running the test logic to synchronize
|
# This lock should be acquired in the thread running the test logic to synchronize
|
||||||
# access to any data shared with the P2PInterface or P2PConnection.
|
# access to any data shared with the P2PInterface or P2PConnection.
|
||||||
mininode_lock = threading.RLock()
|
mininode_lock = threading.Lock()
|
||||||
|
|
||||||
|
|
||||||
class NetworkThread(threading.Thread):
|
class NetworkThread(threading.Thread):
|
||||||
@@ -658,8 +658,6 @@ class P2PTxInvStore(P2PInterface):
|
|||||||
# save txid
|
# save txid
|
||||||
self.tx_invs_received[i.hash] += 1
|
self.tx_invs_received[i.hash] += 1
|
||||||
|
|
||||||
super().on_inv(message)
|
|
||||||
|
|
||||||
def get_invs(self):
|
def get_invs(self):
|
||||||
with mininode_lock:
|
with mininode_lock:
|
||||||
return list(self.tx_invs_received.keys())
|
return list(self.tx_invs_received.keys())
|
||||||
@@ -669,6 +667,6 @@ class P2PTxInvStore(P2PInterface):
|
|||||||
The mempool should mark unbroadcast=False for these transactions.
|
The mempool should mark unbroadcast=False for these transactions.
|
||||||
"""
|
"""
|
||||||
# Wait until invs have been received (and getdatas sent) for each txid.
|
# Wait until invs have been received (and getdatas sent) for each txid.
|
||||||
self.wait_until(lambda: set(self.get_invs()) == set([int(tx, 16) for tx in txns]), timeout)
|
self.wait_until(lambda: set(self.tx_invs_received.keys()) == set([int(tx, 16) for tx in txns]), timeout)
|
||||||
# Flush messages and wait for the getdatas to be processed
|
# Flush messages and wait for the getdatas to be processed
|
||||||
self.sync_with_ping()
|
self.sync_with_ping()
|
||||||
Reference in new issue
Block a user