Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -aurNp '--exclude=bin' curl-7.58.0-orig/include/curl/curl.h curl-7.58.0/include/curl/curl.h
- --- curl-7.58.0-orig/include/curl/curl.h 2018-01-22 09:55:10.000000000 +0100
- +++ curl-7.58.0/include/curl/curl.h 2018-02-17 12:20:09.515491604 +0100
- @@ -1819,6 +1819,9 @@ typedef enum {
- /* Post MIME data. */
- CINIT(MIMEPOST, OBJECTPOINT, 269),
- + /* time between sending HTTP/2 PING request */
- + CINIT(CONNUP_KEEPINTVL, LONG, 270),
- +
- CURLOPT_LASTENTRY /* the last unused */
- } CURLoption;
- diff -aurNp '--exclude=bin' curl-7.58.0-orig/include/curl/easy.h curl-7.58.0/include/curl/easy.h
- --- curl-7.58.0-orig/include/curl/easy.h 2017-12-03 00:33:20.000000000 +0100
- +++ curl-7.58.0/include/curl/easy.h 2018-02-17 09:50:20.061622205 +0100
- @@ -29,6 +29,7 @@ CURL_EXTERN CURL *curl_easy_init(void);
- CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...);
- CURL_EXTERN CURLcode curl_easy_perform(CURL *curl);
- CURL_EXTERN void curl_easy_cleanup(CURL *curl);
- +CURL_EXTERN CURLcode curl_easy_conn_upkeep(CURL *curl);
- /*
- * NAME curl_easy_getinfo()
- diff -aurNp '--exclude=bin' curl-7.58.0-orig/include/curl/multi.h curl-7.58.0/include/curl/multi.h
- --- curl-7.58.0-orig/include/curl/multi.h 2017-12-03 00:33:21.000000000 +0100
- +++ curl-7.58.0/include/curl/multi.h 2018-02-17 11:39:12.872394487 +0100
- @@ -132,6 +132,15 @@ CURL_EXTERN CURLM *curl_multi_init(void)
- CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle,
- CURL *curl_handle);
- +/*
- + * Name: curl_multi_conn_upkeep()
- + *
- + * Desc: keep all connections alive
- + *
- + * Returns: CURLMcode type, general multi error code.
- + */
- +CURL_EXTERN CURLMcode curl_multi_conn_upkeep(CURLM *multi_handle);
- +
- /*
- * Name: curl_multi_remove_handle()
- *
- diff -aurNp '--exclude=bin' curl-7.58.0-orig/lib/easy.c curl-7.58.0/lib/easy.c
- --- curl-7.58.0-orig/lib/easy.c 2018-01-22 09:55:10.000000000 +0100
- +++ curl-7.58.0/lib/easy.c 2018-02-17 11:31:11.481827134 +0100
- @@ -1177,3 +1177,22 @@ CURLcode curl_easy_send(struct Curl_easy
- return result;
- }
- +
- +/*
- + * Performs connections keep functions.
- + */
- +CURLcode curl_easy_conn_upkeep(struct Curl_easy *data)
- +{
- + /* Verify that we got a somewhat good easy handle too */
- + if(!GOOD_EASY_HANDLE(data))
- + return CURLM_BAD_EASY_HANDLE;
- +
- + if(data->multi_easy) {
- + /* Use the common function to keep connections alive. */
- + return Curl_conn_upkeep(&data->multi_easy->conn_cache, data);
- + }
- + else {
- + /* No connections, so just return success */
- + return CURLE_OK;
- + }
- +}
- diff -aurNp '--exclude=bin' curl-7.58.0-orig/lib/http2.c curl-7.58.0/lib/http2.c
- --- curl-7.58.0-orig/lib/http2.c 2018-01-22 09:55:10.000000000 +0100
- +++ curl-7.58.0/lib/http2.c 2018-02-17 11:54:57.144345445 +0100
- @@ -180,17 +180,48 @@ static bool http2_connisdead(struct conn
- return ret_val;
- }
- -
- static unsigned int http2_conncheck(struct connectdata *check,
- unsigned int checks_to_perform)
- {
- unsigned int ret_val = CONNRESULT_NONE;
- + struct http_conn *c = &check->proto.httpc;
- + int rc;
- + bool send_frames = false;
- if(checks_to_perform & CONNCHECK_ISDEAD) {
- if(http2_connisdead(check))
- ret_val |= CONNRESULT_DEAD;
- }
- + if(checks_to_perform & CONNCHECK_KEEPALIVE) {
- + struct curltime now = Curl_now();
- + time_t elapsed = Curl_timediff(now, check->keepalive);
- +#if 0
- + infof(check->data, "elapsed conn_up_keepintvl %6d %d\n",
- + elapsed, check->conn_up_keepintvl);
- +#endif
- + if(elapsed > check->conn_up_keepintvl) {
- + /* Perform an HTTP/2 PING */
- + rc = nghttp2_submit_ping(c->h2, 0, ZERO_NULL);
- + if(!rc) {
- + /* Successfully added a PING frame to the session. Need to flag this
- + so the frame is sent. */
- + send_frames = true;
- + } else
- + failf(check->data, "nghttp2_submit_ping() failed: %s(%d)",
- + nghttp2_strerror(rc), rc);
- +
- + check->keepalive = now;
- + }
- + }
- +
- + if(send_frames) {
- + rc = nghttp2_session_send(c->h2);
- + if(rc)
- + failf(check->data, "nghttp2_session_send() failed: %s(%d)",
- + nghttp2_strerror(rc), rc);
- + }
- +
- return ret_val;
- }
- diff -aurNp '--exclude=bin' curl-7.58.0-orig/lib/multi.c curl-7.58.0/lib/multi.c
- --- curl-7.58.0-orig/lib/multi.c 2018-01-22 09:55:10.000000000 +0100
- +++ curl-7.58.0/lib/multi.c 2018-02-17 11:39:51.456579807 +0100
- @@ -620,6 +620,16 @@ static CURLcode multi_done(struct connec
- return result;
- }
- +CURLMcode curl_multi_conn_upkeep(struct Curl_multi *multi)
- +{
- + /* First, make some basic checks that the CURLM handle is a good handle */
- + if(!GOOD_MULTI_HANDLE(multi))
- + return CURLM_BAD_HANDLE;
- +
- + /* Use the common function to keep connections alive. */
- + return Curl_conn_upkeep(&multi->conn_cache, multi);
- +}
- +
- CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
- struct Curl_easy *data)
- {
- diff -aurNp '--exclude=bin' curl-7.58.0-orig/lib/setopt.c curl-7.58.0/lib/setopt.c
- --- curl-7.58.0-orig/lib/setopt.c 2018-01-22 10:02:06.000000000 +0100
- +++ curl-7.58.0/lib/setopt.c 2018-02-17 12:20:06.072088428 +0100
- @@ -2524,6 +2524,9 @@ CURLcode Curl_vsetopt(struct Curl_easy *
- case CURLOPT_SSH_COMPRESSION:
- data->set.ssh_compression = (0 != va_arg(param, long))?TRUE:FALSE;
- break;
- + case CURLOPT_CONNUP_KEEPINTVL:
- + data->set.conn_up_keepintvl = va_arg(param, long) * 1000;
- + break;
- default:
- /* unknown tag and its companion, just ignore: */
- result = CURLE_UNKNOWN_OPTION;
- diff -aurNp '--exclude=bin' curl-7.58.0-orig/lib/url.c curl-7.58.0/lib/url.c
- --- curl-7.58.0-orig/lib/url.c 2018-01-23 08:55:37.000000000 +0100
- +++ curl-7.58.0/lib/url.c 2018-02-17 11:54:49.856754734 +0100
- @@ -528,6 +528,8 @@ CURLcode Curl_init_userdefined(struct Cu
- set->sep_headers = TRUE; /* separated header lists by default */
- set->buffer_size = READBUFFER_SIZE;
- + set->conn_up_keepintvl = 60000L; /* default time is 60 seconds */
- +
- Curl_http2_init_userset(set);
- return result;
- }
- @@ -1829,6 +1831,9 @@ static struct connectdata *allocate_conn
- /* Store creation time to help future close decision making */
- conn->created = Curl_now();
- + /* Store current time to give a baseline to keepalive connection times. */
- + conn->keepalive = Curl_now();
- +
- conn->data = data; /* Setup the association between this connection
- and the Curl_easy */
- @@ -1920,6 +1925,8 @@ static struct connectdata *allocate_conn
- conn->fclosesocket = data->set.fclosesocket;
- conn->closesocket_client = data->set.closesocket_client;
- + conn->conn_up_keepintvl = data->set.conn_up_keepintvl;
- +
- return conn;
- error:
- @@ -4848,3 +4855,30 @@ static unsigned int get_protocol_family(
- return family;
- }
- +
- +/*
- + * Wrapper to call functions in Curl_conncache_foreach()
- + *
- + * Returns always 0.
- + */
- +static int conn_upkeep(struct connectdata *conn,
- + void *param)
- +{
- + if(conn->handler->connection_check) {
- + /* Do a protocol-specific keepalive check on the connection. */
- + conn->handler->connection_check(conn, CONNCHECK_KEEPALIVE);
- + }
- +
- + return 0; /* continue iteration */
- +}
- +
- +CURLcode Curl_conn_upkeep(struct conncache *conn_cache,
- + void *data)
- +{
- + /* Loop over every connection and make connection alive. */
- + Curl_conncache_foreach(data,
- + conn_cache,
- + data,
- + conn_upkeep);
- + return CURLE_OK;
- +}
- \ No newline at end of file
- diff -aurNp '--exclude=bin' curl-7.58.0-orig/lib/url.h curl-7.58.0/lib/url.h
- --- curl-7.58.0-orig/lib/url.h 2018-01-22 09:55:10.000000000 +0100
- +++ curl-7.58.0/lib/url.h 2018-02-17 09:50:07.192735072 +0100
- @@ -92,4 +92,7 @@ void Curl_verboseconnect(struct connectd
- (conn->http_proxy.proxytype == CURLPROXY_HTTPS &&\
- !conn->bits.proxy_ssl_connected[SECONDARYSOCKET])
- +CURLcode Curl_conn_upkeep(struct conncache *conn_cache,
- + void *data);
- +
- #endif /* HEADER_CURL_URL_H */
- diff -aurNp '--exclude=bin' curl-7.58.0-orig/lib/urldata.h curl-7.58.0/lib/urldata.h
- --- curl-7.58.0-orig/lib/urldata.h 2018-01-22 10:02:06.000000000 +0100
- +++ curl-7.58.0/lib/urldata.h 2018-02-17 11:54:39.698909137 +0100
- @@ -699,6 +699,7 @@ struct Curl_handler {
- #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. */
- @@ -888,6 +889,11 @@ struct connectdata {
- long ip_version; /* copied from the Curl_easy at creation time */
- + /* Protocols can use a custom keepalive mechanism to keep connections alive.
- + This allows those protocols to track the last time the keepalive mechanism
- + was used on this connection. */
- + struct curltime keepalive;
- +
- /**** curl_get() phase fields */
- curl_socket_t sockfd; /* socket to read from or CURL_SOCKET_BAD */
- @@ -1012,6 +1018,8 @@ struct connectdata {
- char *unix_domain_socket;
- bool abstract_unix_socket;
- #endif
- +
- + time_t conn_up_keepintvl; /* time between sending HTTP/2 PING request */
- };
- /* The end of connectdata. */
- @@ -1682,6 +1690,8 @@ struct UserDefined {
- struct Curl_http2_dep *stream_dependents;
- bool abstract_unix_socket;
- +
- + time_t conn_up_keepintvl; /* time between sending HTTP/2 PING request */
- };
- struct Names {
RAW Paste Data