Skip to content

Commit 46bdd4b

Browse files
author
MarcoFalke
committed
Merge #19178: Make mininode_lock non-reentrant
6206838 [tests] Make mininode_lock non-reentrant (John Newbery) c67c1f2 [tests] Don't call super twice in P2PTxInvStore.on_inv() (John Newbery) 9d80762 [tests] Don't acquire mininode_lock twice in wait_for_broadcast() (John Newbery) edae607 [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: ACK 6206838 😃 jonatack: ACK 6206838 Tree-SHA512: dcbc19e6c986970051705789be0ff7bec70c69cf76d5b468c2ba4cb732883ad512b1de5c3206c2eca41fa3f1c4806999df4cabbf67fc3c463bb817458e59a19c
2 parents 28ce05d + 6206838 commit 46bdd4b

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

test/functional/p2p_compactblocks.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,9 @@ def test_compactblock_construction(self, test_node, use_witness_address=True):
305305
self.check_compactblock_construction_from_block(version, header_and_shortids, block_hash, block)
306306

307307
# Now fetch the compact block using a normal non-announce getdata
308-
with mininode_lock:
309-
test_node.clear_block_announcement()
310-
inv = CInv(MSG_CMPCT_BLOCK, block_hash)
311-
test_node.send_message(msg_getdata([inv]))
308+
test_node.clear_block_announcement()
309+
inv = CInv(MSG_CMPCT_BLOCK, block_hash)
310+
test_node.send_message(msg_getdata([inv]))
312311

313312
wait_until(test_node.received_block_announcement, timeout=30, lock=mininode_lock)
314313

test/functional/test_framework/mininode.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ def test_function():
492492
# P2PConnection acquires this lock whenever delivering a message to a P2PInterface.
493493
# This lock should be acquired in the thread running the test logic to synchronize
494494
# access to any data shared with the P2PInterface or P2PConnection.
495-
mininode_lock = threading.RLock()
495+
mininode_lock = threading.Lock()
496496

497497

498498
class NetworkThread(threading.Thread):
@@ -658,8 +658,6 @@ def on_inv(self, message):
658658
# save txid
659659
self.tx_invs_received[i.hash] += 1
660660

661-
super().on_inv(message)
662-
663661
def get_invs(self):
664662
with mininode_lock:
665663
return list(self.tx_invs_received.keys())
@@ -669,6 +667,6 @@ def wait_for_broadcast(self, txns, timeout=60):
669667
The mempool should mark unbroadcast=False for these transactions.
670668
"""
671669
# Wait until invs have been received (and getdatas sent) for each txid.
672-
self.wait_until(lambda: set(self.get_invs()) == set([int(tx, 16) for tx in txns]), timeout)
670+
self.wait_until(lambda: set(self.tx_invs_received.keys()) == set([int(tx, 16) for tx in txns]), timeout)
673671
# Flush messages and wait for the getdatas to be processed
674672
self.sync_with_ping()

0 commit comments

Comments
 (0)