This builds off of #6089, with more fixes for the python p2p testing framework (see #5981).
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. However, there was no existing lock to protect other data structures that are not specific to a single NodeConnCB, such as BlockStore or TxStore, which are created in comptool.py and shared by all the NodeConnCB instances.
Moreover comptool.py had a race condition because it wasn't synchronizing access to the BlockStore, nor using the existing NodeConnCB locks before accessing the block_request_map inside the comptool.py TestNode objects. I believe this type of race condition triggered a test failure reported in #5981.
This pull tries to simplify the synchronization and make the code more robust to race conditions by replacing all the individual locks one single global lock that we now use to synchronize the two threads. The networking thread acquires this lock before delivering every message; NodeConn.send_message() uses this lock to synchronize access to the sendbuf; and the thread running the test logic will now acquire this lock before accessing any data shared with one or more NodeConnCB or NodeConn objects.