aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/rtsp.c35
-rw-r--r--lib/rtsp.h7
-rw-r--r--lib/url.c39
3 files changed, 42 insertions, 39 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;
diff --git a/lib/rtsp.h b/lib/rtsp.h
index 82e07068d..2e2074edc 100644
--- a/lib/rtsp.h
+++ b/lib/rtsp.h
@@ -8,7 +8,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -46,6 +46,11 @@ CURLcode Curl_rtsp_connect(struct connectdata *conn, bool *done);
CURLcode Curl_rtsp_disconnect(struct connectdata *conn, bool dead_connection);
CURLcode Curl_rtsp_parseheader(struct connectdata *conn, char *header);
+bool Curl_rtsp_connisdead(struct connectdata *check);
+
+#else
+/* disabled */
+#define Curl_rtsp_connisdead(x) TRUE
#endif /* CURL_DISABLE_RTSP */
diff --git a/lib/url.c b/lib/url.c
index 47ac725f3..106d4e7ec 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -2736,41 +2736,6 @@ static bool SocketIsDead(curl_socket_t sock)
return ret_val;
}
-#ifndef CURL_DISABLE_RTSP
-/*
- * 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.
- */
-static bool RTSPConnIsDead(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;
-}
-#endif /* CURL_DISABLE_RTSP */
-
static bool IsPipeliningPossible(const struct SessionHandle *handle,
const struct connectdata *conn)
{
@@ -2931,12 +2896,10 @@ ConnectionExists(struct SessionHandle *data,
handles in pipeline and the connection isn't already marked in
use */
bool dead;
-#ifndef CURL_DISABLE_RTSP
if(check->handler->protocol & CURLPROTO_RTSP)
/* RTSP is a special case due to RTP interleaving */
- dead = RTSPConnIsDead(check);
+ dead = Curl_rtsp_connisdead(check);
else
-#endif /*CURL_DISABLE_RTSP*/
dead = SocketIsDead(check->sock[FIRSTSOCKET]);
if(dead) {