]> code.delx.au - pymsnt/commitdiff
Added timeout to file sending.
authorjamesbunton <jamesbunton@55fbd22a-6204-0410-b2f0-b6c764c7e90a>
Tue, 2 May 2006 15:06:15 +0000 (15:06 +0000)
committerjamesbunton <jamesbunton@55fbd22a-6204-0410-b2f0-b6c764c7e90a>
Tue, 2 May 2006 15:06:15 +0000 (15:06 +0000)
git-svn-id: http://delx.cjb.net/svn/pymsnt/trunk@153 55fbd22a-6204-0410-b2f0-b6c764c7e90a

committer: jamesbunton <jamesbunton@55fbd22a-6204-0410-b2f0-b6c764c7e90a>

src/ft.py
src/misciq.py
src/tlib/msn/msn.py
src/tlib/throttle.py

index 756d3bfa16dd08979ffc4bc29c3b1f6b2a9291bf..218441a0d6384211ea12f5d25e96af0ce031352c 100644 (file)
--- a/src/ft.py
+++ b/src/ft.py
@@ -300,6 +300,8 @@ class JEP65ConnectionSend(protocol.Protocol):
        def connectionLost(self, reason):
                if self.state == self.STATE_READY:
                        self.factory.consumer.close()
+               else:
+                       self.factory.consumer.error()
        
        def _waitAuthOk(self):
                ver, method = struct.unpack("!BB", self.buf[:2])
index 64cbe90bc150754eae1e54cff76b2efe21935146..dc6baade6d9319102319a1afbd85211a93d63743 100644 (file)
@@ -660,6 +660,10 @@ class Socks5FileTransfer:
                                except error.NotConnectingError:
                                        pass
 
+                       if factory.streamHostTimeout:
+                               factory.streamHostTimeout.cancel()
+                               factory.streamHostTimeout = None
+
                        iq = Element((None, "iq"))
                        iq["type"] = "result"
                        iq["from"] = toj.full()
@@ -673,12 +677,15 @@ class Socks5FileTransfer:
 
 
                # Try the streamhosts
+               LogEvent(INFO)
                factory = protocol.ClientFactory()
                factory.protocol = ft.JEP65ConnectionSend
                factory.consumer = consumer
                factory.hash = utils.socks5Hash(sid, froj.full(), toj.full())
                factory.madeConnection = gotStreamhost
                factory.connectors = []
+               factory.streamHostTimeout = reactor.callLater(120, consumer.error)
+
                for streamhost in streamhosts:
                        factory.connectors.append(reactor.connectTCP(streamhost[1], streamhost[2], factory))
 
index 373c5511e6021c359c675e0f992dccb1e7be3c16..14f1a0182839a45aa28d3f741219b461d3f7e162 100644 (file)
@@ -154,7 +154,7 @@ STATUS_LUNCH   = 'LUN'
 
 PINGSPEED = 50.0
 
-DEBUGALL = False
+DEBUGALL = True
 LINEDEBUG = False
 MESSAGEDEBUG = False
 MSNP2PDEBUG = False
index 65df425e5c1ffcfff4b8cbba68229dc091f6f80f..88b194e8198be2b7d82e583ba928c9d22a5763c3 100644 (file)
@@ -21,6 +21,12 @@ class Throttler:
        def close(self):
                self.canClose = True
        
+       def error(self):
+               self.consumer.error()
+               self.consumer = None
+               self.buffer = None
+               self.loopTask.stop()
+       
        def loopFunc(self):
                if self.canClose and len(self.buffer) == 0:
                        self.consumer.close()