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

[minion-cvs] Fix some bugs in resource cap code



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

Modified Files:
	ClientMain.py TLSConnection.py 
Log Message:
Fix some bugs in resource cap code

Index: ClientMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ClientMain.py,v
retrieving revision 1.153
retrieving revision 1.154
diff -u -d -r1.153 -r1.154
--- ClientMain.py	2 Feb 2004 07:05:49 -0000	1.153
+++ ClientMain.py	7 Feb 2004 07:25:14 -0000	1.154
@@ -490,11 +490,7 @@
         try:
             clientLock()
             if nGood:
-                if len(pktList) > 1:
-                    mword = "packets"
-                else:
-                    mword = "packet"
-                LOG.info("... %s %s sent", nGood, mword)
+                LOG.info("... %s sent", nGood)
                 LOG.trace("Removing %s successful packets from queue", nGood)
             for idx in packetsSentByIndex.keys():
                 if handles and handles[idx]:
@@ -508,9 +504,10 @@
                     e2 = sys.exc_info()
                     LOG.error("Error while cleaning queue: %s",e2[1])
 
-            if nBad and warnIfLost:
-                LOG.error("Error with queueing disabled: %s/%s lost",
-                          nBad, nGood+nBad)
+            if nBad and noQueue:
+                if warnIfLost:
+                    LOG.error("Error with queueing disabled: %s/%s lost",
+                              nBad, nGood+nBad)
             elif nBad and lazyQueue:
                 LOG.info("Error while delivering packets; %s/%s left in queue",
                          nBad,nGood+nBad)
@@ -520,10 +517,11 @@
 
                 self.queuePackets(badPackets, routingInfo)
             elif nBad:
-                LOG.info("Error while delivering %s; leaving %s/%s in queue",
-                         mword, nBad, nBad+nGood)
+                assert not (noQueue or lazyQueue)
+                LOG.info("Error while delivering packets; leaving %s/%s in queue",
+                         nBad, nBad+nGood)
             if exc and not nBad:
-                LOG.info("Got error after all messages were delivered.")
+                LOG.info("Got error after all packets were delivered.")
             if exc:
                 LOG.info("Error was: %s",exc[1])
         finally:

Index: TLSConnection.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/TLSConnection.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- TLSConnection.py	6 Feb 2004 23:14:28 -0000	1.9
+++ TLSConnection.py	7 Feb 2004 07:25:14 -0000	1.10
@@ -367,7 +367,7 @@
     def __doRead(self, cap):
         "Helper function: read as much data as we can."
         self.__readBlockedOnWrite = 0
-        while self.__reading and cap >= 0:
+        while self.__reading and cap > 0:
             try:
                 s = self.tls.read(min(_READLEN,cap))
                 if s == 0:
@@ -379,7 +379,8 @@
                     return cap
                 else:
                     # We got some data; add it to the inbuf.
-                    LOG.trace("Read got %s bytes from %s", len(s),self.address)
+                    LOG.trace("Read got %s bytes from %s", 
+                              len(s), self.address)
                     self.inbuf.append(s)
                     self.inbuflen += len(s)
                     cap -= len(s)
@@ -413,7 +414,7 @@
             bytesCutoff = sys.maxint
             maxBytes = sys.maxint-bytesNow
         else:
-            bytesCutoff = nr+nw+maxBytes
+            bytesCutoff = bytesNow+maxBytes
         try:
             self.lastActivity = time.time()
             while bytesNow < bytesCutoff and self.__stateFn(r, w, maxBytes):