diff options
author | Max Dymond <max.dymond@metaswitch.com> | 2017-05-31 12:09:56 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2017-06-30 10:17:27 +0200 |
commit | c75f63d7c432ab42614c05f8a8081edf4beb9ee9 (patch) | |
tree | cebc51907096057746d240271c01b105f269a05d /lib/url.c | |
parent | 192877058e3c50181f3cdc349c17c13b6f9465b9 (diff) | |
download | curl-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.c | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -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; |