Commit c31dc434 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Bug fix: ServerSocket was not set in non-blocking mode, causing the master wait

on the recv() until a ping was sent to it. Now the non-bloking state is defined
in the Connector __init__ to ensure all sockets will not block.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1118 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 92f2ab72
...@@ -53,13 +53,14 @@ class SocketConnector: ...@@ -53,13 +53,14 @@ class SocketConnector:
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
else: else:
self.socket = s self.socket = s
# always use non-blocking sockets
self.socket.setblocking(0)
def makeClientConnection(self, addr): def makeClientConnection(self, addr):
self.is_closed = False self.is_closed = False
self.remote_addr = addr self.remote_addr = addr
try: try:
try: try:
self.socket.setblocking(0)
self.socket.connect(addr) self.socket.connect(addr)
except socket.error, (err, errmsg): except socket.error, (err, errmsg):
if err == errno.EINPROGRESS: if err == errno.EINPROGRESS:
...@@ -76,7 +77,6 @@ class SocketConnector: ...@@ -76,7 +77,6 @@ class SocketConnector:
self.is_closed = False self.is_closed = False
self.is_listening = True self.is_listening = True
try: try:
self.socket.setblocking(0)
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.socket.bind(addr) self.socket.bind(addr)
self.socket.listen(5) self.socket.listen(5)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment