summaryrefslogtreecommitdiff
path: root/lib/url.c
diff options
context:
space:
mode:
authorMax Dymond <max.dymond@metaswitch.com>2017-05-31 12:09:56 +0100
committerDaniel Stenberg <daniel@haxx.se>2017-06-30 10:17:27 +0200
commitc75f63d7c432ab42614c05f8a8081edf4beb9ee9 (patch)
treecebc51907096057746d240271c01b105f269a05d /lib/url.c
parent192877058e3c50181f3cdc349c17c13b6f9465b9 (diff)
downloadcurl-c75f63d7c432ab42614c05f8a8081edf4beb9ee9.tar.gz
handler: refactor connection checking
Add a new type of callback to Curl_handler which performs checks on the connection. Alter RTSP so that it uses this callback to do its own check on connection health.
Diffstat (limited to 'lib/url.c')
-rw-r--r--lib/url.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/url.c b/lib/url.c
index 07bdea129..e4aa515be 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -274,6 +274,7 @@ static const struct Curl_handler Curl_handler_dummy = {
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
0, /* defport */
0, /* protocol */
PROTOPT_NONE /* flags */
@@ -3379,11 +3380,19 @@ static bool disconnect_if_dead(struct connectdata *conn,
handles in pipeline and the connection isn't already marked in
use */
bool dead;
- if(conn->handler->protocol & CURLPROTO_RTSP)
- /* RTSP is a special case due to RTP interleaving */
- dead = Curl_rtsp_connisdead(conn);
- else
+
+ if(conn->handler->connection_check) {
+ /* The protocol has a special method for checking the state of the
+ connection. Use it to check if the connection is dead. */
+ unsigned int state;
+
+ state = conn->handler->connection_check(conn, CONNCHECK_ISDEAD);
+ dead = (state & CONNRESULT_DEAD);
+ }
+ else {
+ /* Use the general method for determining the death of a connection */
dead = SocketIsDead(conn->sock[FIRSTSOCKET]);
+ }
if(dead) {
conn->data = data;