Be more robust in case of clients doing broken things
When sending responses to API calls, catch the case where a client
isn't listening or doesn't accept the answer properly. Log it and move
on, don't hang.
Change-Id: I003d7a32ab0bdd6e37b44cc72cdbf8be43bf64b6
diff --git a/ipc/ipc.py b/ipc/ipc.py
index a7c6c49..8df1219 100644
--- a/ipc/ipc.py
+++ b/ipc/ipc.py
@@ -92,10 +92,15 @@
self.conn = None
raise SocketError("Server unable to format reply data")
- # send the actual number of bytes to read.
- self.conn.send(data[0])
- # now send the bytes.
- self.conn.send(data[1])
+ try:
+ # send the actual number of bytes to read.
+ self.conn.send(data[0])
+ # now send the bytes.
+ self.conn.send(data[1])
+ except socket.error as e:
+ logging.error("Can't send response to client: %s", e)
+ logging.error("Was trying to send data:")
+ logging.error(data)
def server_close(self):
if self.conn is not None: