summaryrefslogtreecommitdiff
path: root/lib/rtsp.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2011-03-23 17:27:58 +0100
committerDaniel Stenberg <daniel@haxx.se>2011-03-23 17:27:58 +0100
commitcc9e4321d38f26fec59789a7b3a3bf6a0bf27ce4 (patch)
treedb6c731511c58f524ef569bca41c2d4c638e8116 /lib/rtsp.c
parent970587567ec809f47b7c51ff015a4277eb75813a (diff)
downloadcurl-cc9e4321d38f26fec59789a7b3a3bf6a0bf27ce4.tar.gz
rtsp: move protocol code to dedicated file
The RTSP-specific function for checking for "dead" connection is better located in rtsp.c. The code using this is now written without #ifdefs as the function call is instead turned into a macro (in rtsp.h) when RTSP is disabled.
Diffstat (limited to 'lib/rtsp.c')
-rw-r--r--lib/rtsp.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/rtsp.c b/lib/rtsp.c
index c39ae011e..52cf5efc7 100644
--- a/lib/rtsp.c
+++ b/lib/rtsp.c
@@ -36,6 +36,8 @@
#include "rtsp.h"
#include "rawstr.h"
#include "curl_memory.h"
+#include "select.h"
+#include "connect.h"
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
@@ -100,6 +102,39 @@ const struct Curl_handler Curl_handler_rtsp = {
PROTOPT_NONE /* flags */
};
+/*
+ * The server may send us RTP data at any point, and RTSPREQ_RECEIVE does not
+ * want to block the application forever while receiving a stream. Therefore,
+ * we cannot assume that an RTSP socket is dead just because it is readable.
+ *
+ * Instead, if it is readable, run Curl_getconnectinfo() to peek at the socket
+ * and distinguish between closed and data.
+ */
+bool Curl_rtsp_connisdead(struct connectdata *check)
+{
+ int sval;
+ bool ret_val = TRUE;
+
+ sval = Curl_socket_ready(check->sock[FIRSTSOCKET], CURL_SOCKET_BAD, 0);
+ if(sval == 0) {
+ /* timeout */
+ ret_val = FALSE;
+ }
+ else if (sval & CURL_CSELECT_ERR) {
+ /* socket is in an error state */
+ ret_val = TRUE;
+ }
+ else if (sval & CURL_CSELECT_IN) {
+ /* readable with no error. could be closed or could be alive */
+ curl_socket_t connectinfo =
+ Curl_getconnectinfo(check->data, &check);
+ if(connectinfo != CURL_SOCKET_BAD)
+ ret_val = FALSE;
+ }
+
+ return ret_val;
+}
+
CURLcode Curl_rtsp_connect(struct connectdata *conn, bool *done)
{
CURLcode httpStatus;