From 54ba7c42178542499920441cdcd6464edcf3203e Mon Sep 17 00:00:00 2001 From: Jean-Paul Saman Date: Mon, 10 Dec 2007 10:03:13 +0000 Subject: [PATCH] Fix hang in live555 when sending RTSP OPTIONS by letting readSocket() timeout after 5 seconds. Added reconnect case to modules/demux/live555.cpp (without backing off scenario). --- extras/contrib/src/Patches/live.patch | 23 +++++++++++++++++++++++ modules/demux/live555.cpp | 6 ++++++ 2 files changed, 29 insertions(+) diff --git a/extras/contrib/src/Patches/live.patch b/extras/contrib/src/Patches/live.patch index a53bf9dc88..208db1bc11 100644 --- a/extras/contrib/src/Patches/live.patch +++ b/extras/contrib/src/Patches/live.patch @@ -114,3 +114,26 @@ diff -ru live/groupsock/NetInterface.cpp live-patched/groupsock/NetInterface.cpp } Boolean RTSPClient::parseGetParameterHeader(char const* line, +--- live/liveMedia/RTSPClient.cpp 2007-04-28 16:02:39.000000000 +0200 ++++ live-patched/liveMedia/RTSPClient.cpp 2007-12-10 10:42:00.000000000 +0100 +@@ -2074,7 +2076,8 @@ Boolean RTSPClient::getResponse(char con + unsigned RTSPClient::getResponse1(char*& responseBuffer, + unsigned responseBufferSize) { + struct sockaddr_in fromAddress; +- ++ struct timeval timeout; ++ + if (responseBufferSize == 0) return 0; // just in case... + responseBuffer[0] = '\0'; // ditto + +@@ -2084,7 +2087,9 @@ unsigned RTSPClient::getResponse1(char*& + Boolean success = False; + while (1) { + unsigned char firstByte; +- if (readSocket(envir(), fInputSocketNum, &firstByte, 1, fromAddress) ++ timeout.tv_sec = 5; ++ timeout.tv_usec = 0; ++ if (readSocket(envir(), fInputSocketNum, &firstByte, 1, fromAddress, &timeout) + != 1) break; + if (firstByte != '$') { + // Normal case: This is the start of a regular response; use it: diff --git a/modules/demux/live555.cpp b/modules/demux/live555.cpp index 81ebcd58f3..7133bdde3a 100644 --- a/modules/demux/live555.cpp +++ b/modules/demux/live555.cpp @@ -552,6 +552,12 @@ describe: if( p_sys->rtsp ) RTSPClient::close( p_sys->rtsp ); goto createnew; } + else + { + msg_Info( p_demux, "connection timeout, retrying" ); + if( p_sys->rtsp ) RTSPClient::close( p_sys->rtsp ); + goto createnew; + } i_ret = VLC_EGENERIC; } if( psz_url ) free( psz_url ); -- 2.39.2