Force synchronous processing for entire announce logic flow
This commit is contained in:
parent
c9b6dc007a
commit
326d719a49
1 changed files with 295 additions and 286 deletions
|
|
@ -37,6 +37,7 @@ import struct
|
|||
import inspect
|
||||
import threading
|
||||
from time import sleep
|
||||
from threading import Lock
|
||||
from .vendor import umsgpack as umsgpack
|
||||
from RNS.Interfaces.BackboneInterface import BackboneInterface
|
||||
|
||||
|
|
@ -154,6 +155,7 @@ class Transport:
|
|||
tables_cull_interval = 5.0
|
||||
interface_last_jobs = 0.0
|
||||
interface_jobs_interval = 5.0
|
||||
inbound_announce_lock = Lock()
|
||||
|
||||
traffic_rxb = 0
|
||||
traffic_txb = 0
|
||||
|
|
@ -1524,6 +1526,7 @@ class Transport:
|
|||
|
||||
random_blob = packet.data[RNS.Identity.KEYSIZE//8+RNS.Identity.NAME_HASH_LENGTH//8:RNS.Identity.KEYSIZE//8+RNS.Identity.NAME_HASH_LENGTH//8+10]
|
||||
random_blobs = []
|
||||
with Transport.inbound_announce_lock:
|
||||
if packet.destination_hash in Transport.path_table:
|
||||
random_blobs = Transport.path_table[packet.destination_hash][IDX_PT_RANDBLOBS]
|
||||
|
||||
|
|
@ -1818,24 +1821,30 @@ class Transport:
|
|||
execute_callback = False
|
||||
|
||||
if execute_callback:
|
||||
|
||||
if len(inspect.signature(handler.received_announce).parameters) == 3:
|
||||
def job():
|
||||
handler.received_announce(destination_hash=packet.destination_hash,
|
||||
announced_identity=announce_identity,
|
||||
app_data=RNS.Identity.recall_app_data(packet.destination_hash))
|
||||
threading.Thread(target=job, daemon=True).start()
|
||||
|
||||
elif len(inspect.signature(handler.received_announce).parameters) == 4:
|
||||
def job():
|
||||
handler.received_announce(destination_hash=packet.destination_hash,
|
||||
announced_identity=announce_identity,
|
||||
app_data=RNS.Identity.recall_app_data(packet.destination_hash),
|
||||
announce_packet_hash = packet.packet_hash)
|
||||
threading.Thread(target=job, daemon=True).start()
|
||||
|
||||
elif len(inspect.signature(handler.received_announce).parameters) == 5:
|
||||
def job():
|
||||
handler.received_announce(destination_hash=packet.destination_hash,
|
||||
announced_identity=announce_identity,
|
||||
app_data=RNS.Identity.recall_app_data(packet.destination_hash),
|
||||
announce_packet_hash = packet.packet_hash,
|
||||
is_path_response = packet.context == RNS.Packet.PATH_RESPONSE)
|
||||
threading.Thread(target=job, daemon=True).start()
|
||||
|
||||
else:
|
||||
raise TypeError("Invalid signature for announce handler callback")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue