mirror of
https://github.com/markqvist/Reticulum.git
synced 2026-10-26 02:48:57 -04:00
Contention comments
This commit is contained in:
parent
2d7f858a54
commit
e46496032c
1 changed files with 9 additions and 0 deletions
|
|
@ -571,6 +571,9 @@ class Transport:
|
|||
|
||||
# Process receipts list for timed-out packets
|
||||
if time.time() > Transport.receipts_last_checked+Transport.receipts_check_interval:
|
||||
# TODO: The pop(0) is expensive under the lock.
|
||||
# Could improve contention via an initial reverse(),
|
||||
# then pop() trick or similar.
|
||||
with Transport.receipts_lock:
|
||||
while len(Transport.receipts) > Transport.MAX_RECEIPTS:
|
||||
culled_receipt = Transport.receipts.pop(0)
|
||||
|
|
@ -578,6 +581,9 @@ class Transport:
|
|||
culled_receipt.check_timeout()
|
||||
should_collect = True
|
||||
|
||||
# TODO: Actually, this whole thing might need re-
|
||||
# thinking a bit, but may require moving receipts
|
||||
# to a dict or something else entirely.
|
||||
with Transport.receipts_lock:
|
||||
expired_receipts = []
|
||||
for receipt in Transport.receipts:
|
||||
|
|
@ -2349,6 +2355,9 @@ class Transport:
|
|||
else:
|
||||
RNS.log("Proof received on wrong interface, not transporting it.", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
|
||||
# TODO: Lock contention could be improved here
|
||||
# by a copy(), instead of running the list
|
||||
# comprehension under lock.
|
||||
with Transport.receipts_lock:
|
||||
if proof_hash != None:
|
||||
# Only test validation if hash matches
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue