Asyncore updates
- performance optimisation, reduce number of loops when waiting for protocol headers / commands
This commit is contained in:
parent
2555f692eb
commit
18988ae2e6
|
@ -78,13 +78,13 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
|||
if self.magic != 0xE9BEB4D9:
|
||||
# skip 1 byte in order to sync
|
||||
self.bm_proto_reset()
|
||||
self.set_state("bm_header", 1)
|
||||
self.set_state("bm_header", length=1, expectBytes=protocol.Header.size)
|
||||
logger.debug("Bad magic")
|
||||
self.close()
|
||||
return False
|
||||
if self.payloadLength > BMProto.maxMessageSize:
|
||||
self.invalid = True
|
||||
self.set_state("bm_command", protocol.Header.size, expectBytes=self.payloadLength)
|
||||
self.set_state("bm_command", length=protocol.Header.size, expectBytes=self.payloadLength)
|
||||
return True
|
||||
|
||||
def state_bm_command(self):
|
||||
|
@ -130,7 +130,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
|||
self.close()
|
||||
return False
|
||||
if retval:
|
||||
self.set_state("bm_header", self.payloadLength)
|
||||
self.set_state("bm_header", length=self.payloadLength, expectBytes=protocol.Header.size)
|
||||
self.bm_proto_reset()
|
||||
# else assume the command requires a different state to follow
|
||||
return True
|
||||
|
|
|
@ -69,7 +69,7 @@ class TCPConnection(BMProto, TLSDispatcher):
|
|||
ObjectTracker.__init__(self)
|
||||
UISignalQueue.put(('updateNetworkStatusTab', 'no data'))
|
||||
self.bm_proto_reset()
|
||||
self.set_state("bm_header")
|
||||
self.set_state("bm_header", expectBytes=protocol.Header.size)
|
||||
|
||||
def antiIntersectionDelay(self, initial = False):
|
||||
# estimated time for a small object to propagate across the whole network
|
||||
|
|
|
@ -68,7 +68,7 @@ class UDPSocket(BMProto):
|
|||
ObjectTracker.__init__(self)
|
||||
self.connecting = False
|
||||
self.connected = True
|
||||
self.set_state("bm_header")
|
||||
self.set_state("bm_header", expectBytes=protocol.Header.size)
|
||||
|
||||
def state_bm_command(self):
|
||||
BMProto.state_bm_command(self)
|
||||
|
|
Reference in New Issue
Block a user