From 7f381c0c2580a30c8d5ab7e1f140a6d0e8f0c7ff Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Mon, 29 May 2017 14:52:31 +0200 Subject: [PATCH] Asyncore update - incoming object handling fix --- src/network/bmproto.py | 3 +-- src/network/connectionpool.py | 2 +- src/network/invthread.py | 6 +++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/network/bmproto.py b/src/network/bmproto.py index 2ad1853d..87d24bba 100644 --- a/src/network/bmproto.py +++ b/src/network/bmproto.py @@ -298,8 +298,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker): self.object.objectType, self.object.streamNumber, self.payload[objectOffset:], self.object.expiresTime, self.object.tag) objectProcessorQueue.put((self.object.objectType,self.object.data)) #DownloadQueue().task_done(self.object.inventoryHash) - network.connectionpool.BMConnectionPool().handleReceivedObject(self, self.object.streamNumber, self.object.inventoryHash) - invQueue.put((self.object.streamNumber, self.object.inventoryHash)) + invQueue.put((self.object.streamNumber, self.object.inventoryHash, self)) #ObjUploadQueue().put(UploadElem(self.object.streamNumber, self.object.inventoryHash)) #broadcastToSendDataQueues((streamNumber, 'advertiseobject', inventoryHash)) return True diff --git a/src/network/connectionpool.py b/src/network/connectionpool.py index e9bc56c8..1e2ed311 100644 --- a/src/network/connectionpool.py +++ b/src/network/connectionpool.py @@ -34,7 +34,7 @@ class BMConnectionPool(object): self.bootstrapped = False - def handleReceivedObject(self, connection, streamNumber, hashid): + def handleReceivedObject(self, streamNumber, hashid, connection = None): for i in self.inboundConnections.values() + self.outboundConnections.values(): if not isinstance(i, network.bmproto.BMProto): continue diff --git a/src/network/invthread.py b/src/network/invthread.py index 1fd4a401..2f0ab594 100644 --- a/src/network/invthread.py +++ b/src/network/invthread.py @@ -34,7 +34,11 @@ class InvThread(threading.Thread, StoppableThread): while not state.shutdown: while True: try: - (stream, hash) = invQueue.get(False) + data = invQueue.get(False) + if len(data) == 2: + BMConnectionPool().handleReceivedObject(self, data[0], data[1]) + else: + BMConnectionPool().handleReceivedObject(self, data[0], data[1], data[3]) self.holdHash (stream, hash) #print "Holding hash %i, %s" % (stream, hexlify(hash)) except Queue.Empty: