Browse Source

[2398] Catch EPIPE in msgq

And kill the socket if this is caught. This is similar to the other case where __send_data is called.
Jelte Jansen 12 years ago
parent
commit
8018033c5e
1 changed files with 12 additions and 1 deletions
  1. 12 1
      src/bin/msgq/msgq.py.in

+ 12 - 1
src/bin/msgq/msgq.py.in

@@ -393,7 +393,18 @@ class MsgQ:
         # Try to send some data from the buffer
         (_, msg) = self.sendbuffs[fileno]
         sock = self.sockets[fileno]
-        amount_sent = self.__send_data(sock, msg)
+        try:
+            amount_sent = self.__send_data(sock, msg)
+        except socket.error as sockerr:
+            # in the case the other side seems gone, kill the socket
+            # and drop the send action
+            if sockerr.errno == errno.EPIPE:
+                print("[b10-msgq] SIGPIPE on send, dropping message " +
+                      "and closing connection")
+                self.kill_socket(fileno, sock)
+                return
+            else:
+                raise
         # Keep the rest
         msg = msg[amount_sent:]
         if len(msg) == 0: