[Live-devel] Ignoring SIGPIPE in RTSPClient

Barry Stump bstump at codemass.com
Sun Jun 24 15:40:20 PDT 2012


I have a similar issue to that reported by Philippe Clavel in April where
RTSPClient receives a SIGPIPE from closed socket and terminates the
process.  In my case, I am not using the RTSPServer class, so the fix
implemented in that class does not help me.  Instead, I have adapted that
fix for the RTSPClient class and have included the patch below for
inclusion in an upcoming version of Live555, pending your approval.



--- a/src/live555/liveMedia/RTSPClient.cpp
+++ b/src/live555/liveMedia/RTSPClient.cpp
@@ -374,6 +374,17 @@ int RTSPClient::openConnection() {
     // We don't yet have a TCP socket (or we used to have one, but it got
closed).  Set it up now.
     fInputSocketNum = fOutputSocketNum = setupStreamSocket(envir(), 0);
     if (fInputSocketNum < 0) break;
+
+#ifdef USE_SIGNALS
+    // ignore SIGPIPE so that prematurely closed sockets won't kill our
process
+#ifdef SO_NOSIGPIPE
+    int set_option = 1;
+    setsockopt(fInputSocketNum, SOL_SOCKET, SO_NOSIGPIPE, &set_option,
sizeof set_option);
+    setsockopt(fOutputSocketNum, SOL_SOCKET, SO_NOSIGPIPE, &set_option,
sizeof set_option);
+#else
+    signal(SIGPIPE, SIG_IGN);
+#endif
+#endif

     // Connect to the remote endpoint:
     fServerAddress = *(netAddressBits*)(destAddress.data());


-Barry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20120624/e0049e60/attachment.html>


More information about the live-devel mailing list