r117 - in /debtorrent/trunk/DebTorrent: BT1/AptListener.py launchmanycore.py

camrdale-guest at users.alioth.debian.org camrdale-guest at users.alioth.debian.org
Tue Jun 19 22:23:01 UTC 2007


Author: camrdale-guest
Date: Tue Jun 19 22:23:01 2007
New Revision: 117

URL: http://svn.debian.org/wsvn/debtorrent/?sc=1&rev=117
Log:
Check for closed connections while processing the AptListener download queue.

Modified:
    debtorrent/trunk/DebTorrent/BT1/AptListener.py
    debtorrent/trunk/DebTorrent/launchmanycore.py

Modified: debtorrent/trunk/DebTorrent/BT1/AptListener.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/BT1/AptListener.py?rev=117&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/BT1/AptListener.py (original)
+++ debtorrent/trunk/DebTorrent/BT1/AptListener.py Tue Jun 19 22:23:01 2007
@@ -340,11 +340,16 @@
     def process_queue(self):
         """Process the queue of waiting requests."""
         
-        # TODO: check for and remove/rerequest old connections
         # Schedule it again
         self.rawserver.add_task(self.process_queue, 1)
         
+        closed_conns = []
         for c, v in self.request_queue.items():
+            # Check for a closed connection
+            if c.closed:
+                closed_conns.append(c)
+                continue
+                
             # Remove the downloaded pieces from the list of needed ones
             for piece in list(v[2]):
                 if v[0].storagewrapper.do_I_have(piece):
@@ -358,6 +363,10 @@
                     print 'queued request for file', v[1], 'is complete'
                 del self.request_queue[c]
                 self.answer_package(c, v[0], v[1])
+
+        # Remove closed connections from the queue
+        for c in closed_conns:
+            del self.request_queue[c]
 
 
     def get_infopage(self):
@@ -659,7 +668,6 @@
         
         infohash = sha(bencode(response['info'])).digest()
         
-        # TODO: cleanup, all these aren't needed
         a = {}
         a['path'] = '/'.join(path)
         a['file'] = name

Modified: debtorrent/trunk/DebTorrent/launchmanycore.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/launchmanycore.py?rev=117&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/launchmanycore.py (original)
+++ debtorrent/trunk/DebTorrent/launchmanycore.py Tue Jun 19 22:23:01 2007
@@ -628,7 +628,7 @@
             for f in data['metainfo']['info']['files']:
                 file_num += 1
                 
-                # Check that the file ends with the desired file name (TODO: security risk?)
+                # Check that the file ends with the desired file name
                 if file.endswith('/'.join(f['path'])):
                     if DEBUG:
                         print 'Found file in:', binascii.b2a_hex(hash)




More information about the Debtorrent-commits mailing list