aboutsummaryrefslogtreecommitdiff
path: root/qa/rpc-tests/maxblocksinflight.py
diff options
context:
space:
mode:
authorSuhas Daftuar <sdaftuar@gmail.com>2015-05-01 14:47:21 -0400
committerSuhas Daftuar <sdaftuar@gmail.com>2015-05-01 15:32:24 -0400
commit574db4816fd340b57970760ec30f4c8d6234187f (patch)
tree205d7b6e4e39471b581e7e3f6533699a8d5c0c45 /qa/rpc-tests/maxblocksinflight.py
parent5487975ca3e26e959a815679ba326fb33d6baf8d (diff)
Fix potential race conditions in p2p testing framework
Previously, each NodeConnCB had its own lock to synchronize data structures used by the testing thread and the networking thread, and NodeConn provided a separate additional lock for synchronizing access to each send buffer. This commit replaces those locks with a single global lock (mininode_lock) that we use to synchronize access to all data structures shared by the two threads. Updates comptool and maxblocksinflight to use the new synchronization semantics, eliminating previous race conditions within comptool, and re-enables invalidblockrequest.py in travis.
Diffstat (limited to 'qa/rpc-tests/maxblocksinflight.py')
-rwxr-xr-xqa/rpc-tests/maxblocksinflight.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/qa/rpc-tests/maxblocksinflight.py b/qa/rpc-tests/maxblocksinflight.py
index 94535822d8..87c80cd97e 100755
--- a/qa/rpc-tests/maxblocksinflight.py
+++ b/qa/rpc-tests/maxblocksinflight.py
@@ -61,10 +61,11 @@ class TestManager(NodeConnCB):
time.sleep(2)
total_requests = 0
- for key in self.blockReqCounts:
- total_requests += self.blockReqCounts[key]
- if self.blockReqCounts[key] > 1:
- raise AssertionError("Error, test failed: block %064x requested more than once" % key)
+ with mininode_lock:
+ for key in self.blockReqCounts:
+ total_requests += self.blockReqCounts[key]
+ if self.blockReqCounts[key] > 1:
+ raise AssertionError("Error, test failed: block %064x requested more than once" % key)
if total_requests > MAX_REQUESTS:
raise AssertionError("Error, too many blocks (%d) requested" % total_requests)
print "Round %d: success (total requests: %d)" % (count, total_requests)