Asyncore update

- incoming object handling fix
This commit is contained in:
Peter Šurda 2017-05-29 14:52:31 +02:00
parent 1ccfd41c3f
commit 7f381c0c25
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87
3 changed files with 7 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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: