int sockindex)
{
CURLcode result;
- int n = 0;
+ int n = -1;
struct Curl_cfilter *cf = conn->cfilter[sockindex];
result = cf ? cf->cft->query(cf, data, CF_QUERY_MAX_CONCURRENT,
&n, NULL) : CURLE_UNKNOWN_OPTION;
- return (result || n <= 0) ? 1 : (size_t)n;
+ /* If no filter answered the query, the default is a non-multiplexed
+ * connection with limit 1. Otherwise, the the query may return 0
+ * for connections that are in shutdown, e.g. server HTTP/2 GOAWAY. */
+ return (result || n < 0) ? 1 : (size_t)n;
}
int Curl_conn_get_stream_error(struct Curl_easy *data,
void *userdata)
{
struct multi_done_ctx *mdctx = userdata;
+#ifndef CURL_DISABLE_VERBOSE_STRINGS
+ const char *host =
+#ifndef CURL_DISABLE_PROXY
+ conn->bits.socksproxy ?
+ conn->socks_proxy.host.dispname :
+ conn->bits.httpproxy ? conn->http_proxy.host.dispname :
+#endif
+ conn->bits.conn_to_host ? conn->conn_to_host.dispname :
+ conn->host.dispname;
+ int port =
+#ifndef CURL_DISABLE_PROXY
+ conn->bits.httpproxy ? conn->http_proxy.port :
+#endif
+ conn->bits.conn_to_port ? conn->conn_to_port :
+ conn->remote_port;
+#endif
Curl_detach_connection(data);
#endif
) || conn->bits.close
|| (mdctx->premature && !Curl_conn_is_multiplex(conn, FIRSTSOCKET))) {
- CURL_TRC_M(data, "multi_done, not reusing connection=%"
- FMT_OFF_T ", forbid=%d"
- ", close=%d, premature=%d, conn_multiplex=%d",
- conn->connection_id, data->set.reuse_forbid,
- conn->bits.close, mdctx->premature,
- Curl_conn_is_multiplex(conn, FIRSTSOCKET));
+ CURL_TRC_M(data, "multi_done, terminating conn #%" FMT_OFF_T " to %s:%d, "
+ "forbid=%d, close=%d, premature=%d, conn_multiplex=%d",
+ conn->connection_id, host, port, data->set.reuse_forbid,
+ conn->bits.close, mdctx->premature,
+ Curl_conn_is_multiplex(conn, FIRSTSOCKET));
connclose(conn, "disconnecting");
Curl_conn_terminate(data, conn, mdctx->premature);
}
+ else if(!Curl_conn_get_max_concurrent(data, conn, FIRSTSOCKET)) {
+ CURL_TRC_M(data, "multi_done, conn #%" FMT_OFF_T " to %s:%d was shutdown"
+ " by server, not reusing", conn->connection_id, host, port);
+ connclose(conn, "server shutdown");
+ Curl_conn_terminate(data, conn, mdctx->premature);
+ }
else {
/* the connection is no longer in use by any transfer */
if(Curl_cpool_conn_now_idle(data, conn)) {
/* connection kept in the cpool */
- const char *host =
-#ifndef CURL_DISABLE_PROXY
- conn->bits.socksproxy ?
- conn->socks_proxy.host.dispname :
- conn->bits.httpproxy ? conn->http_proxy.host.dispname :
-#endif
- conn->bits.conn_to_host ? conn->conn_to_host.dispname :
- conn->host.dispname;
data->state.lastconnect_id = conn->connection_id;
- infof(data, "Connection #%" FMT_OFF_T " to host %s left intact",
- conn->connection_id, host);
+ infof(data, "Connection #%" FMT_OFF_T " to host %s:%d left intact",
+ conn->connection_id, host, port);
}
else {
/* connection was removed from the cpool and destroyed. */
^Host:.*
</strip>
<file name="%LOGDIR/stderr%TESTNUMBER" mode="text">
-* Connection #0 to host server1.example.com left intact
-* Connection #1 to host server2.example.com left intact
-* Connection #2 to host server3.example.com left intact
-* Connection #3 to host server4.example.com left intact
+* Connection #0 to host server1.example.com:%HTTPPORT left intact
+* Connection #1 to host server2.example.com:%HTTPPORT left intact
+* Connection #2 to host server3.example.com:%HTTPPORT left intact
+* Connection #3 to host server4.example.com:%HTTPPORT left intact
</file>
<stripfile>
$_ = '' if(($_ !~ /left intact/) && ($_ !~ /Closing connection/))
^Host:.*
</strip>
<file name="%LOGDIR/stderr%TESTNUMBER" mode="text">
-* Connection #0 to host server1.example.com left intact
-* Connection #1 to host server2.example.com left intact
-* Connection #2 to host server3.example.com left intact
-* Connection #3 to host server4.example.com left intact
+* Connection #0 to host server1.example.com:%HTTPPORT left intact
+* Connection #1 to host server2.example.com:%HTTPPORT left intact
+* Connection #2 to host server3.example.com:%HTTPPORT left intact
+* Connection #3 to host server4.example.com:%HTTPPORT left intact
</file>
<stripfile>
$_ = '' if(($_ !~ /left intact/) && ($_ !~ /Closing connection/))
\r
</protocol>
<file name="%LOGDIR/stderr%TESTNUMBER" mode="text">
-== Info: Connection #0 to host %HOSTIP left intact
-== Info: Connection #0 to host %HOSTIP left intact
-== Info: Connection #0 to host %HOSTIP left intact
+== Info: Connection #0 to host %HOSTIP:%HTTPPORT left intact
+== Info: Connection #0 to host %HOSTIP:%HTTPPORT left intact
+== Info: Connection #0 to host %HOSTIP:%HTTPPORT left intact
== Info: shutting down connection #0
-== Info: Connection #1 to host %HOSTIP left intact
+== Info: Connection #1 to host %HOSTIP:%HTTPPORT left intact
</file>
<stripfile>
$_ = '' if(($_ !~ /left intact/) && ($_ !~ /(closing|shutting down) connection #\d+/))
^Host:.*
</strip>
<file name="%LOGDIR/stderr%TESTNUMBER" mode="text">
-* Connection #0 to host localhost left intact
-* Connection #0 to host localhost left intact
-* Connection #0 to host localhost left intact
-* Connection #0 to host localhost left intact
+* Connection #0 to host localhost:%HTTP2TLSPORT left intact
+* Connection #0 to host localhost:%HTTP2TLSPORT left intact
+* Connection #0 to host localhost:%HTTP2TLSPORT left intact
+* Connection #0 to host localhost:%HTTP2TLSPORT left intact
</file>
<stripfile>
$_ = '' if(($_ !~ /left intact/) && ($_ !~ /Closing connection/))
^Host:.*
</strip>
<file name="%LOGDIR/stderr%TESTNUMBER" mode="text">
-* Connection #0 to host localhost left intact
-* Connection #0 to host localhost left intact
-* Connection #0 to host localhost left intact
-* Connection #0 to host localhost left intact
+* Connection #0 to host localhost:%HTTP2TLSPORT left intact
+* Connection #0 to host localhost:%HTTP2TLSPORT left intact
+* Connection #0 to host localhost:%HTTP2TLSPORT left intact
+* Connection #0 to host localhost:%HTTP2TLSPORT left intact
</file>
<stripfile>
$_ = '' if(($_ !~ /left intact/) && ($_ !~ /Closing connection/))
^Host:.*
</strip>
<file name="%LOGDIR/stderr%TESTNUMBER" mode="text">
-== Info: Connection #0 to host localhost left intact
-== Info: Connection #0 to host localhost left intact
-== Info: Connection #0 to host localhost left intact
-== Info: Connection #0 to host localhost left intact
+== Info: Connection #0 to host localhost:%HTTP3PORT left intact
+== Info: Connection #0 to host localhost:%HTTP3PORT left intact
+== Info: Connection #0 to host localhost:%HTTP3PORT left intact
+== Info: Connection #0 to host localhost:%HTTP3PORT left intact
</file>
<stripfile>
$_ = '' if(($_ !~ /left intact/) && ($_ !~ /Closing connection/))