Transport optimisations

This commit is contained in:
Mark Qvist 2022-06-09 16:54:47 +02:00
parent d334613888
commit 0a8b755230

View File

@ -545,13 +545,12 @@ class Transport:
@staticmethod @staticmethod
def outbound(packet): def outbound(packet):
while (Transport.jobs_running): while (Transport.jobs_running):
# TODO: Profile actual impact here on faster links sleep(0.0005)
sleep(0.01)
Transport.jobs_locked = True Transport.jobs_locked = True
# TODO: This updateHash call might be redundant # TODO: This updateHash call might be redundant
packet.update_hash() # packet.update_hash()
sent = False sent = False
outbound_time = time.time() outbound_time = time.time()
@ -735,13 +734,14 @@ class Transport:
Transport.packet_hashlist.append(packet.packet_hash) Transport.packet_hashlist.append(packet.packet_hash)
stored_hash = True stored_hash = True
def send_packet(): # TODO: Re-evaluate potential for blocking
Transport.transmit(interface, packet.raw) # def send_packet():
# Transport.transmit(interface, packet.raw)
thread = threading.Thread(target=send_packet) # thread = threading.Thread(target=send_packet)
thread.daemon = True # thread.daemon = True
thread.start() # thread.start()
Transport.transmit(interface, packet.raw)
sent = True sent = True
if sent: if sent:
@ -860,7 +860,7 @@ class Transport:
return return
while (Transport.jobs_running): while (Transport.jobs_running):
sleep(0.01) sleep(0.0005)
if Transport.identity == None: if Transport.identity == None:
return return