From: JINMEI Tatuya Date: Fri, 30 Dec 2011 06:25:11 +0000 (-0800) Subject: [1522] added SIGPIPE filter and re-enabled tests that failed due to the signal. X-Git-Tag: trac2351_base~304^2~15^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d38b9068dde3191aef574fdda44f381f528b8146;p=thirdparty%2Fkea.git [1522] added SIGPIPE filter and re-enabled tests that failed due to the signal. --- diff --git a/src/lib/server_common/socket_request.cc b/src/lib/server_common/socket_request.cc index 36b4d81e84..8f85334aec 100644 --- a/src/lib/server_common/socket_request.cc +++ b/src/lib/server_common/socket_request.cc @@ -23,6 +23,7 @@ #include #include #include +#include #include 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(); diff --git a/src/lib/server_common/tests/socket_requestor_test.cc b/src/lib/server_common/tests/socket_requestor_test.cc index ecbb57fd92..a32a53de05 100644 --- a/src/lib/server_common/tests/socket_requestor_test.cc +++ b/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 } }