diff --git a/lib/curl_rtmp.c b/lib/curl_rtmp.c index 75b80913d8..7c152e787c 100644 --- a/lib/curl_rtmp.c +++ b/lib/curl_rtmp.c @@ -240,7 +240,7 @@ static const struct Curl_protocol Curl_protocol_rtmp = { rtmp_disconnect, /* disconnect */ ZERO_NULL, /* write_resp */ ZERO_NULL, /* write_resp_hd */ - ZERO_NULL, /* connection_check */ + ZERO_NULL, /* connection_is_dead */ ZERO_NULL, /* attach connection */ ZERO_NULL, /* follow */ }; diff --git a/lib/dict.c b/lib/dict.c index fcdea918cf..f99feff45b 100644 --- a/lib/dict.c +++ b/lib/dict.c @@ -290,7 +290,7 @@ static const struct Curl_protocol Curl_protocol_dict = { ZERO_NULL, /* disconnect */ ZERO_NULL, /* write_resp */ ZERO_NULL, /* write_resp_hd */ - ZERO_NULL, /* connection_check */ + ZERO_NULL, /* connection_is_dead */ ZERO_NULL, /* attach connection */ ZERO_NULL, /* follow */ }; diff --git a/lib/file.c b/lib/file.c index 1c3f663f17..6bc3b440e0 100644 --- a/lib/file.c +++ b/lib/file.c @@ -613,7 +613,7 @@ static const struct Curl_protocol Curl_protocol_file = { file_disconnect, /* disconnect */ ZERO_NULL, /* write_resp */ ZERO_NULL, /* write_resp_hd */ - ZERO_NULL, /* connection_check */ + ZERO_NULL, /* connection_is_dead */ ZERO_NULL, /* attach connection */ ZERO_NULL, /* follow */ }; diff --git a/lib/ftp.c b/lib/ftp.c index 6047759e78..0e52a37514 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -4471,7 +4471,7 @@ static const struct Curl_protocol Curl_protocol_ftp = { ftp_disconnect, /* disconnect */ ZERO_NULL, /* write_resp */ ZERO_NULL, /* write_resp_hd */ - ZERO_NULL, /* connection_check */ + ZERO_NULL, /* connection_is_dead */ ZERO_NULL, /* attach connection */ ZERO_NULL, /* follow */ }; diff --git a/lib/gopher.c b/lib/gopher.c index 71ff39275c..b4945c0c9d 100644 --- a/lib/gopher.c +++ b/lib/gopher.c @@ -187,7 +187,7 @@ static const struct Curl_protocol Curl_protocol_gopher = { ZERO_NULL, /* disconnect */ ZERO_NULL, /* write_resp */ ZERO_NULL, /* write_resp_hd */ - ZERO_NULL, /* connection_check */ + ZERO_NULL, /* connection_is_dead */ ZERO_NULL, /* attach connection */ ZERO_NULL, /* follow */ }; @@ -208,7 +208,7 @@ static const struct Curl_protocol Curl_protocol_gophers = { ZERO_NULL, /* disconnect */ ZERO_NULL, /* write_resp */ ZERO_NULL, /* write_resp_hd */ - ZERO_NULL, /* connection_check */ + ZERO_NULL, /* connection_is_dead */ ZERO_NULL, /* attach connection */ ZERO_NULL, /* follow */ }; diff --git a/lib/http.c b/lib/http.c index 188da5fd83..fb92ef625b 100644 --- a/lib/http.c +++ b/lib/http.c @@ -4997,7 +4997,7 @@ static const struct Curl_protocol Curl_protocol_http = { ZERO_NULL, /* disconnect */ Curl_http_write_resp, /* write_resp */ Curl_http_write_resp_hd, /* write_resp_hd */ - ZERO_NULL, /* connection_check */ + ZERO_NULL, /* connection_is_dead */ ZERO_NULL, /* attach connection */ Curl_http_follow, /* follow */ }; diff --git a/lib/imap.c b/lib/imap.c index 0546595f89..a4d3138383 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -2317,7 +2317,7 @@ static const struct Curl_protocol Curl_protocol_imap = { imap_disconnect, /* disconnect */ ZERO_NULL, /* write_resp */ ZERO_NULL, /* write_resp_hd */ - ZERO_NULL, /* connection_check */ + ZERO_NULL, /* connection_is_dead */ ZERO_NULL, /* attach connection */ ZERO_NULL, /* follow */ }; diff --git a/lib/ldap.c b/lib/ldap.c index e223078b03..c43e6cd4f7 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -991,7 +991,7 @@ const struct Curl_protocol Curl_protocol_ldap = { ZERO_NULL, /* disconnect */ ZERO_NULL, /* write_resp */ ZERO_NULL, /* write_resp_hd */ - ZERO_NULL, /* connection_check */ + ZERO_NULL, /* connection_is_dead */ ZERO_NULL, /* attach connection */ ZERO_NULL, /* follow */ }; diff --git a/lib/mqtt.c b/lib/mqtt.c index e591cfcf01..0fb7bd3529 100644 --- a/lib/mqtt.c +++ b/lib/mqtt.c @@ -979,7 +979,7 @@ static const struct Curl_protocol Curl_protocol_mqtts = { ZERO_NULL, /* disconnect */ ZERO_NULL, /* write_resp */ ZERO_NULL, /* write_resp_hd */ - ZERO_NULL, /* connection_check */ + ZERO_NULL, /* connection_is_dead */ ZERO_NULL, /* attach connection */ ZERO_NULL, /* follow */ }; @@ -1004,7 +1004,7 @@ static const struct Curl_protocol Curl_protocol_mqtt = { ZERO_NULL, /* disconnect */ ZERO_NULL, /* write_resp */ ZERO_NULL, /* write_resp_hd */ - ZERO_NULL, /* connection_check */ + ZERO_NULL, /* connection_is_dead */ ZERO_NULL, /* attach connection */ ZERO_NULL, /* follow */ }; diff --git a/lib/openldap.c b/lib/openldap.c index 95f7681caa..f05a2ab05c 100644 --- a/lib/openldap.c +++ b/lib/openldap.c @@ -1276,7 +1276,7 @@ const struct Curl_protocol Curl_protocol_ldap = { oldap_disconnect, /* disconnect */ ZERO_NULL, /* write_resp */ ZERO_NULL, /* write_resp_hd */ - ZERO_NULL, /* connection_check */ + ZERO_NULL, /* connection_is_dead */ ZERO_NULL, /* attach connection */ ZERO_NULL, /* follow */ }; diff --git a/lib/pop3.c b/lib/pop3.c index de704d11e1..6a9856b8c4 100644 --- a/lib/pop3.c +++ b/lib/pop3.c @@ -1707,7 +1707,7 @@ static const struct Curl_protocol Curl_protocol_pop3 = { pop3_disconnect, /* disconnect */ pop3_write, /* write_resp */ ZERO_NULL, /* write_resp_hd */ - ZERO_NULL, /* connection_check */ + ZERO_NULL, /* connection_is_dead */ ZERO_NULL, /* attach connection */ ZERO_NULL, /* follow */ }; diff --git a/lib/rtsp.c b/lib/rtsp.c index 11848c8282..3de6188ae9 100644 --- a/lib/rtsp.c +++ b/lib/rtsp.c @@ -126,19 +126,13 @@ static CURLcode rtsp_setup_connection(struct Curl_easy *data, /* * Function to check on various aspects of a connection. */ -static uint32_t rtsp_conncheck(struct Curl_easy *data, - struct connectdata *conn, - uint32_t checks_to_perform) +static bool rtsp_conn_is_dead(struct Curl_easy *data, + struct connectdata *conn) { - unsigned int ret_val = CONNRESULT_NONE; - - if(checks_to_perform & CONNCHECK_ISDEAD) { - bool input_pending; - if(!Curl_conn_is_alive(data, conn, &input_pending)) - ret_val |= CONNRESULT_DEAD; - } - - return ret_val; + bool input_pending; + /* Contrary to default handling, this protocol allows pending + * input on an unused connection. */ + return !Curl_conn_is_alive(data, conn, &input_pending); } static CURLcode rtsp_connect(struct Curl_easy *data, bool *done) @@ -1072,7 +1066,7 @@ static const struct Curl_protocol Curl_protocol_rtsp = { ZERO_NULL, /* disconnect */ rtsp_rtp_write_resp, /* write_resp */ rtsp_rtp_write_resp_hd, /* write_resp_hd */ - rtsp_conncheck, /* connection_check */ + rtsp_conn_is_dead, /* connection_is_dead */ ZERO_NULL, /* attach connection */ Curl_http_follow, /* follow */ }; diff --git a/lib/smb.c b/lib/smb.c index 00297adee7..439d035527 100644 --- a/lib/smb.c +++ b/lib/smb.c @@ -1223,7 +1223,7 @@ static const struct Curl_protocol Curl_protocol_smb = { ZERO_NULL, /* disconnect */ ZERO_NULL, /* write_resp */ ZERO_NULL, /* write_resp_hd */ - ZERO_NULL, /* connection_check */ + ZERO_NULL, /* connection_is_dead */ ZERO_NULL, /* attach connection */ ZERO_NULL, /* follow */ }; diff --git a/lib/smtp.c b/lib/smtp.c index 60889858d3..e5b26b51c2 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -1999,7 +1999,7 @@ static const struct Curl_protocol Curl_protocol_smtp = { smtp_disconnect, /* disconnect */ ZERO_NULL, /* write_resp */ ZERO_NULL, /* write_resp_hd */ - ZERO_NULL, /* connection_check */ + ZERO_NULL, /* connection_is_dead */ ZERO_NULL, /* attach connection */ ZERO_NULL, /* follow */ }; diff --git a/lib/telnet.c b/lib/telnet.c index 5bae99e1fc..0cac1f2af1 100644 --- a/lib/telnet.c +++ b/lib/telnet.c @@ -1584,7 +1584,7 @@ static const struct Curl_protocol Curl_protocol_telnet = { ZERO_NULL, /* disconnect */ ZERO_NULL, /* write_resp */ ZERO_NULL, /* write_resp_hd */ - ZERO_NULL, /* connection_check */ + ZERO_NULL, /* connection_is_dead */ ZERO_NULL, /* attach connection */ ZERO_NULL, /* follow */ }; diff --git a/lib/tftp.c b/lib/tftp.c index cc0769bbb3..12fca443ed 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -1347,7 +1347,7 @@ static const struct Curl_protocol Curl_protocol_tftp = { ZERO_NULL, /* disconnect */ ZERO_NULL, /* write_resp */ ZERO_NULL, /* write_resp_hd */ - ZERO_NULL, /* connection_check */ + ZERO_NULL, /* connection_is_dead */ ZERO_NULL, /* attach connection */ ZERO_NULL, /* follow */ }; diff --git a/lib/url.c b/lib/url.c index ec0457bcdd..c133e8ba96 100644 --- a/lib/url.c +++ b/lib/url.c @@ -650,19 +650,12 @@ bool Curl_conn_seems_dead(struct connectdata *conn, /* avoid check if already too old */ dead = TRUE; } - else if(conn->scheme->run->connection_check) { + else if(conn->scheme->run->connection_is_dead) { /* 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; - - /* briefly attach the connection to this transfer for the purpose of - checking it */ + /* briefly attach the connection for the check */ Curl_attach_connection(data, conn); - - state = conn->scheme->run->connection_check(data, conn, - CONNCHECK_ISDEAD); - dead = (state & CONNRESULT_DEAD); - /* detach the connection again */ + dead = conn->scheme->run->connection_is_dead(data, conn); Curl_detach_connection(data); } else { @@ -705,18 +698,7 @@ CURLcode Curl_conn_upkeep(struct Curl_easy *data, /* briefly attach for action */ Curl_attach_connection(data, conn); - if(conn->scheme->run->connection_check) { - /* Do a protocol-specific keepalive check on the connection. */ - unsigned int rc; - rc = conn->scheme->run->connection_check(data, conn, - CONNCHECK_KEEPALIVE); - if(rc & CONNRESULT_DEAD) - result = CURLE_RECV_ERROR; - } - else { - /* Do the generic action on the FIRSTSOCKET filter chain */ - result = Curl_conn_keep_alive(data, conn, FIRSTSOCKET); - } + result = Curl_conn_keep_alive(data, conn, FIRSTSOCKET); Curl_detach_connection(data); conn->keepalive = *Curl_pgrs_now(data); diff --git a/lib/urldata.h b/lib/urldata.h index 5ae148054b..d854b49576 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -492,12 +492,10 @@ struct Curl_protocol { CURLcode (*write_resp_hd)(struct Curl_easy *data, const char *hd, size_t hdlen, bool is_eos); - /* This function can perform various checks on the connection. See - CONNCHECK_* for more information about the checks that can be performed, - and CONNRESULT_* for the results that can be returned. */ - uint32_t (*connection_check)(struct Curl_easy *data, - struct connectdata *conn, - uint32_t checks_to_perform); + /* If used, this function checks for a connection managed by this + protocol and currently not in use, if it should be considered dead. */ + bool (*connection_is_dead)(struct Curl_easy *data, + struct connectdata *conn); /* attach() attaches this transfer to this connection */ void (*attach)(struct Curl_easy *data, struct connectdata *conn); @@ -554,13 +552,6 @@ struct Curl_scheme { without having PROTOPT_SSL. */ #define PROTOPT_CONN_REUSE (1 << 16) /* this protocol can reuse connections */ -#define CONNCHECK_NONE 0 /* No checks */ -#define CONNCHECK_ISDEAD (1 << 0) /* Check if the connection is dead. */ -#define CONNCHECK_KEEPALIVE (1 << 1) /* Perform any keepalive function. */ - -#define CONNRESULT_NONE 0 /* No extra information. */ -#define CONNRESULT_DEAD (1 << 0) /* The connection is dead. */ - #define TRNSPRT_NONE 0 #define TRNSPRT_TCP 3 #define TRNSPRT_UDP 4 diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c index 31b1744618..398db58698 100644 --- a/lib/vssh/libssh.c +++ b/lib/vssh/libssh.c @@ -2985,7 +2985,7 @@ const struct Curl_protocol Curl_protocol_scp = { scp_disconnect, /* disconnect */ ZERO_NULL, /* write_resp */ ZERO_NULL, /* write_resp_hd */ - ZERO_NULL, /* connection_check */ + ZERO_NULL, /* connection_is_dead */ ZERO_NULL, /* attach connection */ ZERO_NULL, /* follow */ }; @@ -3008,7 +3008,7 @@ const struct Curl_protocol Curl_protocol_sftp = { sftp_disconnect, /* disconnect */ ZERO_NULL, /* write_resp */ ZERO_NULL, /* write_resp_hd */ - ZERO_NULL, /* connection_check */ + ZERO_NULL, /* connection_is_dead */ ZERO_NULL, /* attach connection */ ZERO_NULL, /* follow */ }; diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c index b55539efbe..bd1f9681bd 100644 --- a/lib/vssh/libssh2.c +++ b/lib/vssh/libssh2.c @@ -3835,7 +3835,7 @@ const struct Curl_protocol Curl_protocol_scp = { scp_disconnect, /* disconnect */ ZERO_NULL, /* write_resp */ ZERO_NULL, /* write_resp_hd */ - ZERO_NULL, /* connection_check */ + ZERO_NULL, /* connection_is_dead */ ssh_attach, /* attach */ ZERO_NULL, /* follow */ }; @@ -3858,7 +3858,7 @@ const struct Curl_protocol Curl_protocol_sftp = { sftp_disconnect, /* disconnect */ ZERO_NULL, /* write_resp */ ZERO_NULL, /* write_resp_hd */ - ZERO_NULL, /* connection_check */ + ZERO_NULL, /* connection_is_dead */ ssh_attach, /* attach */ ZERO_NULL, /* follow */ }; diff --git a/lib/ws.c b/lib/ws.c index 60465611bb..df0e60ce8b 100644 --- a/lib/ws.c +++ b/lib/ws.c @@ -1930,7 +1930,7 @@ static const struct Curl_protocol Curl_protocol_ws = { ZERO_NULL, /* disconnect */ Curl_http_write_resp, /* write_resp */ Curl_http_write_resp_hd, /* write_resp_hd */ - ZERO_NULL, /* connection_check */ + ZERO_NULL, /* connection_is_dead */ ZERO_NULL, /* attach connection */ Curl_http_follow, /* follow */ };