[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[minion-cvs] Fix a couple of shallow CPU-eating bugs so that cvs min...
Update of /home/minion/cvsroot/src/minion/lib/mixminion/server
In directory moria.mit.edu:/tmp/cvs-serv14453/lib/mixminion/server
Modified Files:
MMTPServer.py
Log Message:
Fix a couple of shallow CPU-eating bugs so that cvs minion doesnt eat my CPU anymore
Index: MMTPServer.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/MMTPServer.py,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- MMTPServer.py 12 Jan 2004 00:49:00 -0000 1.71
+++ MMTPServer.py 22 Jan 2004 05:42:07 -0000 1.72
@@ -146,7 +146,9 @@
(1,2): select.POLLIN+select.POLLOUT+select.POLLERR }
def process(self,timeout):
try:
- events = self.poll.poll(timeout)
+ # (watch out: poll takes a timeout in msec, but select takes a
+ # timeout in sec.)
+ events = self.poll.poll(timeout*1000)
except select.error, e:
if e[0] == errno.EINTR:
return
@@ -154,7 +156,8 @@
raise e
for fd, mask in events:
c = self.connections[fd]
- wr,ww,isopen = c.process(mask&select.POLLIN, mask&select.POLLOUT)
+ wr,ww,isopen = c.process(mask&select.POLLIN, mask&select.POLLOUT,
+ mask&(select.POLLERR|select.POLLHUP))
if not isopen:
self.poll.unregister(fd)
del self.connections[fd]
@@ -180,7 +183,7 @@
class Connection:
"A connection is an abstract superclass for asynchronous channels"
- def process(self, r, w):
+ def process(self, r, w, x):
"""Invoked when there is data to read or write. Must return a 3-tuple
of (wantRead, wantWrite, isOpen)."""
return 0,0,0
@@ -225,7 +228,8 @@
LOG.info("Listening at %s on port %s (fd %s)",
ip, port, self.sock.fileno())
- def process(self, r, w):
+ def process(self, r, w, x):
+ #XXXX007 do something with x
con, addr = self.sock.accept()
LOG.debug("Accepted connection from %s (fd %s)", addr, con.fileno())
self.connectionFactory(con)
@@ -255,8 +259,11 @@
MESSAGE_LEN = 6 + (1<<15) + 20
PROTOCOL_VERSIONS = ['0.3']
def __init__(self, sock, tls, consumer, rejectPackets=0):
+ addr,port=sock.getpeername()
+ serverName = "%s:%s (fd %s)"%(addr,port,sock.fileno())
+
mixminion.TLSConnection.TLSConnection.__init__(
- self, tls, sock, "%s:%s"%sock.getpeername())
+ self, tls, sock, serverName)
EventStats.log.receivedConnection()
self.packetConsumer = consumer
self.junkCallback = lambda : None