Commit 6096ee13 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Fix problem with EAGAIN on socket connection in clients



If a user used ^Z to stop the program, poll() in socket.recv would return
EAGAIN due to SIGSTOP. This patch changes luxi.Transport.Recv to ignore EAGAIN.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 5bbd3f7f
......@@ -195,6 +195,7 @@ class ClientRqHandler(SocketServer.BaseRequestHandler):
def send_message(self, msg):
#print "sending", msg
# TODO: sendall is not guaranteed to send everything
self.request.sendall(msg + self.EOM)
......
......@@ -186,6 +186,7 @@ class Transport:
raise EncodingError("Message terminator found in payload")
self._CheckSocket()
try:
# TODO: sendall is not guaranteed to send everything
self.socket.sendall(msg + self.eom)
except socket.timeout, err:
raise TimeoutError("Sending timeout: %s" % str(err))
......@@ -204,10 +205,16 @@ class Transport:
while not self._msgs:
if time.time() > etime:
raise TimeoutError("Extended receive timeout")
try:
data = self.socket.recv(4096)
except socket.timeout, err:
raise TimeoutError("Receive timeout: %s" % str(err))
while True:
try:
data = self.socket.recv(4096)
except socket.error, err:
if err.args and err.args[0] == errno.EAGAIN:
continue
raise
except socket.timeout, err:
raise TimeoutError("Receive timeout: %s" % str(err))
break
if not data:
raise ConnectionClosedError("Connection closed while reading")
new_msgs = (self._buffer + data).split(self.eom)
......
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