Be explicit about blocking status.

Apparently the assumption that sockets don't inherit their blocking
status from the server socket is invalid. Or python sets the flags
to match. Either way, we need clients to use blocking sockets so
we're now explicitly setting the blocking status.
This commit is contained in:
Paul J. Davis 2010-03-16 11:44:07 -04:00
parent 61a84eece3
commit 8b9cb09b6b

View File

@ -97,12 +97,17 @@ class Worker(object):
def accept(self):
try:
client, addr = self.socket.accept()
self.init_sock(client)
self.handle(client, addr)
self.nr += 1
except socket.error, e:
if e[0] not in (errno.EAGAIN, errno.ECONNABORTED):
raise
def init_sock(self, sock):
sock.setblocking(1)
util.close_on_exec(sock)
def run(self):
self.init_process()
self.nr = 0
@ -145,7 +150,6 @@ class Worker(object):
raise
def handle(self, client, addr):
util.close_on_exec(client)
try:
req = http.Request(client, addr, self.address, self.conf)