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