diff options
author | Daniel Stenberg <daniel@haxx.se> | 2019-04-14 23:20:01 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2019-04-21 23:06:23 +0200 |
commit | e649432e7234dfe6905f4663bd0ce7b37ef2c5e7 (patch) | |
tree | ec343333607d509a68fa8ad74cdb9833c1f380ba /lib/conncache.c | |
parent | 060f870b85a6ee85668caeb791935fe98f4da56d (diff) | |
download | curl-e649432e7234dfe6905f4663bd0ce7b37ef2c5e7.tar.gz |
CURLOPT_MAXAGE_CONN: set the maximum allowed age for conn reuse
... and disconnect too old ones instead of trying to reuse.
Default max age is set to 118 seconds.
Ref: #3722
Closes #3782
Diffstat (limited to 'lib/conncache.c')
-rw-r--r-- | lib/conncache.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/conncache.c b/lib/conncache.c index 39302ba7b..535091996 100644 --- a/lib/conncache.c +++ b/lib/conncache.c @@ -434,6 +434,7 @@ bool Curl_conncache_return_conn(struct connectdata *conn) struct connectdata *conn_candidate = NULL; conn->data = NULL; /* no owner anymore */ + conn->lastused = Curl_now(); /* it was used up until now */ if(maxconnects > 0 && Curl_conncache_size(data) > maxconnects) { infof(data, "Connection cache is full, closing the oldest one.\n"); @@ -479,7 +480,7 @@ Curl_conncache_extract_bundle(struct Curl_easy *data, if(!CONN_INUSE(conn) && !conn->data) { /* Set higher score for the age passed since the connection was used */ - score = Curl_timediff(now, conn->now); + score = Curl_timediff(now, conn->lastused); if(score > highscore) { highscore = score; @@ -537,7 +538,7 @@ Curl_conncache_extract_oldest(struct Curl_easy *data) if(!CONN_INUSE(conn) && !conn->data) { /* Set higher score for the age passed since the connection was used */ - score = Curl_timediff(now, conn->now); + score = Curl_timediff(now, conn->lastused); if(score > highscore) { highscore = score; |