diff options
author | Anders Bakken <agbakken@gmail.com> | 2015-12-21 10:13:15 -0800 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2015-12-23 10:20:37 +0100 |
commit | a464f33843ee11b0bf8cfcfd927b9a3c37b2aed0 (patch) | |
tree | 3cf67f11bfb9e7806e6925167123c70272f8e6c5 /lib | |
parent | 04cb90948e3aefc9076d4767d8fe1f262d0d5bb7 (diff) |
ConnectionExists: with *PIPEWAIT, wait for connections
Try harder to prevent libcurl from opening up an additional socket when
CURLOPT_PIPEWAIT is set. Accomplished by letting ongoing TCP and TLS
handshakes complete first before the decision is made.
Closes #575
Diffstat (limited to 'lib')
-rw-r--r-- | lib/url.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -3140,6 +3140,7 @@ ConnectionExists(struct SessionHandle *data, { struct connectdata *check; struct connectdata *chosen = 0; + bool foundPendingCandidate = FALSE; bool canPipeline = IsPipeliningPossible(data, needle); #ifdef USE_NTLM bool wantNTLMhttp = ((data->state.authhost.want & CURLAUTH_NTLM) || @@ -3239,6 +3240,8 @@ ConnectionExists(struct SessionHandle *data, if((check->sock[FIRSTSOCKET] == CURL_SOCKET_BAD) || check->bits.close) { + if(!check->bits.close) + foundPendingCandidate = TRUE; /* Don't pick a connection that hasn't connected yet or that is going to get closed. */ infof(data, "Connection #%ld isn't open enough, can't reuse\n", @@ -3339,6 +3342,7 @@ ConnectionExists(struct SessionHandle *data, continue; } else if(check->ssl[FIRSTSOCKET].state != ssl_connection_complete) { + foundPendingCandidate = TRUE; DEBUGF(infof(data, "Connection #%ld has not started SSL connect, " "can't reuse\n", @@ -3447,6 +3451,12 @@ ConnectionExists(struct SessionHandle *data, return TRUE; /* yes, we found one to use! */ } + if(foundPendingCandidate && data->set.pipewait) { + infof(data, + "Found pending candidate for reuse and CURLOPT_PIPEWAIT is set"); + *waitpipe = TRUE; + } + return FALSE; /* no matching connecting exists */ } |