Browse Source

[1522] added SIGPIPE filter and re-enabled tests that failed due to the signal.

JINMEI Tatuya 13 years ago
parent
commit
d38b9068dd

+ 14 - 1
src/lib/server_common/socket_request.cc

@@ -23,6 +23,7 @@
 #include <sys/un.h>
 #include <sys/socket.h>
 #include <cerrno>
+#include <csignal>
 #include <cstddef>
 
 namespace isc {
@@ -238,7 +239,19 @@ class SocketRequestorCCSession : public SocketRequestor {
 public:
     SocketRequestorCCSession(config::ModuleCCSession& session) :
         session_(session)
-    {}
+    {
+        // We need to filter SIGPIPE to prevent it from happening in
+        // getSocketFd() while writing to the UNIX domain socket after the
+        // remote end closed it.  See lib/util/io/socketsession for more
+        // background details.
+        // Note: we should eventually unify this level of details into a single
+        // module.  Setting a single filter here should be considered a short
+        // term workaround.
+        if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
+            isc_throw(Unexpected, "Failed to filter SIGPIPE: " <<
+                      strerror(errno));
+        }
+    }
 
     ~SocketRequestorCCSession() {
         closeFdShareSockets();

+ 0 - 2
src/lib/server_common/tests/socket_requestor_test.cc

@@ -540,7 +540,6 @@ TEST_F(SocketRequestorTest, testSocketPassing) {
         ASSERT_THROW(doRequest(), SocketRequestor::SocketError);
     }
 
-#if 0
     // Vector is of first socket is now empty, so the socket should be gone
     addAnswer("foo", ts.getPath());
     ASSERT_THROW(doRequest(), SocketRequestor::SocketError);
@@ -549,7 +548,6 @@ TEST_F(SocketRequestorTest, testSocketPassing) {
     // gone
     addAnswer("foo", ts2.getPath());
     ASSERT_THROW(doRequest(), SocketRequestor::SocketError);
-#endif
 }
 
 }