[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[minion-cvs] Fix more bandwidth-cap bugs on write.



Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv22009/lib/mixminion

Modified Files:
	TLSConnection.py 
Log Message:
Fix more bandwidth-cap bugs on write.

Index: TLSConnection.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/TLSConnection.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- TLSConnection.py	7 Feb 2004 07:25:14 -0000	1.10
+++ TLSConnection.py	7 Feb 2004 08:58:53 -0000	1.11
@@ -278,6 +278,7 @@
                 # give up.
                 s = "x"
                 while s != 0:
+                    #XXXX007 respect cap.
                     s = self.tls.read(_READLEN) # might raise TLSWant*
                     if s == 0:
                         LOG.debug("Read returned 0; shutdown to %s done",
@@ -300,11 +301,12 @@
                 LOG.debug("Got a completed shutdown from %s", self.address)
                 self.shutdownFinished()
                 raise _Closing()
-                return 0
             else:
                 LOG.trace("Shutdown returned zero -- entering read mode.")
                 self.__awaitingShutdown = 1
                 self.__bytesReadOnShutdown = 0
+                self.wantRead = 1
+                return 1
 
     def __closedFn(self,r,w, cap):
         """state function: called when the connection is closed"""
@@ -358,10 +360,11 @@
                 self.outbuflen -= n
                 cap -= n
                 self.onWrite(n)
-        # There's no more data to write.  We only want write events now if
-        # read is blocking on write.
-        self.wantWrite = self.__readBlockedOnWrite
-        self.doneWriting()
+        if not self.outbuf:
+            # There's no more data to write.  We only want write events now if
+            # read is blocking on write.
+            self.wantWrite = self.__readBlockedOnWrite
+            self.doneWriting()
         return cap
 
     def __doRead(self, cap):
@@ -390,12 +393,11 @@
                         self.onRead()
             except _ml.TLSWantRead:
                 self.wantRead = 1
-                return cap
             except _ml.TLSWantWrite:
                 self.wantRead = 0
                 self.wantWrite = 1
                 self.__readBlockedOnWrite = 1
-                return cap
+            return cap
 
     def process(self, r, w, x, maxBytes=None):
         """Given that we've received read/write events as indicated in r/w,
@@ -409,7 +411,7 @@
         if not (r or w):
             return self.wantRead, self.wantWrite, (self.sock is not None),0
 
-        bytesAtStart = bytesNow = self.tls.get_num_bytes_raw();
+        bytesAtStart = bytesNow = self.tls.get_num_bytes_raw()
         if maxBytes is None:
             bytesCutoff = sys.maxint
             maxBytes = sys.maxint-bytesNow