Commits

Martin Gergov committed bb58ad6

loseConnection is safe to call.

  • Participants
  • Parent commits f0232b6

Comments (0)

Files changed (2)

File examples/newserver.py

         #print self.counter
         log.msg("{2}:received {0}:{1}".format(self.counter, data, len(data)))
         if self.counter == 10:
+            self.transport.loseConnection()
             return
         self.transport.write(data)
         self.counter += 1

File udt4twisted/udt.py

 
         @see: L{twisted.internet.interfaces.IWriteDescriptor.doWrite}.
         """
-
+        # If we're empty return
+        if len(self.messageBuffer) == 0:
+            #check for graceful disconnection
+            if self.disconnecting:
+                return self._postLoseConnection()
+            return None
         # Send as much data as you can.
-        if len(self.messageBuffer) == 0:
-            return None
         result = self.splitAndSend()
-        if len(self.messageBuffer) == 0:
+        if len(self.messageBuffer) == 0 or result:
             #self.stopWriting()
             #Really stop writable event
             self.reactor._poller.remove_usock(self.socket.UDTSOCKET)