← Commit list

1be704e17e

Stefan Eissing
Stefan Eissing
2024-08-28
SUCCESS Duration: 209s

Subject

cpool: rename "connection cache/conncache" to "Connection Pools/cpool"

Binary

Download Binary (853 KB)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

$ git checkout -f 1be704e17e70b626f89108f33b59bcdeb16f4b0e
Previous HEAD position was 29610e5f3d transfer: skip EOS read when download done
HEAD is now at 1be704e17e cpool: rename "connection cache/conncache" to "Connection Pools/cpool"

$ git clean -fdx
Removing Makefile
Removing Makefile.in
Removing aclocal.m4
Removing autom4te.cache/
Removing compile
Removing config.guess
Removing config.log
Removing config.status
Removing config.sub
Removing configure
Removing curl-config
Removing depcomp
Removing docs/Makefile
Removing docs/Makefile.in
Removing docs/cmdline-opts/Makefile
Removing docs/cmdline-opts/Makefile.in
Removing docs/examples/.deps/
Removing docs/examples/Makefile
Removing docs/examples/Makefile.in
Removing docs/libcurl/Makefile
Removing docs/libcurl/Makefile.in
Removing docs/libcurl/opts/Makefile
Removing docs/libcurl/opts/Makefile.in
Removing include/Makefile
Removing include/Makefile.in
Removing include/curl/Makefile
Removing include/curl/Makefile.in
Removing install-sh
Removing lib/.deps/
Removing lib/.dirstamp
Removing lib/.libs/
Removing lib/Makefile
Removing lib/Makefile.in
Removing lib/base64.o
Removing lib/curl_config.h
Removing lib/curl_config.h.in
Removing lib/curl_multibyte.o
Removing lib/dynbuf.o
Removing lib/libcurl.la
Removing lib/libcurl.vers
Removing lib/libcurl_la-altsvc.lo
Removing lib/libcurl_la-altsvc.o
Removing lib/libcurl_la-amigaos.lo
Removing lib/libcurl_la-amigaos.o
Removing lib/libcurl_la-asyn-ares.lo
Removing lib/libcurl_la-asyn-ares.o
Removing lib/libcurl_la-asyn-thread.lo
Removing lib/libcurl_la-asyn-thread.o
Removing lib/libcurl_la-base64.lo
Removing lib/libcurl_la-base64.o
Removing lib/libcurl_la-bufq.lo
Removing lib/libcurl_la-bufq.o
Removing lib/libcurl_la-bufref.lo
Removing lib/libcurl_la-bufref.o
Removing lib/libcurl_la-c-hyper.lo
Removing lib/libcurl_la-c-hyper.o
Removing lib/libcurl_la-cf-h1-proxy.lo
Removing lib/libcurl_la-cf-h1-proxy.o
Removing lib/libcurl_la-cf-h2-proxy.lo
Removing lib/libcurl_la-cf-h2-proxy.o
Removing lib/libcurl_la-cf-haproxy.lo
Removing lib/libcurl_la-cf-haproxy.o
Removing lib/libcurl_la-cf-https-connect.lo
Removing lib/libcurl_la-cf-https-connect.o
Removing lib/libcurl_la-cf-socket.lo
Removing lib/libcurl_la-cf-socket.o
Removing lib/libcurl_la-cfilters.lo
Removing lib/libcurl_la-cfilters.o
Removing lib/libcurl_la-conncache.lo
Removing lib/libcurl_la-conncache.o
Removing lib/libcurl_la-connect.lo
Removing lib/libcurl_la-connect.o
Removing lib/libcurl_la-content_encoding.lo
Removing lib/libcurl_la-content_encoding.o
Removing lib/libcurl_la-cookie.lo
Removing lib/libcurl_la-cookie.o
Removing lib/libcurl_la-curl_addrinfo.lo
Removing lib/libcurl_la-curl_addrinfo.o
Removing lib/libcurl_la-curl_des.lo
Removing lib/libcurl_la-curl_des.o
Removing lib/libcurl_la-curl_endian.lo
Removing lib/libcurl_la-curl_endian.o
Removing lib/libcurl_la-curl_fnmatch.lo
Removing lib/libcurl_la-curl_fnmatch.o
Removing lib/libcurl_la-curl_get_line.lo
Removing lib/libcurl_la-curl_get_line.o
Removing lib/libcurl_la-curl_gethostname.lo
Removing lib/libcurl_la-curl_gethostname.o
Removing lib/libcurl_la-curl_gssapi.lo
Removing lib/libcurl_la-curl_gssapi.o
Removing lib/libcurl_la-curl_memrchr.lo
Removing lib/libcurl_la-curl_memrchr.o
Removing lib/libcurl_la-curl_multibyte.lo
Removing lib/libcurl_la-curl_multibyte.o
Removing lib/libcurl_la-curl_ntlm_core.lo
Removing lib/libcurl_la-curl_ntlm_core.o
Removing lib/libcurl_la-curl_path.lo
Removing lib/libcurl_la-curl_path.o
Removing lib/libcurl_la-curl_range.lo
Removing lib/libcurl_la-curl_range.o
Removing lib/libcurl_la-curl_rtmp.lo
Removing lib/libcurl_la-curl_rtmp.o
Removing lib/libcurl_la-curl_sasl.lo
Removing lib/libcurl_la-curl_sasl.o
Removing lib/libcurl_la-curl_sha512_256.lo
Removing lib/libcurl_la-curl_sha512_256.o
Removing lib/libcurl_la-curl_sspi.lo
Removing lib/libcurl_la-curl_sspi.o
Removing lib/libcurl_la-curl_threads.lo
Removing lib/libcurl_la-curl_threads.o
Removing lib/libcurl_la-curl_trc.lo
Removing lib/libcurl_la-curl_trc.o
Removing lib/libcurl_la-cw-out.lo
Removing lib/libcurl_la-cw-out.o
Removing lib/libcurl_la-dict.lo
Removing lib/libcurl_la-dict.o
Removing lib/libcurl_la-dllmain.lo
Removing lib/libcurl_la-dllmain.o
Removing lib/libcurl_la-doh.lo
Removing lib/libcurl_la-doh.o
Removing lib/libcurl_la-dynbuf.lo
Removing lib/libcurl_la-dynbuf.o
Removing lib/libcurl_la-dynhds.lo
Removing lib/libcurl_la-dynhds.o
Removing lib/libcurl_la-easy.lo
Removing lib/libcurl_la-easy.o
Removing lib/libcurl_la-easygetopt.lo
Removing lib/libcurl_la-easygetopt.o
Removing lib/libcurl_la-easyoptions.lo
Removing lib/libcurl_la-easyoptions.o
Removing lib/libcurl_la-escape.lo
Removing lib/libcurl_la-escape.o
Removing lib/libcurl_la-file.lo
Removing lib/libcurl_la-file.o
Removing lib/libcurl_la-fileinfo.lo
Removing lib/libcurl_la-fileinfo.o
Removing lib/libcurl_la-fopen.lo
Removing lib/libcurl_la-fopen.o
Removing lib/libcurl_la-formdata.lo
Removing lib/libcurl_la-formdata.o
Removing lib/libcurl_la-ftp.lo
Removing lib/libcurl_la-ftp.o
Removing lib/libcurl_la-ftplistparser.lo
Removing lib/libcurl_la-ftplistparser.o
Removing lib/libcurl_la-getenv.lo
Removing lib/libcurl_la-getenv.o
Removing lib/libcurl_la-getinfo.lo
Removing lib/libcurl_la-getinfo.o
Removing lib/libcurl_la-gopher.lo
Removing lib/libcurl_la-gopher.o
Removing lib/libcurl_la-hash.lo
Removing lib/libcurl_la-hash.o
Removing lib/libcurl_la-headers.lo
Removing lib/libcurl_la-headers.o
Removing lib/libcurl_la-hmac.lo
Removing lib/libcurl_la-hmac.o
Removing lib/libcurl_la-hostasyn.lo
Removing lib/libcurl_la-hostasyn.o
Removing lib/libcurl_la-hostip.lo
Removing lib/libcurl_la-hostip.o
Removing lib/libcurl_la-hostip4.lo
Removing lib/libcurl_la-hostip4.o
Removing lib/libcurl_la-hostip6.lo
Removing lib/libcurl_la-hostip6.o
Removing lib/libcurl_la-hostsyn.lo
Removing lib/libcurl_la-hostsyn.o
Removing lib/libcurl_la-hsts.lo
Removing lib/libcurl_la-hsts.o
Removing lib/libcurl_la-http.lo
Removing lib/libcurl_la-http.o
Removing lib/libcurl_la-http1.lo
Removing lib/libcurl_la-http1.o
Removing lib/libcurl_la-http2.lo
Removing lib/libcurl_la-http2.o
Removing lib/libcurl_la-http_aws_sigv4.lo
Removing lib/libcurl_la-http_aws_sigv4.o
Removing lib/libcurl_la-http_chunks.lo
Removing lib/libcurl_la-http_chunks.o
Removing lib/libcurl_la-http_digest.lo
Removing lib/libcurl_la-http_digest.o
Removing lib/libcurl_la-http_negotiate.lo
Removing lib/libcurl_la-http_negotiate.o
Removing lib/libcurl_la-http_ntlm.lo
Removing lib/libcurl_la-http_ntlm.o
Removing lib/libcurl_la-http_proxy.lo
Removing lib/libcurl_la-http_proxy.o
Removing lib/libcurl_la-idn.lo
Removing lib/libcurl_la-idn.o
Removing lib/libcurl_la-if2ip.lo
Removing lib/libcurl_la-if2ip.o
Removing lib/libcurl_la-imap.lo
Removing lib/libcurl_la-imap.o
Removing lib/libcurl_la-inet_ntop.lo
Removing lib/libcurl_la-inet_ntop.o
Removing lib/libcurl_la-inet_pton.lo
Removing lib/libcurl_la-inet_pton.o
Removing lib/libcurl_la-krb5.lo
Removing lib/libcurl_la-krb5.o
Removing lib/libcurl_la-ldap.lo
Removing lib/libcurl_la-ldap.o
Removing lib/libcurl_la-llist.lo
Removing lib/libcurl_la-llist.o
Removing lib/libcurl_la-macos.lo
Removing lib/libcurl_la-macos.o
Removing lib/libcurl_la-md4.lo
Removing lib/libcurl_la-md4.o
Removing lib/libcurl_la-md5.lo
Removing lib/libcurl_la-md5.o
Removing lib/libcurl_la-memdebug.lo
Removing lib/libcurl_la-memdebug.o
Removing lib/libcurl_la-mime.lo
Removing lib/libcurl_la-mime.o
Removing lib/libcurl_la-mprintf.lo
Removing lib/libcurl_la-mprintf.o
Removing lib/libcurl_la-mqtt.lo
Removing lib/libcurl_la-mqtt.o
Removing lib/libcurl_la-multi.lo
Removing lib/libcurl_la-multi.o
Removing lib/libcurl_la-netrc.lo
Removing lib/libcurl_la-netrc.o
Removing lib/libcurl_la-nonblock.lo
Removing lib/libcurl_la-nonblock.o
Removing lib/libcurl_la-noproxy.lo
Removing lib/libcurl_la-noproxy.o
Removing lib/libcurl_la-openldap.lo
Removing lib/libcurl_la-openldap.o
Removing lib/libcurl_la-parsedate.lo
Removing lib/libcurl_la-parsedate.o
Removing lib/libcurl_la-pingpong.lo
Removing lib/libcurl_la-pingpong.o
Removing lib/libcurl_la-pop3.lo
Removing lib/libcurl_la-pop3.o
Removing lib/libcurl_la-progress.lo
Removing lib/libcurl_la-progress.o
Removing lib/libcurl_la-psl.lo
Removing lib/libcurl_la-psl.o
Removing lib/libcurl_la-rand.lo
Removing lib/libcurl_la-rand.o
Removing lib/libcurl_la-rename.lo
Removing lib/libcurl_la-rename.o
Removing lib/libcurl_la-request.lo
Removing lib/libcurl_la-request.o
Removing lib/libcurl_la-rtsp.lo
Removing lib/libcurl_la-rtsp.o
Removing lib/libcurl_la-select.lo
Removing lib/libcurl_la-select.o
Removing lib/libcurl_la-sendf.lo
Removing lib/libcurl_la-sendf.o
Removing lib/libcurl_la-setopt.lo
Removing lib/libcurl_la-setopt.o
Removing lib/libcurl_la-sha256.lo
Removing lib/libcurl_la-sha256.o
Removing lib/libcurl_la-share.lo
Removing lib/libcurl_la-share.o
Removing lib/libcurl_la-slist.lo
Removing lib/libcurl_la-slist.o
Removing lib/libcurl_la-smb.lo
Removing lib/libcurl_la-smb.o
Removing lib/libcurl_la-smtp.lo
Removing lib/libcurl_la-smtp.o
Removing lib/libcurl_la-socketpair.lo
Removing lib/libcurl_la-socketpair.o
Removing lib/libcurl_la-socks.lo
Removing lib/libcurl_la-socks.o
Removing lib/libcurl_la-socks_gssapi.lo
Removing lib/libcurl_la-socks_gssapi.o
Removing lib/libcurl_la-socks_sspi.lo
Removing lib/libcurl_la-socks_sspi.o
Removing lib/libcurl_la-speedcheck.lo
Removing lib/libcurl_la-speedcheck.o
Removing lib/libcurl_la-splay.lo
Removing lib/libcurl_la-splay.o
Removing lib/libcurl_la-strcase.lo
Removing lib/libcurl_la-strcase.o
Removing lib/libcurl_la-strdup.lo
Removing lib/libcurl_la-strdup.o
Removing lib/libcurl_la-strerror.lo
Removing lib/libcurl_la-strerror.o
Removing lib/libcurl_la-strtok.lo
Removing lib/libcurl_la-strtok.o
Removing lib/libcurl_la-strtoofft.lo
Removing lib/libcurl_la-strtoofft.o
Removing lib/libcurl_la-system_win32.lo
Removing lib/libcurl_la-system_win32.o
Removing lib/libcurl_la-telnet.lo
Removing lib/libcurl_la-telnet.o
Removing lib/libcurl_la-tftp.lo
Removing lib/libcurl_la-tftp.o
Removing lib/libcurl_la-timediff.lo
Removing lib/libcurl_la-timediff.o
Removing lib/libcurl_la-timeval.lo
Removing lib/libcurl_la-timeval.o
Removing lib/libcurl_la-transfer.lo
Removing lib/libcurl_la-transfer.o
Removing lib/libcurl_la-url.lo
Removing lib/libcurl_la-url.o
Removing lib/libcurl_la-urlapi.lo
Removing lib/libcurl_la-urlapi.o
Removing lib/libcurl_la-version.lo
Removing lib/libcurl_la-version.o
Removing lib/libcurl_la-version_win32.lo
Removing lib/libcurl_la-version_win32.o
Removing lib/libcurl_la-warnless.lo
Removing lib/libcurl_la-warnless.o
Removing lib/libcurl_la-ws.lo
Removing lib/libcurl_la-ws.o
Removing lib/nonblock.o
Removing lib/stamp-h1
Removing lib/strtoofft.o
Removing lib/timediff.o
Removing lib/vauth/.deps/
Removing lib/vauth/.dirstamp
Removing lib/vauth/libcurl_la-cleartext.lo
Removing lib/vauth/libcurl_la-cleartext.o
Removing lib/vauth/libcurl_la-cram.lo
Removing lib/vauth/libcurl_la-cram.o
Removing lib/vauth/libcurl_la-digest.lo
Removing lib/vauth/libcurl_la-digest.o
Removing lib/vauth/libcurl_la-digest_sspi.lo
Removing lib/vauth/libcurl_la-digest_sspi.o
Removing lib/vauth/libcurl_la-gsasl.lo
Removing lib/vauth/libcurl_la-gsasl.o
Removing lib/vauth/libcurl_la-krb5_gssapi.lo
Removing lib/vauth/libcurl_la-krb5_gssapi.o
Removing lib/vauth/libcurl_la-krb5_sspi.lo
Removing lib/vauth/libcurl_la-krb5_sspi.o
Removing lib/vauth/libcurl_la-ntlm.lo
Removing lib/vauth/libcurl_la-ntlm.o
Removing lib/vauth/libcurl_la-ntlm_sspi.lo
Removing lib/vauth/libcurl_la-ntlm_sspi.o
Removing lib/vauth/libcurl_la-oauth2.lo
Removing lib/vauth/libcurl_la-oauth2.o
Removing lib/vauth/libcurl_la-spnego_gssapi.lo
Removing lib/vauth/libcurl_la-spnego_gssapi.o
Removing lib/vauth/libcurl_la-spnego_sspi.lo
Removing lib/vauth/libcurl_la-spnego_sspi.o
Removing lib/vauth/libcurl_la-vauth.lo
Removing lib/vauth/libcurl_la-vauth.o
Removing lib/version_win32.o
Removing lib/vquic/.deps/
Removing lib/vquic/.dirstamp
Removing lib/vquic/libcurl_la-curl_msh3.lo
Removing lib/vquic/libcurl_la-curl_msh3.o
Removing lib/vquic/libcurl_la-curl_ngtcp2.lo
Removing lib/vquic/libcurl_la-curl_ngtcp2.o
Removing lib/vquic/libcurl_la-curl_osslq.lo
Removing lib/vquic/libcurl_la-curl_osslq.o
Removing lib/vquic/libcurl_la-curl_quiche.lo
Removing lib/vquic/libcurl_la-curl_quiche.o
Removing lib/vquic/libcurl_la-vquic-tls.lo
Removing lib/vquic/libcurl_la-vquic-tls.o
Removing lib/vquic/libcurl_la-vquic.lo
Removing lib/vquic/libcurl_la-vquic.o
Removing lib/vssh/.deps/
Removing lib/vssh/.dirstamp
Removing lib/vssh/libcurl_la-libssh.lo
Removing lib/vssh/libcurl_la-libssh.o
Removing lib/vssh/libcurl_la-libssh2.lo
Removing lib/vssh/libcurl_la-libssh2.o
Removing lib/vssh/libcurl_la-wolfssh.lo
Removing lib/vssh/libcurl_la-wolfssh.o
Removing lib/vtls/.deps/
Removing lib/vtls/.dirstamp
Removing lib/vtls/libcurl_la-bearssl.lo
Removing lib/vtls/libcurl_la-bearssl.o
Removing lib/vtls/libcurl_la-cipher_suite.lo
Removing lib/vtls/libcurl_la-cipher_suite.o
Removing lib/vtls/libcurl_la-gtls.lo
Removing lib/vtls/libcurl_la-gtls.o
Removing lib/vtls/libcurl_la-hostcheck.lo
Removing lib/vtls/libcurl_la-hostcheck.o
Removing lib/vtls/libcurl_la-keylog.lo
Removing lib/vtls/libcurl_la-keylog.o
Removing lib/vtls/libcurl_la-mbedtls.lo
Removing lib/vtls/libcurl_la-mbedtls.o
Removing lib/vtls/libcurl_la-mbedtls_threadlock.lo
Removing lib/vtls/libcurl_la-mbedtls_threadlock.o
Removing lib/vtls/libcurl_la-openssl.lo
Removing lib/vtls/libcurl_la-openssl.o
Removing lib/vtls/libcurl_la-rustls.lo
Removing lib/vtls/libcurl_la-rustls.o
Removing lib/vtls/libcurl_la-schannel.lo
Removing lib/vtls/libcurl_la-schannel.o
Removing lib/vtls/libcurl_la-schannel_verify.lo
Removing lib/vtls/libcurl_la-schannel_verify.o
Removing lib/vtls/libcurl_la-sectransp.lo
Removing lib/vtls/libcurl_la-sectransp.o
Removing lib/vtls/libcurl_la-vtls.lo
Removing lib/vtls/libcurl_la-vtls.o
Removing lib/vtls/libcurl_la-wolfssl.lo
Removing lib/vtls/libcurl_la-wolfssl.o
Removing lib/vtls/libcurl_la-x509asn1.lo
Removing lib/vtls/libcurl_la-x509asn1.o
Removing lib/warnless.o
Removing libcurl.pc
Removing libtool
Removing ltmain.sh
Removing m4/libtool.m4
Removing m4/ltoptions.m4
Removing m4/ltsugar.m4
Removing m4/ltversion.m4
Removing m4/lt~obsolete.m4
Removing missing
Removing packages/Makefile
Removing packages/Makefile.in
Removing packages/vms/Makefile
Removing packages/vms/Makefile.in
Removing scripts/Makefile
Removing scripts/Makefile.in
Removing src/.deps/
Removing src/.libs/
Removing src/Makefile
Removing src/Makefile.in
Removing src/curl
Removing src/slist_wc.o
Removing src/terminal.o
Removing src/tool_binmode.o
Removing src/tool_bname.o
Removing src/tool_ca_embed.c
Removing src/tool_ca_embed.o
Removing src/tool_cb_dbg.o
Removing src/tool_cb_hdr.o
Removing src/tool_cb_prg.o
Removing src/tool_cb_rea.o
Removing src/tool_cb_see.o
Removing src/tool_cb_soc.o
Removing src/tool_cb_wrt.o
Removing src/tool_cfgable.o
Removing src/tool_dirhie.o
Removing src/tool_doswin.o
Removing src/tool_easysrc.o
Removing src/tool_filetime.o
Removing src/tool_findfile.o
Removing src/tool_formparse.o
Removing src/tool_getparam.o
Removing src/tool_getpass.o
Removing src/tool_help.o
Removing src/tool_helpers.o
Removing src/tool_hugehelp.c
Removing src/tool_hugehelp.o
Removing src/tool_ipfs.o
Removing src/tool_libinfo.o
Removing src/tool_listhelp.o
Removing src/tool_main.o
Removing src/tool_msgs.o
Removing src/tool_operate.o
Removing src/tool_operhlp.o
Removing src/tool_paramhlp.o
Removing src/tool_parsecfg.o
Removing src/tool_progress.o
Removing src/tool_setopt.o
Removing src/tool_sleep.o
Removing src/tool_stderr.o
Removing src/tool_strdup.o
Removing src/tool_urlglob.o
Removing src/tool_util.o
Removing src/tool_vms.o
Removing src/tool_writeout.o
Removing src/tool_writeout_json.o
Removing src/tool_xattr.o
Removing src/var.o
Removing tests/Makefile
Removing tests/Makefile.in
Removing tests/certs/Makefile
Removing tests/certs/Makefile.in
Removing tests/certs/scripts/Makefile
Removing tests/certs/scripts/Makefile.in
Removing tests/config
Removing tests/configurehelp.pm
Removing tests/data/Makefile
Removing tests/data/Makefile.in
Removing tests/http/Makefile
Removing tests/http/Makefile.in
Removing tests/http/clients/.deps/
Removing tests/http/clients/Makefile
Removing tests/http/clients/Makefile.in
Removing tests/http/config.ini
Removing tests/libtest/.deps/
Removing tests/libtest/Makefile
Removing tests/libtest/Makefile.in
Removing tests/server/.deps/
Removing tests/server/Makefile
Removing tests/server/Makefile.in
Removing tests/unit/.deps/
Removing tests/unit/Makefile
Removing tests/unit/Makefile.in

$ autoreconf -fi
libtoolize: putting auxiliary files in '.'.
libtoolize: copying file './ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: copying file 'm4/libtool.m4'
libtoolize: copying file 'm4/ltoptions.m4'
libtoolize: copying file 'm4/ltsugar.m4'
libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
libtoolize: Remember to add 'LT_INIT' to configure.ac.
configure.ac:125: installing './compile'
configure.ac:437: installing './config.guess'
configure.ac:437: installing './config.sub'
configure.ac:125: installing './install-sh'
configure.ac:131: installing './missing'
docs/examples/Makefile.am: installing './depcomp'

$ bash -c find . -name config.guess -exec cp /usr/share/misc/config.guess {} \;

$ bash -c find . -name config.sub -exec cp /usr/share/misc/config.sub {} \;

$ chmod +x configure

$ ./configure --disable-shared --without-ssl --disable-docs
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether make supports nested variables... yes
checking whether to enable debug build options... no
checking whether to enable compiler optimizer... (assumed) yes
checking whether to enable strict compiler warnings... no
checking whether to enable compiler warnings as errors... no
checking whether to enable curl debug memory tracking... no
checking whether to enable hiding of library internal symbols... yes
checking whether to enable c-ares for DNS lookups... no
checking whether to disable dependency on -lrt... (assumed no)
checking whether to enable HTTPSRR support... no
checking whether to enable ECH support... no
checking for path separator... :
checking for sed... /usr/bin/sed
checking for grep... /usr/bin/grep
checking that grep -E works... yes
checking for ar... /usr/bin/ar
checking for a BSD-compatible install... /usr/bin/install -c
checking for gcc... ccache gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether ccache gcc accepts -g... yes
checking for ccache gcc option to enable C11 features... none needed
checking whether ccache gcc understands -c and -o together... yes
checking how to run the C preprocessor... ccache gcc -E
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for stdatomic.h... yes
checking if _Atomic is available... yes
checking for a sed that does not truncate output... (cached) /usr/bin/sed
checking for code coverage support... no
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of ccache gcc... gcc3
checking curl version... 8.10.0-DEV
checking for httpd... no
checking for apache2... no
checking for apachectl... no
checking for apxs... no
configure: httpd/apache2 not in PATH, http tests disabled
configure: apxs not in PATH, http tests disabled
checking for nghttpx... no
checking for caddy... /usr/bin/caddy
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for grep that handles long lines and -e... (cached) /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking if OS is AIX (to define _ALL_SOURCE)... no
checking if _THREAD_SAFE is already defined... no
checking if _THREAD_SAFE is actually needed... no
checking if _THREAD_SAFE is onwards defined... no
checking if _REENTRANT is already defined... no
checking if _REENTRANT is actually needed... no
checking if _REENTRANT is onwards defined... no
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by ccache gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from ccache gcc object... ok
checking for sysroot... no
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if ccache gcc supports -fno-rtti -fno-exceptions... no
checking for ccache gcc option to produce PIC... -fPIC -DPIC
checking if ccache gcc PIC flag -fPIC -DPIC works... yes
checking if ccache gcc static flag -static works... yes
checking if ccache gcc supports -c -o file.o... yes
checking if ccache gcc supports -c -o file.o... (cached) yes
checking whether the ccache gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking whether to build shared libraries with -version-info... yes
checking whether to build shared libraries with -no-undefined... no
checking whether to build shared libraries with -mimpure-text... no
checking whether to build shared libraries with PIC... yes
checking whether to build static libraries with PIC... yes
checking whether to build shared libraries only... no
checking whether to build static libraries only... yes
checking for windres... no
checking if cpp -P is needed... yes
checking if cpp -P works... yes
checking if compiler is DEC/Compaq/HP C... no
checking if compiler is HP-UX C... no
checking if compiler is IBM C... no
checking if compiler is Intel C... no
checking if compiler is clang... no
checking if compiler is GNU C... yes
checking compiler version... gcc '1100' (raw: '11')
checking if compiler is SunPro C... no
checking if compiler is Tiny C... no
checking whether build target is a native Windows one... no
checking if compiler accepts some basic options... yes
configure: compiler options added: -Werror-implicit-function-declaration 
checking if compiler optimizer assumed setting might be used... yes
checking if compiler accepts optimizer enabling options... yes
configure: compiler options added: -O2
checking if compiler accepts strict warning options... yes
configure: compiler options added: -Wno-system-headers 
checking if compiler halts on compilation errors... yes
checking if compiler halts on negative sized arrays... yes
checking if compiler halts on function prototype mismatch... yes
checking if compiler supports hiding library internal symbols... yes
checking whether build target supports Win32 file API... no
checking whether build target supports Win32 crypto API... no
checking for good-to-use Darwin CFLAGS... no
checking whether to support http... yes
checking whether to support ftp... yes
checking whether to support file... yes
checking whether to support ldap... yes
checking whether to support ldaps... yes
checking whether to support rtsp... yes
checking whether to support proxies... yes
checking whether to support dict... yes
checking whether to support telnet... yes
checking whether to support tftp... yes
checking whether to support pop3... yes
checking whether to support imap... yes
checking whether to support smb... yes
checking whether to support smtp... yes
checking whether to support gopher... yes
checking whether to support mqtt... no
checking whether to provide built-in manual... yes
checking whether to build documentation... no
checking whether to enable generation of C code... yes
checking whether to use libgcc... no
checking if X/Open network library is required... no
checking for gethostbyname... yes
checking whether build target is a native Windows one... (cached) no
checking for proto/bsdsocket.h... no
checking for connect in libraries... yes
checking for sys/types.h... (cached) yes
checking for sys/time.h... yes
checking for monotonic clock_gettime... yes
checking for clock_gettime in libraries... no additional lib required
checking if monotonic clock_gettime works... yes
checking for sys/types.h... (cached) yes
checking for sys/time.h... (cached) yes
checking for raw monotonic clock_gettime... yes
checking for pkg-config... /usr/bin/pkg-config
checking for zlib options with pkg-config... found
checking for zlib.h... yes
configure: found both libz and libz.h header
checking for BrotliDecoderDecompress in -lbrotlidec... no
checking for brotli/decode.h... no
checking for ZSTD_createDStream in -lzstd... no
checking for zstd.h... no
checking for lber.h... no
checking for ldap.h... no
checking for ldap_ssl.h... no
checking for LDAP libraries... cannot find LDAP libraries
checking whether to enable IPv6... yes
checking if struct sockaddr_in6 has sin6_scope_id member... yes
checking if argv can be written to... yes
checking if GSS-API support is requested... no
checking whether to enable Windows native SSL/TLS... no
checking whether to enable Secure Transport... no
checking whether to enable Amiga native SSL/TLS (AmiSSL v5)... no
checking for pkg-config... (cached) /usr/bin/pkg-config
checking for libpsl options with pkg-config... found
checking for psl_builtin in -lpsl... yes
checking for libpsl.h... yes
checking for library containing gsasl_init... no
checking for RTMP_Init in -lrtmp... no
checking whether versioned symbols are wanted... no
checking whether to build with libidn2... (assumed) yes
checking for pkg-config... (cached) /usr/bin/pkg-config
checking for libidn2 options with pkg-config... no
configure: IDN_LIBS: "-lidn2"
configure: IDN_LDFLAGS: ""
configure: IDN_CPPFLAGS: ""
configure: IDN_DIR: ""
checking if idn2_lookup_ul can be linked... no
checking for idn2.h... no
checking for pkg-config... (cached) /usr/bin/pkg-config
checking for libnghttp2 options with pkg-config... no
checking for nghttp2_session_get_stream_local_window_size in -lnghttp2... no
checking for sys/types.h... (cached) yes
checking for sys/time.h... (cached) yes
checking for sys/select.h... yes
checking for sys/socket.h... yes
checking for sys/ioctl.h... yes
checking for unistd.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for arpa/inet.h... yes
checking for net/if.h... yes
checking for netinet/in.h... yes
checking for netinet/in6.h... no
checking for sys/un.h... yes
checking for linux/tcp.h... yes
checking for netinet/tcp.h... yes
checking for netinet/udp.h... yes
checking for netdb.h... yes
checking for sys/sockio.h... no
checking for sys/stat.h... (cached) yes
checking for sys/param.h... yes
checking for termios.h... yes
checking for termio.h... yes
checking for fcntl.h... yes
checking for io.h... no
checking for pwd.h... yes
checking for utime.h... yes
checking for sys/utime.h... no
checking for sys/poll.h... yes
checking for poll.h... yes
checking for socket.h... no
checking for sys/resource.h... yes
checking for libgen.h... yes
checking for locale.h... yes
checking for stdbool.h... yes
checking for sys/filio.h... no
checking for sys/wait.h... yes
checking for sys/eventfd.h... yes
checking for setjmp.h... yes
checking for an ANSI C-conforming const... yes
checking for size_t... yes
checking for sys/types.h... (cached) yes
checking for sys/time.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for struct timeval... yes
checking run-time libs availability... fine
checking size of size_t... 8
checking size of long... 8
checking size of int... 4
checking size of time_t... 8
checking size of off_t... 8
checking size of curl_off_t... 8
checking size of curl_socket_t... 4
checking for long long... yes
checking for ssize_t... yes
checking for bool... yes
checking for sa_family_t... yes
checking for suseconds_t... yes
checking if time_t is unsigned... no
checking for in_addr_t... yes
checking for struct sockaddr_storage... yes
checking for sys/select.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for select... yes
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for recv... yes
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for send... yes
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for MSG_NOSIGNAL... yes
checking for sys/types.h... (cached) yes
checking for unistd.h... (cached) yes
checking if alarm can be linked... yes
checking if alarm is prototyped... yes
checking if alarm is compilable... yes
checking if alarm usage allowed... yes
checking if alarm might be used... yes
checking for sys/types.h... (cached) yes
checking for strings.h... (cached) yes
checking for sys/types.h... (cached) yes
checking for libgen.h... (cached) yes
checking if basename can be linked... yes
checking if basename is prototyped... yes
checking if basename is compilable... yes
checking if basename usage allowed... yes
checking if basename might be used... yes
checking for sys/types.h... (cached) yes
checking for socket.h... (cached) no
checking if closesocket can be linked... no
checking if closesocket might be used... no
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking if CloseSocket can be linked... no
checking if CloseSocket might be used... no
checking for sys/types.h... (cached) yes
checking for unistd.h... (cached) yes
checking for fcntl.h... (cached) yes
checking if fcntl can be linked... yes
checking if fcntl is prototyped... yes
checking if fcntl is compilable... yes
checking if fcntl usage allowed... yes
checking if fcntl might be used... yes
checking if fcntl O_NONBLOCK is compilable... yes
checking if fcntl O_NONBLOCK usage allowed... yes
checking if fcntl O_NONBLOCK might be used... yes
checking whether build target is a native Windows one... (cached) no
checking for sys/types.h... (cached) yes
checking for netdb.h... (cached) yes
checking if freeaddrinfo can be linked... yes
checking if freeaddrinfo is prototyped... yes
checking if freeaddrinfo is compilable... yes
checking if freeaddrinfo usage allowed... yes
checking if freeaddrinfo might be used... yes
checking for sys/types.h... (cached) yes
checking for sys/xattr.h... yes
checking if fsetxattr can be linked... yes
checking if fsetxattr is prototyped... yes
checking if fsetxattr takes 5 args.... yes
checking if fsetxattr is compilable... yes
checking if fsetxattr usage allowed... yes
checking if fsetxattr might be used... yes
checking if ftruncate can be linked... yes
checking if ftruncate is prototyped... yes
checking if ftruncate is compilable... yes
checking if ftruncate usage allowed... yes
checking if ftruncate might be used... yes
checking for sys/types.h... (cached) yes
checking if getaddrinfo can be linked... yes
checking if getaddrinfo is prototyped... yes
checking if getaddrinfo is compilable... yes
checking if getaddrinfo seems to work... yes
checking if getaddrinfo usage allowed... yes
checking if getaddrinfo might be used... yes
checking if getaddrinfo is threadsafe... yes
checking if gethostbyname can be linked... yes
checking if gethostbyname is prototyped... yes
checking if gethostbyname is compilable... yes
checking if gethostbyname usage allowed... yes
checking if gethostbyname might be used... yes
checking if gethostbyname_r can be linked... yes
checking if gethostbyname_r is prototyped... yes
checking if gethostbyname_r takes 3 args.... no
checking if gethostbyname_r takes 5 args.... no
checking if gethostbyname_r takes 6 args.... yes
checking if gethostbyname_r is compilable... yes
checking if gethostbyname_r usage allowed... yes
checking if gethostbyname_r might be used... yes
checking if gethostname can be linked... yes
checking if gethostname is prototyped... yes
checking if gethostname is compilable... yes
checking for gethostname arg 2 data type... size_t
checking if gethostname usage allowed... yes
checking if gethostname might be used... yes
checking if getpeername can be linked... yes
checking if getpeername is prototyped... yes
checking if getpeername is compilable... yes
checking if getpeername usage allowed... yes
checking if getpeername might be used... yes
checking if getsockname can be linked... yes
checking if getsockname is prototyped... yes
checking if getsockname is compilable... yes
checking if getsockname usage allowed... yes
checking if getsockname might be used... yes
checking for net/if.h... (cached) yes
checking if if_nametoindex can be linked... yes
checking if if_nametoindex is prototyped... yes
checking if if_nametoindex is compilable... yes
checking if if_nametoindex usage allowed... yes
checking if if_nametoindex might be used... yes
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for netinet/in.h... (cached) yes
checking for ifaddrs.h... yes
checking if getifaddrs can be linked... yes
checking if getifaddrs is prototyped... yes
checking if getifaddrs is compilable... yes
checking if getifaddrs seems to work... yes
checking if getifaddrs usage allowed... yes
checking if getifaddrs might be used... yes
checking for sys/types.h... (cached) yes
checking for sys/time.h... (cached) yes
checking if gmtime_r can be linked... yes
checking if gmtime_r is prototyped... yes
checking if gmtime_r is compilable... yes
checking if gmtime_r seems to work... yes
checking if gmtime_r usage allowed... yes
checking if gmtime_r might be used... yes
checking for sys/types.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for netinet/in.h... (cached) yes
checking for arpa/inet.h... (cached) yes
checking if inet_ntop can be linked... yes
checking if inet_ntop is prototyped... yes
checking if inet_ntop is compilable... yes
checking if inet_ntop seems to work... yes
checking if inet_ntop usage allowed... yes
checking if inet_ntop might be used... yes
checking if inet_pton can be linked... yes
checking if inet_pton is prototyped... yes
checking if inet_pton is compilable... yes
checking if inet_pton seems to work... yes
checking if inet_pton usage allowed... yes
checking if inet_pton might be used... yes
checking for sys/types.h... (cached) yes
checking for unistd.h... (cached) yes
checking for sys/socket.h... (cached) yes
checking for sys/ioctl.h... (cached) yes
checking for stropts.h... no
checking if ioctl can be linked... yes
checking if ioctl is prototyped... yes
checking if ioctl is compilable... yes
checking if ioctl usage allowed... yes
checking if ioctl might be used... yes
checking if ioctl FIONBIO is compilable... yes
checking if ioctl FIONBIO usage allowed... yes
checking if ioctl FIONBIO might be used... yes
checking if ioctl SIOCGIFADDR is compilable... yes
checking if ioctl SIOCGIFADDR usage allowed... yes
checking if ioctl SIOCGIFADDR might be used... yes
checking if ioctlsocket can be linked... no
checking if ioctlsocket might be used... no
checking if IoctlSocket can be linked... no
checking if IoctlSocket might be used... no
checking if memrchr can be linked... yes
checking if memrchr is prototyped... no
checking if memrchr might be used... no
checking for sys/types.h... (cached) yes
checking for poll.h... (cached) yes
checking for sys/poll.h... (cached) yes
checking if poll can be linked... yes
checking if poll is prototyped... yes
checking if poll is compilable... yes
checking if poll seems to work... yes
checking if poll usage allowed... yes
checking if poll might be used... yes
checking for sys/types.h... (cached) yes
checking if sigaction can be linked... yes
checking if sigaction is prototyped... yes
checking if sigaction is compilable... yes
checking if sigaction usage allowed... yes
checking if sigaction might be used... yes
checking if siginterrupt can be linked... yes
checking if siginterrupt is prototyped... yes
checking if siginterrupt is compilable... yes
checking if siginterrupt usage allowed... yes
checking if siginterrupt might be used... yes
checking if signal can be linked... yes
checking if signal is prototyped... yes
checking if signal is compilable... yes
checking if signal usage allowed... yes
checking if signal might be used... yes
checking for sys/types.h... (cached) yes
checking if sigsetjmp can be linked... no
checking if sigsetjmp seems a macro... yes
checking if sigsetjmp is compilable... yes
checking if sigsetjmp usage allowed... yes
checking if sigsetjmp might be used... yes
checking if socket can be linked... yes
checking if socket is prototyped... yes
checking if socket is compilable... yes
checking if socket usage allowed... yes
checking if socket might be used... yes
checking if socketpair can be linked... yes
checking if socketpair is prototyped... yes
checking if socketpair is compilable... yes
checking if socketpair usage allowed... yes
checking if socketpair might be used... yes
checking if strcasecmp can be linked... yes
checking if strcasecmp is prototyped... yes
checking if strcasecmp is compilable... yes
checking if strcasecmp usage allowed... yes
checking if strcasecmp might be used... yes
checking if strcmpi can be linked... no
checking if strcmpi might be used... no
checking if strdup can be linked... yes
checking if strdup is prototyped... yes
checking if strdup is compilable... yes
checking if strdup usage allowed... yes
checking if strdup might be used... yes
checking if strerror_r can be linked... yes
checking if strerror_r is prototyped... yes
checking if strerror_r is compilable... yes
checking if strerror_r is glibc like... no
checking if strerror_r is POSIX like... yes
checking if strerror_r seems to work... yes
checking if strerror_r usage allowed... yes
checking if strerror_r might be used... yes
checking if stricmp can be linked... no
checking if stricmp might be used... no
checking if strtok_r can be linked... yes
checking if strtok_r is prototyped... yes
checking if strtok_r is compilable... yes
checking if strtok_r usage allowed... yes
checking if strtok_r might be used... yes
checking if strtoll can be linked... yes
checking if strtoll is prototyped... yes
checking if strtoll is compilable... yes
checking if strtoll usage allowed... yes
checking if strtoll might be used... yes
checking for ccache gcc options needed to detect all undeclared functions... none needed
checking whether getpwuid_r is declared... yes
checking for _fseeki64... no
checking for arc4random... no
checking for eventfd... yes
checking for fnmatch... yes
checking for geteuid... yes
checking for getpass_r... no
checking for getppid... yes
checking for getpwuid... yes
checking for getpwuid_r... yes
checking for getrlimit... yes
checking for gettimeofday... yes
checking for if_nametoindex... yes
checking for mach_absolute_time... no
checking for pipe... yes
checking for sched_yield... yes
checking for sendmsg... yes
checking for setlocale... yes
checking for setmode... no
checking for setrlimit... yes
checking for snprintf... yes
checking for utime... yes
checking for utimes... yes
checking for fseeko... yes
checking whether fseeko is declared... yes
checking how to set a socket into non-blocking mode... fcntl O_NONBLOCK
checking whether to enable the threaded resolver... yes
checking whether to link macOS CoreFoundation, CoreServices, and SystemConfiguration frameworks... no
checking whether to use POSIX threads for threaded resolver... auto
checking for pthread.h... yes
checking for pthread_create... yes
checking for dirent.h... yes
checking for opendir... yes
checking convert -I options to -isystem... yes
checking whether to enable verbose strings... yes
checking whether to enable SSPI support (Windows native builds only)... no
checking whether to enable basic authentication method... yes
checking whether to enable bearer authentication method... yes
checking whether to enable digest authentication method... yes
checking whether to enable kerberos authentication method... yes
checking whether to enable negotiate authentication method... yes
checking whether to enable aws sig methods... yes
checking whether to support NTLM... yes
checking whether to enable TLS-SRP authentication... yes
checking whether to enable Unix domain sockets... auto
checking for struct sockaddr_un.sun_path... yes
checking whether to support cookies... yes
checking whether to support socketpair... yes
checking whether to support HTTP authentication... yes
checking whether to support DoH... yes
checking whether to support the MIME API... yes
checking whether to support binding connections locally... yes
checking whether to support the form API... yes
checking whether to support date parsing... yes
checking whether to support netrc parsing... yes
checking whether to support progress-meter... yes
checking whether to support DNS shuffling... yes
checking whether to support curl_easy_option*... yes
checking whether to support alt-svc... yes
checking whether to support headers-api... yes
configure: disables HSTS due to lack of SSL
checking whether to support WebSockets... no
checking whether hiding of library internal symbols will actually happen... yes
checking if this build supports HTTPS-proxy... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating docs/Makefile
config.status: creating docs/examples/Makefile
config.status: creating docs/libcurl/Makefile
config.status: creating docs/libcurl/opts/Makefile
config.status: creating docs/cmdline-opts/Makefile
config.status: creating include/Makefile
config.status: creating include/curl/Makefile
config.status: creating src/Makefile
config.status: creating lib/Makefile
config.status: creating scripts/Makefile
config.status: creating lib/libcurl.vers
config.status: creating tests/Makefile
config.status: creating tests/config
config.status: creating tests/certs/Makefile
config.status: creating tests/certs/scripts/Makefile
config.status: creating tests/data/Makefile
config.status: creating tests/server/Makefile
config.status: creating tests/libtest/Makefile
config.status: creating tests/unit/Makefile
config.status: creating tests/http/config.ini
config.status: creating tests/http/Makefile
config.status: creating tests/http/clients/Makefile
config.status: creating packages/Makefile
config.status: creating packages/vms/Makefile
config.status: creating curl-config
config.status: creating libcurl.pc
config.status: creating lib/curl_config.h
config.status: executing depfiles commands
config.status: executing libtool commands
configure: Configured to build curl/libcurl:

  Host setup:       x86_64-pc-linux-gnu
  Install prefix:   /usr/local
  Compiler:         ccache gcc
   CFLAGS:          -Werror-implicit-function-declaration -O2 -Wno-system-headers
   CFLAGS extras:   
   CPPFLAGS:        
   LDFLAGS:         
   LIBS:            -lpsl -lz

  curl version:     8.10.0-DEV
  SSL:              no      (--with-{openssl,gnutls,mbedtls,wolfssl,schannel,secure-transport,amissl,bearssl,rustls} )
  SSH:              no      (--with-{libssh,libssh2})
  zlib:             enabled
  brotli:           no      (--with-brotli)
  zstd:             no      (--with-zstd)
  GSS-API:          no      (--with-gssapi)
  GSASL:            no      (libgsasl not found)
  TLS-SRP:          no      (--enable-tls-srp)
  resolver:         POSIX threaded
  IPv6:             enabled
  Unix sockets:     enabled
  IDN:              no      (--with-{libidn2,winidn})
  Build docs:       no
  Build libcurl:    Shared=no, Static=yes
  Built-in manual:  no      (--enable-manual)
  --libcurl option: enabled (--disable-libcurl-option)
  Verbose errors:   enabled (--disable-verbose)
  Code coverage:    disabled
  SSPI:             no      (--enable-sspi)
  ca cert bundle:   no
  ca cert path:     
  ca fallback:      
  LDAP:             no      (--enable-ldap / --with-ldap-lib / --with-lber-lib)
  LDAPS:            no      (--enable-ldaps)
  RTSP:             enabled
  RTMP:             no      (--with-librtmp)
  PSL:              enabled
  Alt-svc:          enabled (--disable-alt-svc)
  Headers API:      enabled (--disable-headers-api)
  HSTS:             no      (--enable-hsts)
  HTTP1:            enabled (internal)
  HTTP2:            no      (--with-nghttp2)
  HTTP3:            no      (--with-ngtcp2 --with-nghttp3, --with-quiche, --with-openssl-quic, --with-msh3)
  ECH:              no      (--enable-ech)
  WebSockets:       no      (--enable-websockets)
  Protocols:        dict file ftp gopher http imap ipfs ipns mqtt pop3 rtsp smtp telnet tftp
  Features:         alt-svc AsynchDNS IPv6 Largefile libz PSL threadsafe UnixSockets

configure: WARNING: Cannot find libraries for LDAP support: LDAP disabled
configure: WARNING: libgsasl was not found
configure: WARNING: Cannot find libidn2

$ make -j3
Making all in lib
make[1]: Entering directory '/root/asi_db/builds/curl/_worktrees/w0/lib'
make  all-am
make[2]: Entering directory '/root/asi_db/builds/curl/_worktrees/w0/lib'
  CC       libcurl_la-amigaos.lo
  CC       libcurl_la-altsvc.lo
  CC       libcurl_la-asyn-ares.lo
  CC       libcurl_la-asyn-thread.lo
  CC       libcurl_la-base64.lo
  CC       libcurl_la-bufq.lo
  CC       libcurl_la-bufref.lo
  CC       libcurl_la-c-hyper.lo
  CC       libcurl_la-cf-h1-proxy.lo
  CC       libcurl_la-cf-h2-proxy.lo
  CC       libcurl_la-cf-haproxy.lo
  CC       libcurl_la-cf-https-connect.lo
  CC       libcurl_la-cf-socket.lo
  CC       libcurl_la-cfilters.lo
  CC       libcurl_la-conncache.lo
  CC       libcurl_la-connect.lo
  CC       libcurl_la-content_encoding.lo
  CC       libcurl_la-cookie.lo
  CC       libcurl_la-curl_addrinfo.lo
  CC       libcurl_la-curl_des.lo
  CC       libcurl_la-curl_endian.lo
  CC       libcurl_la-curl_fnmatch.lo
  CC       libcurl_la-curl_get_line.lo
  CC       libcurl_la-curl_gethostname.lo
  CC       libcurl_la-curl_gssapi.lo
  CC       libcurl_la-curl_memrchr.lo
  CC       libcurl_la-curl_multibyte.lo
  CC       libcurl_la-curl_ntlm_core.lo
  CC       libcurl_la-curl_path.lo
  CC       libcurl_la-curl_range.lo
  CC       libcurl_la-curl_rtmp.lo
  CC       libcurl_la-curl_sasl.lo
  CC       libcurl_la-curl_sha512_256.lo
  CC       libcurl_la-curl_sspi.lo
  CC       libcurl_la-curl_threads.lo
  CC       libcurl_la-curl_trc.lo
  CC       libcurl_la-cw-out.lo
  CC       libcurl_la-dict.lo
  CC       libcurl_la-dllmain.lo
  CC       libcurl_la-doh.lo
  CC       libcurl_la-dynbuf.lo
  CC       libcurl_la-dynhds.lo
  CC       libcurl_la-easy.lo
  CC       libcurl_la-easygetopt.lo
  CC       libcurl_la-easyoptions.lo
  CC       libcurl_la-escape.lo
  CC       libcurl_la-file.lo
  CC       libcurl_la-fileinfo.lo
  CC       libcurl_la-fopen.lo
  CC       libcurl_la-formdata.lo
  CC       libcurl_la-ftp.lo
  CC       libcurl_la-ftplistparser.lo
  CC       libcurl_la-getenv.lo
  CC       libcurl_la-getinfo.lo
  CC       libcurl_la-gopher.lo
  CC       libcurl_la-hash.lo
  CC       libcurl_la-headers.lo
  CC       libcurl_la-hmac.lo
  CC       libcurl_la-hostasyn.lo
  CC       libcurl_la-hostip.lo
  CC       libcurl_la-hostip4.lo
  CC       libcurl_la-hostip6.lo
  CC       libcurl_la-hostsyn.lo
  CC       libcurl_la-hsts.lo
  CC       libcurl_la-http.lo
  CC       libcurl_la-http1.lo
  CC       libcurl_la-http2.lo
  CC       libcurl_la-http_aws_sigv4.lo
  CC       libcurl_la-http_chunks.lo
  CC       libcurl_la-http_digest.lo
  CC       libcurl_la-http_negotiate.lo
  CC       libcurl_la-http_ntlm.lo
  CC       libcurl_la-http_proxy.lo
  CC       libcurl_la-idn.lo
  CC       libcurl_la-if2ip.lo
  CC       libcurl_la-imap.lo
  CC       libcurl_la-inet_ntop.lo
  CC       libcurl_la-inet_pton.lo
  CC       libcurl_la-krb5.lo
  CC       libcurl_la-ldap.lo
  CC       libcurl_la-llist.lo
  CC       libcurl_la-macos.lo
  CC       libcurl_la-md4.lo
  CC       libcurl_la-md5.lo
  CC       libcurl_la-memdebug.lo
  CC       libcurl_la-mime.lo
  CC       libcurl_la-mprintf.lo
  CC       libcurl_la-mqtt.lo
  CC       libcurl_la-multi.lo
  CC       libcurl_la-netrc.lo
  CC       libcurl_la-nonblock.lo
  CC       libcurl_la-noproxy.lo
  CC       libcurl_la-openldap.lo
  CC       libcurl_la-parsedate.lo
  CC       libcurl_la-pingpong.lo
  CC       libcurl_la-pop3.lo
  CC       libcurl_la-progress.lo
  CC       libcurl_la-psl.lo
  CC       libcurl_la-rand.lo
  CC       libcurl_la-rename.lo
  CC       libcurl_la-request.lo
  CC       libcurl_la-rtsp.lo
  CC       libcurl_la-select.lo
  CC       libcurl_la-sendf.lo
  CC       libcurl_la-setopt.lo
  CC       libcurl_la-sha256.lo
  CC       libcurl_la-share.lo
  CC       libcurl_la-slist.lo
  CC       libcurl_la-smb.lo
  CC       libcurl_la-smtp.lo
  CC       libcurl_la-socketpair.lo
  CC       libcurl_la-socks.lo
  CC       libcurl_la-socks_gssapi.lo
  CC       libcurl_la-socks_sspi.lo
  CC       libcurl_la-speedcheck.lo
  CC       libcurl_la-splay.lo
  CC       libcurl_la-strcase.lo
  CC       libcurl_la-strdup.lo
  CC       libcurl_la-strerror.lo
  CC       libcurl_la-strtok.lo
  CC       libcurl_la-strtoofft.lo
  CC       libcurl_la-system_win32.lo
  CC       libcurl_la-telnet.lo
  CC       libcurl_la-tftp.lo
  CC       libcurl_la-timediff.lo
  CC       libcurl_la-timeval.lo
  CC       libcurl_la-transfer.lo
  CC       libcurl_la-url.lo
  CC       libcurl_la-urlapi.lo
  CC       libcurl_la-version.lo
  CC       libcurl_la-version_win32.lo
  CC       libcurl_la-warnless.lo
  CC       libcurl_la-ws.lo
  CC       vauth/libcurl_la-cleartext.lo
  CC       vauth/libcurl_la-cram.lo
  CC       vauth/libcurl_la-digest.lo
  CC       vauth/libcurl_la-digest_sspi.lo
  CC       vauth/libcurl_la-gsasl.lo
  CC       vauth/libcurl_la-krb5_gssapi.lo
  CC       vauth/libcurl_la-krb5_sspi.lo
  CC       vauth/libcurl_la-ntlm.lo
  CC       vauth/libcurl_la-ntlm_sspi.lo
  CC       vauth/libcurl_la-oauth2.lo
  CC       vauth/libcurl_la-spnego_gssapi.lo
  CC       vauth/libcurl_la-spnego_sspi.lo
  CC       vauth/libcurl_la-vauth.lo
  CC       vtls/libcurl_la-bearssl.lo
  CC       vtls/libcurl_la-cipher_suite.lo
  CC       vtls/libcurl_la-gtls.lo
  CC       vtls/libcurl_la-hostcheck.lo
  CC       vtls/libcurl_la-keylog.lo
  CC       vtls/libcurl_la-mbedtls.lo
  CC       vtls/libcurl_la-mbedtls_threadlock.lo
  CC       vtls/libcurl_la-openssl.lo
  CC       vtls/libcurl_la-rustls.lo
  CC       vtls/libcurl_la-schannel.lo
  CC       vtls/libcurl_la-schannel_verify.lo
  CC       vtls/libcurl_la-sectransp.lo
  CC       vtls/libcurl_la-vtls.lo
  CC       vtls/libcurl_la-wolfssl.lo
  CC       vtls/libcurl_la-x509asn1.lo
  CC       vquic/libcurl_la-curl_msh3.lo
  CC       vquic/libcurl_la-curl_ngtcp2.lo
  CC       vquic/libcurl_la-curl_osslq.lo
  CC       vquic/libcurl_la-curl_quiche.lo
  CC       vquic/libcurl_la-vquic.lo
  CC       vquic/libcurl_la-vquic-tls.lo
  CC       vssh/libcurl_la-libssh.lo
  CC       vssh/libcurl_la-libssh2.lo
  CC       vssh/libcurl_la-wolfssh.lo
  CCLD     libcurl.la
make[2]: Leaving directory '/root/asi_db/builds/curl/_worktrees/w0/lib'
make[1]: Leaving directory '/root/asi_db/builds/curl/_worktrees/w0/lib'
Making all in docs
make[1]: Entering directory '/root/asi_db/builds/curl/_worktrees/w0/docs'
Making all in .
make[2]: Entering directory '/root/asi_db/builds/curl/_worktrees/w0/docs'
make[2]: Nothing to be done for 'all-am'.
make[2]: Leaving directory '/root/asi_db/builds/curl/_worktrees/w0/docs'
Making all in cmdline-opts
make[2]: Entering directory '/root/asi_db/builds/curl/_worktrees/w0/docs/cmdline-opts'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/root/asi_db/builds/curl/_worktrees/w0/docs/cmdline-opts'
Making all in libcurl
make[2]: Entering directory '/root/asi_db/builds/curl/_worktrees/w0/docs/libcurl'
Making all in opts
make[3]: Entering directory '/root/asi_db/builds/curl/_worktrees/w0/docs/libcurl/opts'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/root/asi_db/builds/curl/_worktrees/w0/docs/libcurl/opts'
make[3]: Entering directory '/root/asi_db/builds/curl/_worktrees/w0/docs/libcurl'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/root/asi_db/builds/curl/_worktrees/w0/docs/libcurl'
make[2]: Leaving directory '/root/asi_db/builds/curl/_worktrees/w0/docs/libcurl'
make[1]: Leaving directory '/root/asi_db/builds/curl/_worktrees/w0/docs'
Making all in src
make[1]: Entering directory '/root/asi_db/builds/curl/_worktrees/w0/src'
  CC       slist_wc.o
  CC       terminal.o
  CC       tool_binmode.o
  CC       tool_bname.o
  CC       tool_cb_dbg.o
  CC       tool_cb_hdr.o
  CC       tool_cb_prg.o
  CC       tool_cb_rea.o
  CC       tool_cb_see.o
  CC       tool_cb_soc.o
  CC       tool_cb_wrt.o
  CC       tool_cfgable.o
  CC       tool_dirhie.o
  CC       tool_doswin.o
  CC       tool_easysrc.o
  CC       tool_filetime.o
  CC       tool_findfile.o
  CC       tool_formparse.o
  CC       tool_getparam.o
  CC       tool_getpass.o
  CC       tool_help.o
  CC       tool_helpers.o
echo '#include "tool_hugehelp.h"' >> tool_hugehelp.c
  CC       tool_ipfs.o
  CC       tool_libinfo.o
  CC       tool_listhelp.o
  CC       tool_main.o
  CC       tool_msgs.o
  CC       tool_operate.o
  CC       tool_operhlp.o
  CC       tool_paramhlp.o
  CC       tool_parsecfg.o
  CC       tool_progress.o
  CC       tool_setopt.o
  CC       tool_sleep.o
  CC       tool_stderr.o
  CC       tool_strdup.o
  CC       tool_urlglob.o
  CC       tool_util.o
  CC       tool_vms.o
  CC       tool_writeout.o
  CC       tool_writeout_json.o
  CC       tool_xattr.o
  CC       var.o
echo 'extern const void *curl_ca_embed; const void *curl_ca_embed;' > tool_ca_embed.c
  CC       tool_hugehelp.o
  CC       tool_ca_embed.o
  CC       ../lib/base64.o
  CC       ../lib/curl_multibyte.o
  CC       ../lib/dynbuf.o
  CC       ../lib/nonblock.o
  CC       ../lib/strtoofft.o
  CC       ../lib/version_win32.o
  CC       ../lib/timediff.o
  CC       ../lib/warnless.o
  CCLD     curl
make[1]: Leaving directory '/root/asi_db/builds/curl/_worktrees/w0/src'
Making all in scripts
make[1]: Entering directory '/root/asi_db/builds/curl/_worktrees/w0/scripts'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/root/asi_db/builds/curl/_worktrees/w0/scripts'
make[1]: Entering directory '/root/asi_db/builds/curl/_worktrees/w0'
make[1]: Nothing to be done for 'all-am'.
make[1]: Leaving directory '/root/asi_db/builds/curl/_worktrees/w0'

Commit Diff GitHub →

lib/conncache.c+685 -490
@@ -47,202 +47,242 @@
#include "curl_memory.h"
#include "memdebug.h"
-#define HASHKEY_SIZE 128
-static void connc_discard_conn(struct conncache *connc,
- struct Curl_easy *last_data,
+#define CPOOL_IS_LOCKED(c) ((c) && (c)->locked)
+
+#define CPOOL_LOCK(c) \
+ do { \
+ if((c)) { \
+ if(CURL_SHARE_KEEP_CONNECT((c)->share)) \
+ Curl_share_lock(((c)->idata), CURL_LOCK_DATA_CONNECT, \
+ CURL_LOCK_ACCESS_SINGLE); \
+ DEBUGASSERT(!(c)->locked); \
+ (c)->locked = TRUE; \
+ } \
+ } while(0)
+
+#define CPOOL_UNLOCK(c) \
+ do { \
+ if((c)) { \
+ DEBUGASSERT((c)->locked); \
+ (c)->locked = FALSE; \
+ if(CURL_SHARE_KEEP_CONNECT((c)->share)) \
+ Curl_share_unlock((c)->idata, CURL_LOCK_DATA_CONNECT); \
+ } \
+ } while(0)
+
+
+/* A list of connections to the same destinationn. */
+struct cpool_bundle {
+ struct Curl_llist conns; /* connections in the bundle */
+ size_t dest_len; /* total length of destination, including NUL */
+ char *dest[1]; /* destination of bundle, allocated to keep dest_len bytes */
+};
+
+
+static void cpool_discard_conn(struct cpool *cpool,
+ struct Curl_easy *data,
struct connectdata *conn,
bool aborted);
-static void connc_disconnect(struct Curl_easy *data,
- struct connectdata *conn,
- struct conncache *connc,
- bool do_shutdown);
-static void connc_run_conn_shutdown(struct Curl_easy *data,
+static void cpool_close_and_destroy(struct cpool *cpool,
+ struct connectdata *conn,
+ struct Curl_easy *data,
+ bool do_shutdown);
+static void cpool_run_conn_shutdown(struct Curl_easy *data,
struct connectdata *conn,
bool *done);
-static void connc_run_conn_shutdown_handler(struct Curl_easy *data,
+static void cpool_run_conn_shutdown_handler(struct Curl_easy *data,
struct connectdata *conn);
-static CURLMcode connc_update_shutdown_ev(struct Curl_multi *multi,
+static CURLMcode cpool_update_shutdown_ev(struct Curl_multi *multi,
struct Curl_easy *data,
struct connectdata *conn);
-static void connc_shutdown_all(struct conncache *connc, int timeout_ms);
+static void cpool_shutdown_all(struct cpool *cpool,
+ struct Curl_easy *data, int timeout_ms);
+static void cpool_close_and_destroy_all(struct cpool *cpool);
+static struct connectdata *cpool_get_oldest_idle(struct cpool *cpool);
-static CURLcode bundle_create(struct connectbundle **bundlep)
+static struct cpool_bundle *cpool_bundle_create(const char *dest,
+ size_t dest_len)
{
- DEBUGASSERT(*bundlep == NULL);
- *bundlep = malloc(sizeof(struct connectbundle));
- if(!*bundlep)
- return CURLE_OUT_OF_MEMORY;
-
- (*bundlep)->num_connections = 0;
- (*bundlep)->multiuse = BUNDLE_UNKNOWN;
-
- Curl_llist_init(&(*bundlep)->conn_list, NULL);
- return CURLE_OK;
+ struct cpool_bundle *bundle;
+ bundle = calloc(1, sizeof(*bundle) + dest_len);
+ if(!bundle)
+ return NULL;
+ Curl_llist_init(&bundle->conns, NULL);
+ bundle->dest_len = dest_len;
+ memcpy(bundle->dest, dest, dest_len);
+ return bundle;
}
-static void bundle_destroy(struct connectbundle *bundle)
+static void cpool_bundle_destroy(struct cpool_bundle *bundle)
{
+ DEBUGASSERT(!Curl_llist_count(&bundle->conns));
free(bundle);
}
/* Add a connection to a bundle */
-static void bundle_add_conn(struct connectbundle *bundle,
- struct connectdata *conn)
+static void cpool_bundle_add(struct cpool_bundle *bundle,
+ struct connectdata *conn)
{
- Curl_llist_append(&bundle->conn_list, conn, &conn->bundle_node);
- conn->bundle = bundle;
- bundle->num_connections++;
+ DEBUGASSERT(!Curl_node_llist(&conn->cpool_node));
+ Curl_llist_append(&bundle->conns, conn, &conn->cpool_node);
+ conn->bits.in_cpool = TRUE;
}
/* Remove a connection from a bundle */
-static int bundle_remove_conn(struct connectbundle *bundle,
- struct connectdata *conn)
+static void cpool_bundle_remove(struct cpool_bundle *bundle,
+ struct connectdata *conn)
{
- struct Curl_llist_node *curr = Curl_llist_head(&bundle->conn_list);
- while(curr) {
- if(Curl_node_elem(curr) == conn) {
- Curl_node_remove(curr);
- bundle->num_connections--;
- conn->bundle = NULL;
- return 1; /* we removed a handle */
- }
- curr = Curl_node_next(curr);
- }
- DEBUGASSERT(0);
- return 0;
+ (void)bundle;
+ DEBUGASSERT(Curl_node_llist(&conn->cpool_node) == &bundle->conns);
+ Curl_node_remove(&conn->cpool_node);
+ conn->bits.in_cpool = FALSE;
}
-static void free_bundle_hash_entry(void *freethis)
+static void cpool_bundle_free_entry(void *freethis)
{
- struct connectbundle *b = (struct connectbundle *) freethis;
-
- bundle_destroy(b);
+ cpool_bundle_destroy((struct cpool_bundle *)freethis);
}
-int Curl_conncache_init(struct conncache *connc,
- struct Curl_multi *multi, size_t size)
+int Curl_cpool_init(struct cpool *cpool,
+ Curl_cpool_disconnect_cb *disconnect_cb,
+ struct Curl_multi *multi,
+ struct Curl_share *share,
+ size_t size)
{
- Curl_hash_init(&connc->hash, size, Curl_hash_str,
- Curl_str_key_compare, free_bundle_hash_entry);
+ DEBUGASSERT(!!multi != !!share); /* either one */
+ Curl_hash_init(&cpool->dest2bundle, size, Curl_hash_str,
+ Curl_str_key_compare, cpool_bundle_free_entry);
+ Curl_llist_init(&cpool->shutdowns, NULL);
+
+ DEBUGASSERT(disconnect_cb);
+ if(!disconnect_cb)
+ return 1;
/* allocate a new easy handle to use when closing cached connections */
- connc->closure_handle = curl_easy_init();
- if(!connc->closure_handle)
+ cpool->idata = curl_easy_init();
+ if(!cpool->idata)
return 1; /* bad */
- connc->closure_handle->state.internal = true;
+ cpool->idata->state.internal = true;
/* TODO: this is quirky. We need an internal handle for certain
* operations, but we do not add it to the multi (if there is one).
* But we give it the multi so that socket event operations can work.
* Probably better to have an internal handle owned by the multi that
- * can be used for conncache operations. */
- connc->closure_handle->multi = multi;
+ * can be used for cpool operations. */
+ cpool->idata->multi = multi;
#ifdef DEBUGBUILD
if(getenv("CURL_DEBUG"))
- connc->closure_handle->set.verbose = true;
+ cpool->idata->set.verbose = true;
#endif
- connc->closure_handle->state.conn_cache = connc;
- connc->multi = multi;
- Curl_llist_init(&connc->shutdowns.conn_list, NULL);
+ cpool->disconnect_cb = disconnect_cb;
+ cpool->idata->multi = cpool->multi = multi;
+ cpool->idata->share = cpool->share = share;
return 0; /* good */
}
-void Curl_conncache_destroy(struct conncache *connc)
+void Curl_cpool_destroy(struct cpool *cpool)
{
- if(connc) {
- if(connc->closure_handle) {
- connc->closure_handle->multi = NULL;
- Curl_close(&connc->closure_handle);
+ if(cpool) {
+ if(cpool->idata) {
+ cpool_close_and_destroy_all(cpool);
+ /* The internal closure handle is special and we need to
+ * disconnect it from multi/share before closing it down. */
+ cpool->idata->multi = NULL;
+ cpool->idata->share = NULL;
+ Curl_close(&cpool->idata);
}
- Curl_hash_destroy(&connc->hash);
- connc->multi = NULL;
+ Curl_hash_destroy(&cpool->dest2bundle);
+ cpool->multi = NULL;
}
}
-/* creates a key to find a bundle for this connection */
-static void hashkey(struct connectdata *conn, char *buf, size_t len)
+static struct cpool *cpool_get_instance(struct Curl_easy *data)
{
- const char *hostname;
- long port = conn->remote_port;
- DEBUGASSERT(len >= HASHKEY_SIZE);
-#ifndef CURL_DISABLE_PROXY
- if(conn->bits.httpproxy && !conn->bits.tunnel_proxy) {
- hostname = conn->http_proxy.host.name;
- port = conn->primary.remote_port;
+ if(data) {
+ if(CURL_SHARE_KEEP_CONNECT(data->share))
+ return &data->share->cpool;
+ else if(data->multi_easy)
+ return &data->multi_easy->cpool;
+ else if(data->multi)
+ return &data->multi->cpool;
}
- else
-#endif
- if(conn->bits.conn_to_host)
- hostname = conn->conn_to_host.name;
- else
- hostname = conn->host.name;
-
- /* put the numbers first so that the hostname gets cut off if too long */
-#ifdef USE_IPV6
- msnprintf(buf, len, "%u/%ld/%s", conn->scope_id, port, hostname);
-#else
- msnprintf(buf, len, "%ld/%s", port, hostname);
-#endif
- Curl_strntolower(buf, buf, len);
+ return NULL;
}
-/* Returns number of connections currently held in the connection cache.
- Locks/unlocks the cache itself!
-*/
-size_t Curl_conncache_size(struct Curl_easy *data)
+void Curl_cpool_xfer_init(struct Curl_easy *data)
{
- size_t num;
- CONNCACHE_LOCK(data);
- num = data->state.conn_cache->num_conn;
- CONNCACHE_UNLOCK(data);
- return num;
+ struct cpool *cpool = cpool_get_instance(data);
+
+ DEBUGASSERT(cpool);
+ if(cpool) {
+ CPOOL_LOCK(cpool);
+ /* the identifier inside the connection cache */
+ data->id = cpool->next_easy_id++;
+ if(cpool->next_easy_id <= 0)
+ cpool->next_easy_id = 0;
+ data->state.lastconnect_id = -1;
+
+ /* The closure handle only ever has default timeouts set. To improve the
+ state somewhat we clone the timeouts from each added handle so that the
+ closure handle always has the same timeouts as the most recently added
+ easy handle. */
+ cpool->idata->set.timeout = data->set.timeout;
+ cpool->idata->set.server_response_timeout =
+ data->set.server_response_timeout;
+ cpool->idata->set.no_signal = data->set.no_signal;
+
+ CPOOL_UNLOCK(cpool);
+ }
+ else {
+ /* We should not get here, but in a non-debug build, do something */
+ data->id = 0;
+ data->state.lastconnect_id = -1;
+ }
}
-/* Look up the bundle with all the connections to the same host this
- connectdata struct is setup to use.
-
- **NOTE**: When it returns, it holds the connection cache lock! */
-struct connectbundle *
-Curl_conncache_find_bundle(struct Curl_easy *data,
- struct connectdata *conn,
- struct conncache *connc)
+static struct cpool_bundle *cpool_find_bundle(struct cpool *cpool,
+ struct connectdata *conn)
{
- struct connectbundle *bundle = NULL;
- CONNCACHE_LOCK(data);
- if(connc) {
- char key[HASHKEY_SIZE];
- hashkey(conn, key, sizeof(key));
- bundle = Curl_hash_pick(&connc->hash, key, strlen(key));
- }
-
- return bundle;
+ return Curl_hash_pick(&cpool->dest2bundle,
+ conn->destination, conn->destination_len);
}
-static void *connc_add_bundle(struct conncache *connc,
- char *key, struct connectbundle *bundle)
+static struct cpool_bundle *
+cpool_add_bundle(struct cpool *cpool, struct connectdata *conn)
{
- return Curl_hash_add(&connc->hash, key, strlen(key), bundle);
+ struct cpool_bundle *bundle;
+
+ bundle = cpool_bundle_create(conn->destination, conn->destination_len);
+ if(!bundle)
+ return NULL;
+
+ if(!Curl_hash_add(&cpool->dest2bundle,
+ bundle->dest, bundle->dest_len, bundle)) {
+ cpool_bundle_destroy(bundle);
+ return NULL;
+ }
+ return bundle;
}
-static void connc_remove_bundle(struct conncache *connc,
- struct connectbundle *bundle)
+static void cpool_remove_bundle(struct cpool *cpool,
+ struct cpool_bundle *bundle)
{
struct Curl_hash_iterator iter;
struct Curl_hash_element *he;
- if(!connc)
+ if(!cpool)
return;
- Curl_hash_start_iterate(&connc->hash, &iter);
+ Curl_hash_start_iterate(&cpool->dest2bundle, &iter);
he = Curl_hash_next_element(&iter);
while(he) {
if(he->ptr == bundle) {
/* The bundle is destroyed by the hash destructor function,
free_bundle_hash_entry() */
- Curl_hash_delete(&connc->hash, he->key, he->key_len);
+ Curl_hash_delete(&cpool->dest2bundle, he->key, he->key_len);
return;
}
@@ -250,120 +290,164 @@ static void connc_remove_bundle(struct conncache *connc,
}
}
-CURLcode Curl_conncache_add_conn(struct Curl_easy *data)
+static struct connectdata *
+cpool_bundle_get_oldest_idle(struct cpool_bundle *bundle);
+
+int Curl_cpool_check_limits(struct Curl_easy *data,
+ struct connectdata *conn)
{
- CURLcode result = CURLE_OK;
- struct connectbundle *bundle = NULL;
- struct connectdata *conn = data->conn;
- struct conncache *connc = data->state.conn_cache;
- DEBUGASSERT(conn);
+ struct cpool *cpool = cpool_get_instance(data);
+ struct cpool_bundle *bundle;
+ size_t dest_limit = 0;
+ size_t total_limit = 0;
+ int result = CPOOL_LIMIT_OK;
+
+ if(!cpool)
+ return CPOOL_LIMIT_OK;
+
+ if(data && data->multi) {
+ dest_limit = data->multi->max_host_connections;
+ total_limit = data->multi->max_total_connections;
+ }
- /* *find_bundle() locks the connection cache */
- bundle = Curl_conncache_find_bundle(data, conn, data->state.conn_cache);
- if(!bundle) {
- char key[HASHKEY_SIZE];
+ if(!dest_limit && !total_limit)
+ return CPOOL_LIMIT_OK;
+
+ CPOOL_LOCK(cpool);
+ if(dest_limit) {
+ bundle = cpool_find_bundle(cpool, conn);
+ while(bundle && (Curl_llist_count(&bundle->conns) >= dest_limit)) {
+ struct connectdata *oldest_idle = NULL;
+ /* The bundle is full. Extract the oldest connection that may
+ * be removed now, if there is one. */
+ oldest_idle = cpool_bundle_get_oldest_idle(bundle);
+ if(!oldest_idle)
+ break;
+ /* disconnect the old conn and continue */
+ DEBUGF(infof(data, "Discarding connection #%"
+ CURL_FORMAT_CURL_OFF_T " from %zu to reach destination "
+ "limit of %zu", oldest_idle->connection_id,
+ Curl_llist_count(&bundle->conns), dest_limit));
+ Curl_cpool_disconnect(data, oldest_idle, FALSE);
+ }
+ if(bundle && (Curl_llist_count(&bundle->conns) >= dest_limit)) {
+ result = CPOOL_LIMIT_DEST;
+ goto out;
+ }
+ }
- result = bundle_create(&bundle);
- if(result) {
- goto unlock;
+ if(total_limit) {
+ while(cpool->num_conn >= total_limit) {
+ struct connectdata *oldest_idle = cpool_get_oldest_idle(cpool);
+ if(!oldest_idle)
+ break;
+ /* disconnect the old conn and continue */
+ DEBUGF(infof(data, "Discarding connection #%"
+ CURL_FORMAT_CURL_OFF_T " from %zu to reach total "
+ "limit of %zu",
+ oldest_idle->connection_id, cpool->num_conn, total_limit));
+ Curl_cpool_disconnect(data, oldest_idle, FALSE);
+ }
+ if(cpool->num_conn >= total_limit) {
+ result = CPOOL_LIMIT_TOTAL;
+ goto out;
}
+ }
+
+out:
+ CPOOL_UNLOCK(cpool);
+ return result;
+}
- hashkey(conn, key, sizeof(key));
+CURLcode Curl_cpool_add_conn(struct Curl_easy *data,
+ struct connectdata *conn)
+{
+ CURLcode result = CURLE_OK;
+ struct cpool_bundle *bundle = NULL;
+ struct cpool *cpool = cpool_get_instance(data);
+ DEBUGASSERT(conn);
+
+ DEBUGASSERT(cpool);
+ if(!cpool)
+ return CURLE_FAILED_INIT;
- if(!connc_add_bundle(data->state.conn_cache, key, bundle)) {
- bundle_destroy(bundle);
+ CPOOL_LOCK(cpool);
+ bundle = cpool_find_bundle(cpool, conn);
+ if(!bundle) {
+ bundle = cpool_add_bundle(cpool, conn);
+ if(!bundle) {
result = CURLE_OUT_OF_MEMORY;
- goto unlock;
+ goto out;
}
}
- bundle_add_conn(bundle, conn);
- conn->connection_id = connc->next_connection_id++;
- connc->num_conn++;
-
+ cpool_bundle_add(bundle, conn);
+ conn->connection_id = cpool->next_connection_id++;
+ cpool->num_conn++;
DEBUGF(infof(data, "Added connection %" CURL_FORMAT_CURL_OFF_T ". "
"The cache now contains %zu members",
- conn->connection_id, connc->num_conn));
-
-unlock:
- CONNCACHE_UNLOCK(data);
+ conn->connection_id, cpool->num_conn));
+out:
+ CPOOL_UNLOCK(cpool);
return result;
}
-static void connc_remove_conn(struct conncache *connc,
+static void cpool_remove_conn(struct cpool *cpool,
struct connectdata *conn)
{
- struct connectbundle *bundle = conn->bundle;
-
- /* The bundle pointer can be NULL, since this function can be called
- due to a failed connection attempt, before being added to a bundle */
- if(bundle) {
- bundle_remove_conn(bundle, conn);
- if(connc && bundle->num_connections == 0)
- connc_remove_bundle(connc, bundle);
- conn->bundle = NULL; /* removed from it */
- if(connc)
- connc->num_conn--;
+ struct Curl_llist *list = Curl_node_llist(&conn->cpool_node);
+ DEBUGASSERT(cpool);
+ if(list) {
+ /* The connection is certainly in the pool, but where? */
+ struct cpool_bundle *bundle = cpool_find_bundle(cpool, conn);
+ if(bundle && (list == &bundle->conns)) {
+ cpool_bundle_remove(bundle, conn);
+ if(!Curl_llist_count(&bundle->conns))
+ cpool_remove_bundle(cpool, bundle);
+ conn->bits.in_cpool = FALSE;
+ cpool->num_conn--;
+ }
+ else {
+ /* Not in a bundle, already in the shutdown list? */
+ DEBUGASSERT(list == &cpool->shutdowns);
+ }
}
}
-/*
- * Removes the connectdata object from the connection cache, but the transfer
- * still owns this connection.
- *
- * Pass TRUE/FALSE in the 'lock' argument depending on if the parent function
- * already holds the lock or not.
- */
-void Curl_conncache_remove_conn(struct Curl_easy *data,
- struct connectdata *conn, bool lock)
-{
- struct conncache *connc = data->state.conn_cache;
-
- if(lock)
- CONNCACHE_LOCK(data);
- connc_remove_conn(connc, conn);
- if(lock)
- CONNCACHE_UNLOCK(data);
- if(connc)
- DEBUGF(infof(data, "The cache now contains %zu members",
- connc->num_conn));
-}
-
-/* This function iterates the entire connection cache and calls the function
+/* This function iterates the entire connection pool and calls the function
func() with the connection pointer as the first argument and the supplied
'param' argument as the other.
- The conncache lock is still held when the callback is called. It needs it,
+ The cpool lock is still held when the callback is called. It needs it,
so that it can safely continue traversing the lists once the callback
returns.
- Returns 1 if the loop was aborted due to the callback's return code.
+ Returns TRUE if the loop was aborted due to the callback's return code.
Return 0 from func() to continue the loop, return 1 to abort it.
*/
-bool Curl_conncache_foreach(struct Curl_easy *data,
- struct conncache *connc,
- void *param,
- int (*func)(struct Curl_easy *data,
- struct connectdata *conn, void *param))
+static bool cpool_foreach(struct Curl_easy *data,
+ struct cpool *cpool,
+ void *param,
+ int (*func)(struct Curl_easy *data,
+ struct connectdata *conn, void *param))
{
struct Curl_hash_iterator iter;
struct Curl_hash_element *he;
- if(!connc)
+ if(!cpool)
return FALSE;
- CONNCACHE_LOCK(data);
- Curl_hash_start_iterate(&connc->hash, &iter);
+ Curl_hash_start_iterate(&cpool->dest2bundle, &iter);
he = Curl_hash_next_element(&iter);
while(he) {
struct Curl_llist_node *curr;
- struct connectbundle *bundle = he->ptr;
+ struct cpool_bundle *bundle = he->ptr;
he = Curl_hash_next_element(&iter);
- curr = Curl_llist_head(&bundle->conn_list);
+ curr = Curl_llist_head(&bundle->conns);
while(curr) {
/* Yes, we need to update curr before calling func(), because func()
might decide to remove the connection */
@@ -371,104 +455,85 @@ bool Curl_conncache_foreach(struct Curl_easy *data,
curr = Curl_node_next(curr);
if(1 == func(data, conn, param)) {
- CONNCACHE_UNLOCK(data);
return TRUE;
}
}
}
- CONNCACHE_UNLOCK(data);
return FALSE;
}
-/* Return the first connection found in the cache. Used when closing all
- connections.
-
- NOTE: no locking is done here as this is presumably only done when cleaning
- up a cache!
-*/
-static struct connectdata *
-connc_find_first_connection(struct conncache *connc)
+/* Return a live connection in the pool or NULL. */
+static struct connectdata *cpool_get_live_conn(struct cpool *cpool)
{
struct Curl_hash_iterator iter;
struct Curl_hash_element *he;
- struct connectbundle *bundle;
+ struct cpool_bundle *bundle;
+ struct Curl_llist_node *conn_node;
- Curl_hash_start_iterate(&connc->hash, &iter);
-
- he = Curl_hash_next_element(&iter);
- while(he) {
- struct Curl_llist_node *curr;
+ Curl_hash_start_iterate(&cpool->dest2bundle, &iter);
+ for(he = Curl_hash_next_element(&iter); he;
+ he = Curl_hash_next_element(&iter)) {
bundle = he->ptr;
-
- curr = Curl_llist_head(&bundle->conn_list);
- if(curr) {
- return Curl_node_elem(curr);
- }
-
- he = Curl_hash_next_element(&iter);
+ conn_node = Curl_llist_head(&bundle->conns);
+ if(conn_node)
+ return Curl_node_elem(conn_node);
}
-
return NULL;
}
/*
- * Give ownership of a connection back to the connection cache. Might
- * disconnect the oldest existing in there to make space.
+ * A connection (already in the pool) has become idle. Do any
+ * cleanups in regard to the pool's limits.
*
- * Return TRUE if stored, FALSE if closed.
+ * Return TRUE if idle connection kept in pool, FALSE if closed.
*/
-bool Curl_conncache_return_conn(struct Curl_easy *data,
- struct connectdata *conn)
+bool Curl_cpool_conn_now_idle(struct Curl_easy *data,
+ struct connectdata *conn)
{
unsigned int maxconnects = !data->multi->maxconnects ?
data->multi->num_easy * 4: data->multi->maxconnects;
- struct connectdata *conn_candidate = NULL;
+ struct connectdata *oldest_idle = NULL;
+ struct cpool *cpool = cpool_get_instance(data);
+ bool kept = TRUE;
conn->lastused = Curl_now(); /* it was used up until now */
- if(maxconnects && Curl_conncache_size(data) > maxconnects) {
- infof(data, "Connection cache is full, closing the oldest one");
-
- conn_candidate = Curl_conncache_extract_oldest(data);
- if(conn_candidate) {
- /* Use the closure handle for this disconnect so that anything that
- happens during the disconnect is not stored and associated with the
- 'data' handle which already just finished a transfer and it is
- important that details from this (unrelated) disconnect does not
- taint meta-data in the data handle. */
- struct conncache *connc = data->state.conn_cache;
- connc_disconnect(NULL, conn_candidate, connc, TRUE);
+ if(cpool && maxconnects) {
+ /* may be called form a callback already under lock */
+ bool do_lock = !CPOOL_IS_LOCKED(cpool);
+ if(do_lock)
+ CPOOL_LOCK(cpool);
+ if(cpool->num_conn > maxconnects) {
+ infof(data, "Connection pool is full, closing the oldest one");
+
+ oldest_idle = cpool_get_oldest_idle(cpool);
+ kept = (oldest_idle != conn);
+ if(oldest_idle) {
+ Curl_cpool_disconnect(cpool->idata, oldest_idle, FALSE);
+ }
}
+ if(do_lock)
+ CPOOL_UNLOCK(cpool);
}
- return (conn_candidate == conn) ? FALSE : TRUE;
-
+ return kept;
}
/*
* This function finds the connection in the connection bundle that has been
* unused for the longest time.
- *
- * Does not lock the connection cache!
- *
- * Returns the pointer to the oldest idle connection, or NULL if none was
- * found.
*/
-struct connectdata *
-Curl_conncache_extract_bundle(struct Curl_easy *data,
- struct connectbundle *bundle)
+static struct connectdata *
+cpool_bundle_get_oldest_idle(struct cpool_bundle *bundle)
{
struct Curl_llist_node *curr;
timediff_t highscore = -1;
timediff_t score;
struct curltime now;
- struct connectdata *conn_candidate = NULL;
+ struct connectdata *oldest_idle = NULL;
struct connectdata *conn;
- (void)data;
-
now = Curl_now();
-
- curr = Curl_llist_head(&bundle->conn_list);
+ curr = Curl_llist_head(&bundle->conns);
while(curr) {
conn = Curl_node_elem(curr);
@@ -478,130 +543,126 @@ Curl_conncache_extract_bundle(struct Curl_easy *data,
if(score > highscore) {
highscore = score;
- conn_candidate = conn;
+ oldest_idle = conn;
}
}
curr = Curl_node_next(curr);
}
- if(conn_candidate) {
- /* remove it to prevent another thread from nicking it */
- bundle_remove_conn(bundle, conn_candidate);
- data->state.conn_cache->num_conn--;
- DEBUGF(infof(data, "The cache now contains %zu members",
- data->state.conn_cache->num_conn));
- }
-
- return conn_candidate;
+ return oldest_idle;
}
-/*
- * This function finds the connection in the connection cache that has been
- * unused for the longest time and extracts that from the bundle.
- *
- * Returns the pointer to the connection, or NULL if none was found.
- */
-struct connectdata *
-Curl_conncache_extract_oldest(struct Curl_easy *data)
+static struct connectdata *cpool_get_oldest_idle(struct cpool *cpool)
{
- struct conncache *connc = data->state.conn_cache;
struct Curl_hash_iterator iter;
struct Curl_llist_node *curr;
struct Curl_hash_element *he;
+ struct connectdata *oldest_idle = NULL;
+ struct cpool_bundle *bundle;
+ struct curltime now;
timediff_t highscore =- 1;
timediff_t score;
- struct curltime now;
- struct connectdata *conn_candidate = NULL;
- struct connectbundle *bundle;
- struct connectbundle *bundle_candidate = NULL;
now = Curl_now();
+ Curl_hash_start_iterate(&cpool->dest2bundle, &iter);
- CONNCACHE_LOCK(data);
- Curl_hash_start_iterate(&connc->hash, &iter);
-
- he = Curl_hash_next_element(&iter);
- while(he) {
+ for(he = Curl_hash_next_element(&iter); he;
+ he = Curl_hash_next_element(&iter)) {
struct connectdata *conn;
-
bundle = he->ptr;
- curr = Curl_llist_head(&bundle->conn_list);
- while(curr) {
+ for(curr = Curl_llist_head(&bundle->conns); curr;
+ curr = Curl_node_next(curr)) {
conn = Curl_node_elem(curr);
+ if(CONN_INUSE(conn) || conn->bits.close || conn->connect_only)
+ continue;
+ /* Set higher score for the age passed since the connection was used */
+ score = Curl_timediff(now, conn->lastused);
+ if(score > highscore) {
+ highscore = score;
+ oldest_idle = conn;
+ }
+ }
+ }
+ return oldest_idle;
+}
- if(!CONN_INUSE(conn) && !conn->bits.close &&
- !conn->connect_only) {
- /* Set higher score for the age passed since the connection was used */
- score = Curl_timediff(now, conn->lastused);
+bool Curl_cpool_find(struct Curl_easy *data,
+ const char *destination, size_t dest_len,
+ Curl_cpool_conn_match_cb *conn_cb,
+ Curl_cpool_done_match_cb *done_cb,
+ void *userdata)
+{
+ struct cpool *cpool = cpool_get_instance(data);
+ struct cpool_bundle *bundle;
+ bool result = FALSE;
- if(score > highscore) {
- highscore = score;
- conn_candidate = conn;
- bundle_candidate = bundle;
- }
- }
+ DEBUGASSERT(cpool);
+ DEBUGASSERT(conn_cb);
+ if(!cpool)
+ return FALSE;
+
+ CPOOL_LOCK(cpool);
+ bundle = Curl_hash_pick(&cpool->dest2bundle, (void *)destination, dest_len);
+ if(bundle) {
+ struct Curl_llist_node *curr = Curl_llist_head(&bundle->conns);
+ while(curr) {
+ struct connectdata *conn = Curl_node_elem(curr);
+ /* Get next node now. callback might discard current */
curr = Curl_node_next(curr);
- }
- he = Curl_hash_next_element(&iter);
- }
- if(conn_candidate) {
- /* remove it to prevent another thread from nicking it */
- bundle_remove_conn(bundle_candidate, conn_candidate);
- connc->num_conn--;
- DEBUGF(infof(data, "The cache now contains %zu members",
- connc->num_conn));
+ if(conn_cb(conn, userdata)) {
+ result = TRUE;
+ break;
+ }
+ }
}
- CONNCACHE_UNLOCK(data);
- return conn_candidate;
+ if(done_cb) {
+ result = done_cb(result, userdata);
+ }
+ CPOOL_UNLOCK(cpool);
+ return result;
}
-static void connc_shutdown_discard_all(struct conncache *connc)
+static void cpool_shutdown_discard_all(struct cpool *cpool)
{
- struct Curl_llist_node *e = Curl_llist_head(&connc->shutdowns.conn_list);
+ struct Curl_llist_node *e = Curl_llist_head(&cpool->shutdowns);
struct connectdata *conn;
if(!e)
return;
- DEBUGF(infof(connc->closure_handle, "conncache_shutdown_discard_all"));
- DEBUGASSERT(!connc->shutdowns.iter_locked);
- connc->shutdowns.iter_locked = TRUE;
+ DEBUGF(infof(cpool->idata, "cpool_shutdown_discard_all"));
while(e) {
conn = Curl_node_elem(e);
Curl_node_remove(e);
- DEBUGF(infof(connc->closure_handle, "discard connection #%"
+ DEBUGF(infof(cpool->idata, "discard connection #%"
CURL_FORMAT_CURL_OFF_T, conn->connection_id));
- connc_disconnect(NULL, conn, connc, FALSE);
- e = Curl_llist_head(&connc->shutdowns.conn_list);
+ cpool_close_and_destroy(cpool, conn, NULL, FALSE);
+ e = Curl_llist_head(&cpool->shutdowns);
}
- connc->shutdowns.iter_locked = FALSE;
}
-static void connc_close_all(struct conncache *connc)
+static void cpool_close_and_destroy_all(struct cpool *cpool)
{
- struct Curl_easy *data = connc->closure_handle;
struct connectdata *conn;
int timeout_ms = 0;
SIGPIPE_VARIABLE(pipe_st);
- if(!data)
- return;
-
+ DEBUGASSERT(cpool);
/* Move all connections to the shutdown list */
sigpipe_init(&pipe_st);
- conn = connc_find_first_connection(connc);
+ CPOOL_LOCK(cpool);
+ conn = cpool_get_live_conn(cpool);
while(conn) {
- connc_remove_conn(connc, conn);
- sigpipe_apply(data, &pipe_st);
- /* This will remove the connection from the cache */
+ cpool_remove_conn(cpool, conn);
+ sigpipe_apply(cpool->idata, &pipe_st);
connclose(conn, "kill all");
- Curl_conncache_remove_conn(connc->closure_handle, conn, TRUE);
- connc_discard_conn(connc, connc->closure_handle, conn, FALSE);
+ cpool_discard_conn(cpool, cpool->idata, conn, FALSE);
- conn = connc_find_first_connection(connc);
+ conn = cpool_get_live_conn(cpool);
}
+ CPOOL_UNLOCK(cpool);
/* Just for testing, run graceful shutdown */
#ifdef DEBUGBUILD
@@ -614,65 +675,44 @@ static void connc_close_all(struct conncache *connc)
}
}
#endif
- connc_shutdown_all(connc, timeout_ms);
+ sigpipe_apply(cpool->idata, &pipe_st);
+ cpool_shutdown_all(cpool, cpool->idata, timeout_ms);
/* discard all connections in the shutdown list */
- connc_shutdown_discard_all(connc);
+ cpool_shutdown_discard_all(cpool);
- sigpipe_apply(data, &pipe_st);
- Curl_hostcache_clean(data, data->dns.hostcache);
- connc->closure_handle->multi = NULL;
- Curl_close(&connc->closure_handle);
+ Curl_hostcache_clean(cpool->idata, cpool->idata->dns.hostcache);
sigpipe_restore(&pipe_st);
}
-void Curl_conncache_close_all_connections(struct conncache *connc)
-{
- connc_close_all(connc);
-}
-static void connc_shutdown_discard_oldest(struct conncache *connc)
+static void cpool_shutdown_destroy_oldest(struct cpool *cpool)
{
struct Curl_llist_node *e;
struct connectdata *conn;
- DEBUGASSERT(!connc->shutdowns.iter_locked);
- if(connc->shutdowns.iter_locked)
- return;
-
- e = Curl_llist_head(&connc->shutdowns.conn_list);
+ e = Curl_llist_head(&cpool->shutdowns);
if(e) {
SIGPIPE_VARIABLE(pipe_st);
conn = Curl_node_elem(e);
Curl_node_remove(e);
sigpipe_init(&pipe_st);
- sigpipe_apply(connc->closure_handle, &pipe_st);
- connc_disconnect(NULL, conn, connc, FALSE);
+ sigpipe_apply(cpool->idata, &pipe_st);
+ cpool_close_and_destroy(cpool, conn, NULL, FALSE);
sigpipe_restore(&pipe_st);
}
}
-static void connc_discard_conn(struct conncache *connc,
- struct Curl_easy *last_data,
+static void cpool_discard_conn(struct cpool *cpool,
+ struct Curl_easy *data,
struct connectdata *conn,
bool aborted)
{
- /* `last_data`, if present, is the transfer that last worked with
- * the connection. It is present when the connection is being shut down
- * via `Curl_conncache_discard_conn()`, e.g. when the transfer failed
- * or does not allow connection reuse.
- * Using the original handle is necessary for shutting down the protocol
- * handler belonging to the connection. Protocols like 'file:' rely on
- * being invoked to clean up their allocations in the easy handle.
- * When a connection comes from the cache, the transfer is no longer
- * there and we use the cache is own closure handle.
- */
- struct Curl_easy *data = last_data? last_data : connc->closure_handle;
bool done = FALSE;
DEBUGASSERT(data);
- DEBUGASSERT(connc);
- DEBUGASSERT(!conn->bundle);
+ DEBUGASSERT(cpool);
+ DEBUGASSERT(!conn->bits.in_cpool);
/*
* If this connection is not marked to force-close, leave it open if there
@@ -701,22 +741,14 @@ static void connc_discard_conn(struct conncache *connc,
if(!done) {
/* Attempt to shutdown the connection right away. */
Curl_attach_connection(data, conn);
- connc_run_conn_shutdown(data, conn, &done);
+ cpool_run_conn_shutdown(data, conn, &done);
DEBUGF(infof(data, "[CCACHE] shutdown #%" CURL_FORMAT_CURL_OFF_T
", done=%d",conn->connection_id, done));
Curl_detach_connection(data);
}
if(done) {
- connc_disconnect(data, conn, connc, FALSE);
- return;
- }
-
- DEBUGASSERT(!connc->shutdowns.iter_locked);
- if(connc->shutdowns.iter_locked) {
- DEBUGF(infof(data, "[CCACHE] discarding #%" CURL_FORMAT_CURL_OFF_T
- ", list locked", conn->connection_id));
- connc_disconnect(data, conn, connc, FALSE);
+ cpool_close_and_destroy(cpool, conn, data, FALSE);
return;
}
@@ -724,58 +756,85 @@ static void connc_discard_conn(struct conncache *connc,
* during multi processing. */
if(data->multi && data->multi->max_shutdown_connections > 0 &&
(data->multi->max_shutdown_connections >=
- (long)Curl_llist_count(&connc->shutdowns.conn_list))) {
+ (long)Curl_llist_count(&cpool->shutdowns))) {
DEBUGF(infof(data, "[CCACHE] discarding oldest shutdown connection "
"due to limit of %ld",
data->multi->max_shutdown_connections));
- connc_shutdown_discard_oldest(connc);
+ cpool_shutdown_destroy_oldest(cpool);
}
if(data->multi && data->multi->socket_cb) {
- DEBUGASSERT(connc == &data->multi->conn_cache);
+ DEBUGASSERT(cpool == &data->multi->cpool);
/* Start with an empty shutdown pollset, so out internal closure handle
* is added to the sockets. */
memset(&conn->shutdown_poll, 0, sizeof(conn->shutdown_poll));
- if(connc_update_shutdown_ev(data->multi, connc->closure_handle, conn)) {
+ if(cpool_update_shutdown_ev(data->multi, cpool->idata, conn)) {
DEBUGF(infof(data, "[CCACHE] update events for shutdown failed, "
"discarding #%" CURL_FORMAT_CURL_OFF_T,
conn->connection_id));
- connc_disconnect(data, conn, connc, FALSE);
+ cpool_close_and_destroy(cpool, conn, data, FALSE);
return;
}
}
- Curl_llist_append(&connc->shutdowns.conn_list, conn, &conn->bundle_node);
+ Curl_llist_append(&cpool->shutdowns, conn, &conn->cpool_node);
DEBUGF(infof(data, "[CCACHE] added #%" CURL_FORMAT_CURL_OFF_T
" to shutdown list of length %zu", conn->connection_id,
- Curl_llist_count(&connc->shutdowns.conn_list)));
+ Curl_llist_count(&cpool->shutdowns)));
}
-void Curl_conncache_disconnect(struct Curl_easy *data,
- struct connectdata *conn,
- bool aborted)
+void Curl_cpool_disconnect(struct Curl_easy *data,
+ struct connectdata *conn,
+ bool aborted)
{
- DEBUGASSERT(data);
- /* Connection must no longer be in and connection cache */
- DEBUGASSERT(!conn->bundle);
+ struct cpool *cpool = cpool_get_instance(data);
+ bool do_lock;
+
+ DEBUGASSERT(cpool);
+ DEBUGASSERT(data && !data->conn);
+ if(!cpool)
+ return;
+
+ /* If this connection is not marked to force-close, leave it open if there
+ * are other users of it */
+ if(CONN_INUSE(conn) && !aborted) {
+ DEBUGASSERT(0); /* does this ever happen? */
+ DEBUGF(infof(data, "Curl_disconnect when inuse: %zu", CONN_INUSE(conn)));
+ return;
+ }
+
+ /* This method may be called while we are under lock, e.g. from a
+ * user callback in find. */
+ do_lock = !CPOOL_IS_LOCKED(cpool);
+ if(do_lock)
+ CPOOL_LOCK(cpool);
+
+ if(conn->bits.in_cpool) {
+ cpool_remove_conn(cpool, conn);
+ DEBUGASSERT(!conn->bits.in_cpool);
+ }
+
+ /* Run the callback to let it clean up anything it wants to. */
+ aborted = cpool->disconnect_cb(data, conn, aborted);
if(data->multi) {
- /* Add it to the multi's conncache for shutdown handling */
+ /* Add it to the multi's cpool for shutdown handling */
infof(data, "%s connection #%" CURL_FORMAT_CURL_OFF_T,
aborted? "closing" : "shutting down", conn->connection_id);
- connc_discard_conn(&data->multi->conn_cache, data, conn, aborted);
+ cpool_discard_conn(&data->multi->cpool, data, conn, aborted);
}
else {
/* No multi available. Make a best-effort shutdown + close */
infof(data, "closing connection #%" CURL_FORMAT_CURL_OFF_T,
conn->connection_id);
- DEBUGASSERT(!conn->bundle);
- connc_run_conn_shutdown_handler(data, conn);
- connc_disconnect(data, conn, NULL, !aborted);
+ cpool_close_and_destroy(NULL, conn, data, !aborted);
}
+
+ if(do_lock)
+ CPOOL_UNLOCK(cpool);
}
-static void connc_run_conn_shutdown_handler(struct Curl_easy *data,
+static void cpool_run_conn_shutdown_handler(struct Curl_easy *data,
struct connectdata *conn)
{
if(!conn->bits.shutdown_handler) {
@@ -793,6 +852,7 @@ static void connc_run_conn_shutdown_handler(struct Curl_easy *data,
DEBUGF(infof(data, "connection #%" CURL_FORMAT_CURL_OFF_T
", shutdown protocol handler (aborted=%d)",
conn->connection_id, conn->bits.aborted));
+
conn->handler->disconnect(data, conn, conn->bits.aborted);
}
@@ -803,7 +863,7 @@ static void connc_run_conn_shutdown_handler(struct Curl_easy *data,
}
}
-static void connc_run_conn_shutdown(struct Curl_easy *data,
+static void cpool_run_conn_shutdown(struct Curl_easy *data,
struct connectdata *conn,
bool *done)
{
@@ -813,7 +873,7 @@ static void connc_run_conn_shutdown(struct Curl_easy *data,
/* We expect to be attached when called */
DEBUGASSERT(data->conn == conn);
- connc_run_conn_shutdown_handler(data, conn);
+ cpool_run_conn_shutdown_handler(data, conn);
if(conn->bits.shutdown_filters) {
*done = TRUE;
@@ -840,25 +900,23 @@ static void connc_run_conn_shutdown(struct Curl_easy *data,
conn->bits.shutdown_filters = TRUE;
}
-CURLcode Curl_conncache_add_pollfds(struct conncache *connc,
- struct curl_pollfds *cpfds)
+static CURLcode cpool_add_pollfds(struct cpool *cpool,
+ struct curl_pollfds *cpfds)
{
CURLcode result = CURLE_OK;
- DEBUGASSERT(!connc->shutdowns.iter_locked);
- connc->shutdowns.iter_locked = TRUE;
- if(Curl_llist_head(&connc->shutdowns.conn_list)) {
+ if(Curl_llist_head(&cpool->shutdowns)) {
struct Curl_llist_node *e;
struct easy_pollset ps;
struct connectdata *conn;
- for(e = Curl_llist_head(&connc->shutdowns.conn_list); e;
+ for(e = Curl_llist_head(&cpool->shutdowns); e;
e = Curl_node_next(e)) {
conn = Curl_node_elem(e);
memset(&ps, 0, sizeof(ps));
- Curl_attach_connection(connc->closure_handle, conn);
- Curl_conn_adjust_pollset(connc->closure_handle, &ps);
- Curl_detach_connection(connc->closure_handle);
+ Curl_attach_connection(cpool->idata, conn);
+ Curl_conn_adjust_pollset(cpool->idata, &ps);
+ Curl_detach_connection(cpool->idata);
result = Curl_pollfds_add_ps(cpfds, &ps);
if(result) {
@@ -868,29 +926,37 @@ CURLcode Curl_conncache_add_pollfds(struct conncache *connc,
}
}
out:
- connc->shutdowns.iter_locked = FALSE;
return result;
}
-CURLcode Curl_conncache_add_waitfds(struct conncache *connc,
- struct curl_waitfds *cwfds)
+CURLcode Curl_cpool_add_pollfds(struct cpool *cpool,
+ struct curl_pollfds *cpfds)
+{
+ CURLcode result;
+ CPOOL_LOCK(cpool);
+ result = cpool_add_pollfds(cpool, cpfds);
+ CPOOL_UNLOCK(cpool);
+ return result;
+}
+
+CURLcode Curl_cpool_add_waitfds(struct cpool *cpool,
+ struct curl_waitfds *cwfds)
{
CURLcode result = CURLE_OK;
- DEBUGASSERT(!connc->shutdowns.iter_locked);
- connc->shutdowns.iter_locked = TRUE;
- if(Curl_llist_head(&connc->shutdowns.conn_list)) {
+ CPOOL_LOCK(cpool);
+ if(Curl_llist_head(&cpool->shutdowns)) {
struct Curl_llist_node *e;
struct easy_pollset ps;
struct connectdata *conn;
- for(e = Curl_llist_head(&connc->shutdowns.conn_list); e;
+ for(e = Curl_llist_head(&cpool->shutdowns); e;
e = Curl_node_next(e)) {
conn = Curl_node_elem(e);
memset(&ps, 0, sizeof(ps));
- Curl_attach_connection(connc->closure_handle, conn);
- Curl_conn_adjust_pollset(connc->closure_handle, &ps);
- Curl_detach_connection(connc->closure_handle);
+ Curl_attach_connection(cpool->idata, conn);
+ Curl_conn_adjust_pollset(cpool->idata, &ps);
+ Curl_detach_connection(cpool->idata);
result = Curl_waitfds_add_ps(cwfds, &ps);
if(result)
@@ -898,14 +964,14 @@ CURLcode Curl_conncache_add_waitfds(struct conncache *connc,
}
}
out:
- connc->shutdowns.iter_locked = FALSE;
+ CPOOL_UNLOCK(cpool);
return result;
}
-static void connc_perform(struct conncache *connc)
+static void cpool_perform(struct cpool *cpool)
{
- struct Curl_easy *data = connc->closure_handle;
- struct Curl_llist_node *e = Curl_llist_head(&connc->shutdowns.conn_list);
+ struct Curl_easy *data = cpool->idata;
+ struct Curl_llist_node *e = Curl_llist_head(&cpool->shutdowns);
struct Curl_llist_node *enext;
struct connectdata *conn;
struct curltime *nowp = NULL;
@@ -917,21 +983,19 @@ static void connc_perform(struct conncache *connc)
return;
DEBUGASSERT(data);
- DEBUGASSERT(!connc->shutdowns.iter_locked);
DEBUGF(infof(data, "[CCACHE] perform, %zu connections being shutdown",
- Curl_llist_count(&connc->shutdowns.conn_list)));
- connc->shutdowns.iter_locked = TRUE;
+ Curl_llist_count(&cpool->shutdowns)));
while(e) {
enext = Curl_node_next(e);
conn = Curl_node_elem(e);
Curl_attach_connection(data, conn);
- connc_run_conn_shutdown(data, conn, &done);
+ cpool_run_conn_shutdown(data, conn, &done);
DEBUGF(infof(data, "[CCACHE] shutdown #%" CURL_FORMAT_CURL_OFF_T
", done=%d", conn->connection_id, done));
Curl_detach_connection(data);
if(done) {
Curl_node_remove(e);
- connc_disconnect(NULL, conn, connc, FALSE);
+ cpool_close_and_destroy(cpool, conn, NULL, FALSE);
}
else {
/* Not done, when does this connection time out? */
@@ -945,60 +1009,52 @@ static void connc_perform(struct conncache *connc)
}
e = enext;
}
- connc->shutdowns.iter_locked = FALSE;
if(next_from_now_ms)
Curl_expire(data, next_from_now_ms, EXPIRE_RUN_NOW);
}
-void Curl_conncache_multi_perform(struct Curl_multi *multi)
+void Curl_cpool_multi_perform(struct Curl_multi *multi)
{
- connc_perform(&multi->conn_cache);
+ CPOOL_LOCK(&multi->cpool);
+ cpool_perform(&multi->cpool);
+ CPOOL_UNLOCK(&multi->cpool);
}
/*
- * Disconnects the given connection. Note the connection may not be the
- * primary connection, like when freeing room in the connection cache or
- * killing of a dead old connection.
- *
- * A connection needs an easy handle when closing down. We support this passed
- * in separately since the connection to get closed here is often already
- * disassociated from an easy handle.
- *
- * This function MUST NOT reset state in the Curl_easy struct if that
- * is not strictly bound to the life-time of *this* particular connection.
- *
+ * Close and destroy the connection. Run the shutdown sequence once,
+ * of so requested.
*/
-static void connc_disconnect(struct Curl_easy *data,
- struct connectdata *conn,
- struct conncache *connc,
- bool do_shutdown)
+static void cpool_close_and_destroy(struct cpool *cpool,
+ struct connectdata *conn,
+ struct Curl_easy *data,
+ bool do_shutdown)
{
bool done;
/* there must be a connection to close */
DEBUGASSERT(conn);
- /* it must be removed from the connection cache */
- DEBUGASSERT(!conn->bundle);
+ /* it must be removed from the connection pool */
+ DEBUGASSERT(!conn->bits.in_cpool);
/* there must be an associated transfer */
- DEBUGASSERT(data || connc);
+ DEBUGASSERT(data || cpool);
if(!data)
- data = connc->closure_handle;
+ data = cpool->idata;
/* the transfer must be detached from the connection */
DEBUGASSERT(data && !data->conn);
Curl_attach_connection(data, conn);
- connc_run_conn_shutdown_handler(data, conn);
+ cpool_run_conn_shutdown_handler(data, conn);
if(do_shutdown) {
/* Make a last attempt to shutdown handlers and filters, if
* not done so already. */
- connc_run_conn_shutdown(data, conn, &done);
+ cpool_run_conn_shutdown(data, conn, &done);
}
- if(connc)
+ if(cpool)
DEBUGF(infof(data, "[CCACHE] closing #%" CURL_FORMAT_CURL_OFF_T,
conn->connection_id));
else
@@ -1012,7 +1068,7 @@ static void connc_disconnect(struct Curl_easy *data,
}
-static CURLMcode connc_update_shutdown_ev(struct Curl_multi *multi,
+static CURLMcode cpool_update_shutdown_ev(struct Curl_multi *multi,
struct Curl_easy *data,
struct connectdata *conn)
{
@@ -1035,49 +1091,41 @@ static CURLMcode connc_update_shutdown_ev(struct Curl_multi *multi,
return mresult;
}
-void Curl_conncache_multi_socket(struct Curl_multi *multi,
- curl_socket_t s, int ev_bitmask)
+void Curl_cpool_multi_socket(struct Curl_multi *multi,
+ curl_socket_t s, int ev_bitmask)
{
- struct conncache *connc = &multi->conn_cache;
- struct Curl_easy *data = connc->closure_handle;
- struct Curl_llist_node *e = Curl_llist_head(&connc->shutdowns.conn_list);
+ struct cpool *cpool = &multi->cpool;
+ struct Curl_easy *data = cpool->idata;
+ struct Curl_llist_node *e;
struct connectdata *conn;
bool done;
(void)ev_bitmask;
DEBUGASSERT(multi->socket_cb);
- if(!e)
- return;
-
- connc->shutdowns.iter_locked = TRUE;
+ CPOOL_LOCK(cpool);
+ e = Curl_llist_head(&cpool->shutdowns);
while(e) {
conn = Curl_node_elem(e);
if(s == conn->sock[FIRSTSOCKET] || s == conn->sock[SECONDARYSOCKET]) {
Curl_attach_connection(data, conn);
- connc_run_conn_shutdown(data, conn, &done);
+ cpool_run_conn_shutdown(data, conn, &done);
DEBUGF(infof(data, "[CCACHE] shutdown #%" CURL_FORMAT_CURL_OFF_T
", done=%d", conn->connection_id, done));
Curl_detach_connection(data);
- if(done || connc_update_shutdown_ev(multi, data, conn)) {
+ if(done || cpool_update_shutdown_ev(multi, data, conn)) {
Curl_node_remove(e);
- connc_disconnect(NULL, conn, connc, FALSE);
+ cpool_close_and_destroy(cpool, conn, NULL, FALSE);
}
break;
}
e = Curl_node_next(e);
}
- connc->shutdowns.iter_locked = FALSE;
+ CPOOL_UNLOCK(cpool);
}
-void Curl_conncache_multi_close_all(struct Curl_multi *multi)
-{
- connc_close_all(&multi->conn_cache);
-}
-
-
#define NUM_POLLS_ON_STACK 10
-static CURLcode connc_shutdown_wait(struct conncache *connc, int timeout_ms)
+static CURLcode cpool_shutdown_wait(struct cpool *cpool, int timeout_ms)
{
struct pollfd a_few_on_stack[NUM_POLLS_ON_STACK];
struct curl_pollfds cpfds;
@@ -1085,7 +1133,7 @@ static CURLcode connc_shutdown_wait(struct conncache *connc, int timeout_ms)
Curl_pollfds_init(&cpfds, a_few_on_stack, NUM_POLLS_ON_STACK);
- result = Curl_conncache_add_pollfds(connc, &cpfds);
+ result = cpool_add_pollfds(cpool, &cpfds);
if(result)
goto out;
@@ -1096,9 +1144,9 @@ out:
return result;
}
-static void connc_shutdown_all(struct conncache *connc, int timeout_ms)
+static void cpool_shutdown_all(struct cpool *cpool,
+ struct Curl_easy *data, int timeout_ms)
{
- struct Curl_easy *data = connc->closure_handle;
struct connectdata *conn;
struct curltime started = Curl_now();
@@ -1106,74 +1154,221 @@ static void connc_shutdown_all(struct conncache *connc, int timeout_ms)
return;
(void)data;
- DEBUGF(infof(data, "conncache shutdown all"));
+ DEBUGF(infof(data, "cpool shutdown all"));
/* Move all connections into the shutdown queue */
- conn = connc_find_first_connection(connc);
- while(conn) {
- /* This will remove the connection from the cache */
- DEBUGF(infof(data, "moving connection %" CURL_FORMAT_CURL_OFF_T
+ for(conn = cpool_get_live_conn(cpool); conn;
+ conn = cpool_get_live_conn(cpool)) {
+ /* Move conn from live set to shutdown or destroy right away */
+ DEBUGF(infof(data, "moving connection #%" CURL_FORMAT_CURL_OFF_T
" to shutdown queue", conn->connection_id));
- connc_remove_conn(connc, conn);
- connc_discard_conn(connc, NULL, conn, FALSE);
- conn = connc_find_first_connection(connc);
+ cpool_remove_conn(cpool, conn);
+ cpool_discard_conn(cpool, data, conn, FALSE);
}
- DEBUGASSERT(!connc->shutdowns.iter_locked);
- while(Curl_llist_head(&connc->shutdowns.conn_list)) {
+ while(Curl_llist_head(&cpool->shutdowns)) {
timediff_t timespent;
int remain_ms;
- connc_perform(connc);
+ cpool_perform(cpool);
- if(!Curl_llist_head(&connc->shutdowns.conn_list)) {
- DEBUGF(infof(data, "conncache shutdown ok"));
+ if(!Curl_llist_head(&cpool->shutdowns)) {
+ DEBUGF(infof(data, "cpool shutdown ok"));
break;
}
/* wait for activity, timeout or "nothing" */
timespent = Curl_timediff(Curl_now(), started);
if(timespent >= (timediff_t)timeout_ms) {
- DEBUGF(infof(data, "conncache shutdown %s",
+ DEBUGF(infof(data, "cpool shutdown %s",
(timeout_ms > 0)? "timeout" : "best effort done"));
break;
}
remain_ms = timeout_ms - (int)timespent;
- if(connc_shutdown_wait(connc, remain_ms)) {
- DEBUGF(infof(data, "conncache shutdown all, abort"));
+ if(cpool_shutdown_wait(cpool, remain_ms)) {
+ DEBUGF(infof(data, "cpool shutdown all, abort"));
break;
}
}
- /* Due to errors/timeout, we might come here without being full ydone. */
- connc_shutdown_discard_all(connc);
+ /* Due to errors/timeout, we might come here without being done. */
+ cpool_shutdown_discard_all(cpool);
+}
+
+struct cpool_reaper_ctx {
+ struct curltime now;
+};
+
+static int cpool_reap_dead_cb(struct Curl_easy *data,
+ struct connectdata *conn, void *param)
+{
+ struct cpool_reaper_ctx *rctx = param;
+ if(Curl_conn_seems_dead(conn, data, &rctx->now)) {
+ /* stop the iteration here, pass back the connection that was pruned */
+ Curl_cpool_disconnect(data, conn, FALSE);
+ return 1;
+ }
+ return 0; /* continue iteration */
+}
+
+/*
+ * This function scans the data's connection pool for half-open/dead
+ * connections, closes and removes them.
+ * The cleanup is done at most once per second.
+ *
+ * When called, this transfer has no connection attached.
+ */
+void Curl_cpool_prune_dead(struct Curl_easy *data)
+{
+ struct cpool *cpool = cpool_get_instance(data);
+ struct cpool_reaper_ctx rctx;
+ timediff_t elapsed;
+
+ if(!cpool)
+ return;
+
+ rctx.now = Curl_now();
+ CPOOL_LOCK(cpool);
+ elapsed = Curl_timediff(rctx.now, cpool->last_cleanup);
+
+ if(elapsed >= 1000L) {
+ while(cpool_foreach(data, cpool, &rctx, cpool_reap_dead_cb))
+ ;
+ cpool->last_cleanup = rctx.now;
+ }
+ CPOOL_UNLOCK(cpool);
+}
+
+static int conn_upkeep(struct Curl_easy *data,
+ struct connectdata *conn,
+ void *param)
+{
+ struct curltime *now = param;
+ /* TODO, shall we reap connections that return an error here? */
+ Curl_conn_upkeep(data, conn, now);
+ return 0; /* continue iteration */
+}
+
+CURLcode Curl_cpool_upkeep(void *data)
+{
+ struct cpool *cpool = cpool_get_instance(data);
+ struct curltime now = Curl_now();
+
+ if(!cpool)
+ return CURLE_OK;
+
+ CPOOL_LOCK(cpool);
+ cpool_foreach(data, cpool, &now, conn_upkeep);
+ CPOOL_UNLOCK(cpool);
+ return CURLE_OK;
+}
+
+struct cpool_find_ctx {
+ curl_off_t id;
+ struct connectdata *conn;
+};
+
+static int cpool_find_conn(struct Curl_easy *data,
+ struct connectdata *conn, void *param)
+{
+ struct cpool_find_ctx *fctx = param;
+ (void)data;
+ if(conn->connection_id == fctx->id) {
+ fctx->conn = conn;
+ return 1;
+ }
+ return 0;
+}
+
+struct connectdata *Curl_cpool_get_conn(struct Curl_easy *data,
+ curl_off_t conn_id)
+{
+ struct cpool *cpool = cpool_get_instance(data);
+ struct cpool_find_ctx fctx;
+
+ if(!cpool)
+ return NULL;
+ fctx.id = conn_id;
+ fctx.conn = NULL;
+ CPOOL_LOCK(cpool);
+ cpool_foreach(cpool->idata, cpool, &fctx, cpool_find_conn);
+ CPOOL_UNLOCK(cpool);
+ return fctx.conn;
+}
+
+struct cpool_do_conn_ctx {
+ curl_off_t id;
+ Curl_cpool_conn_do_cb *cb;
+ void *cbdata;
+};
+
+static int cpool_do_conn(struct Curl_easy *data,
+ struct connectdata *conn, void *param)
+{
+ struct cpool_do_conn_ctx *dctx = param;
+ (void)data;
+ if(conn->connection_id == dctx->id) {
+ dctx->cb(conn, data, dctx->cbdata);
+ return 1;
+ }
+ return 0;
+}
+
+void Curl_cpool_do_by_id(struct Curl_easy *data, curl_off_t conn_id,
+ Curl_cpool_conn_do_cb *cb, void *cbdata)
+{
+ struct cpool *cpool = cpool_get_instance(data);
+ struct cpool_do_conn_ctx dctx;
+
+ if(!cpool)
+ return;
+ dctx.id = conn_id;
+ dctx.cb = cb;
+ dctx.cbdata = cbdata;
+ CPOOL_LOCK(cpool);
+ cpool_foreach(data, cpool, &dctx, cpool_do_conn);
+ CPOOL_UNLOCK(cpool);
+}
+
+void Curl_cpool_do_locked(struct Curl_easy *data,
+ struct connectdata *conn,
+ Curl_cpool_conn_do_cb *cb, void *cbdata)
+{
+ struct cpool *cpool = cpool_get_instance(data);
+ if(cpool) {
+ CPOOL_LOCK(cpool);
+ cb(conn, data, cbdata);
+ CPOOL_UNLOCK(cpool);
+ }
+ else
+ cb(conn, data, cbdata);
}
#if 0
-/* Useful for debugging the connection cache */
-void Curl_conncache_print(struct conncache *connc)
+/* Useful for debugging the connection pool */
+void Curl_cpool_print(struct cpool *cpool)
{
struct Curl_hash_iterator iter;
struct Curl_llist_node *curr;
struct Curl_hash_element *he;
- if(!connc)
+ if(!cpool)
return;
fprintf(stderr, "=Bundle cache=\n");
- Curl_hash_start_iterate(connc->hash, &iter);
+ Curl_hash_start_iterate(cpool->dest2bundle, &iter);
he = Curl_hash_next_element(&iter);
while(he) {
- struct connectbundle *bundle;
+ struct cpool_bundle *bundle;
struct connectdata *conn;
bundle = he->ptr;
fprintf(stderr, "%s -", he->key);
- curr = Curl_llist_head(bundle->conn_list);
+ curr = Curl_llist_head(bundle->conns);
while(curr) {
conn = Curl_node_elem(curr);
lib/conncache.h+145 -108
@@ -25,140 +25,177 @@
*
***************************************************************************/
-/*
- * All accesses to struct fields and changing of data in the connection cache
- * and connectbundles must be done with the conncache LOCKED. The cache might
- * be shared.
- */
-
#include <curl/curl.h>
#include "timeval.h"
struct connectdata;
+struct Curl_easy;
struct curl_pollfds;
struct curl_waitfds;
struct Curl_multi;
+struct Curl_share;
-struct connshutdowns {
- struct Curl_llist conn_list; /* The connectdata to shut down */
- BIT(iter_locked); /* TRUE while iterating the list */
-};
-
-struct conncache {
- struct Curl_hash hash;
+/**
+ * Callback invoked when disconnecting connections.
+ * @param data transfer last handling the connection, not attached
+ * @param conn the connection to discard
+ * @param aborted if the connection is being aborted
+ * @return if the connection is being aborted, e.g. should NOT perform
+ * a shutdown and just close.
+ **/
+typedef bool Curl_cpool_disconnect_cb(struct Curl_easy *data,
+ struct connectdata *conn,
+ bool aborted);
+
+struct cpool {
+ /* the pooled connections, bundled per destination */
+ struct Curl_hash dest2bundle;
size_t num_conn;
curl_off_t next_connection_id;
curl_off_t next_easy_id;
struct curltime last_cleanup;
- struct connshutdowns shutdowns;
- /* handle used for closing cached connections */
- struct Curl_easy *closure_handle;
- struct Curl_multi *multi; /* Optional, set if cache belongs to multi */
+ struct Curl_llist shutdowns; /* The connections being shut down */
+ struct Curl_easy *idata; /* internal handle used for discard */
+ struct Curl_multi *multi; /* != NULL iff pool belongs to multi */
+ struct Curl_share *share; /* != NULL iff pool belongs to share */
+ Curl_cpool_disconnect_cb *disconnect_cb;
+ BIT(locked);
};
-#define BUNDLE_NO_MULTIUSE -1
-#define BUNDLE_UNKNOWN 0 /* initial value */
-#define BUNDLE_MULTIPLEX 2
-
-#ifdef DEBUGBUILD
-/* the debug versions of these macros make extra certain that the lock is
- never doubly locked or unlocked */
-#define CONNCACHE_LOCK(x) \
- do { \
- if((x)->share) { \
- Curl_share_lock((x), CURL_LOCK_DATA_CONNECT, \
- CURL_LOCK_ACCESS_SINGLE); \
- DEBUGASSERT(!(x)->state.conncache_lock); \
- (x)->state.conncache_lock = TRUE; \
- } \
- } while(0)
-
-#define CONNCACHE_UNLOCK(x) \
- do { \
- if((x)->share) { \
- DEBUGASSERT((x)->state.conncache_lock); \
- (x)->state.conncache_lock = FALSE; \
- Curl_share_unlock((x), CURL_LOCK_DATA_CONNECT); \
- } \
- } while(0)
-#else
-#define CONNCACHE_LOCK(x) if((x)->share) \
- Curl_share_lock((x), CURL_LOCK_DATA_CONNECT, CURL_LOCK_ACCESS_SINGLE)
-#define CONNCACHE_UNLOCK(x) if((x)->share) \
- Curl_share_unlock((x), CURL_LOCK_DATA_CONNECT)
-#endif
-
-struct connectbundle {
- int multiuse; /* supports multi-use */
- size_t num_connections; /* Number of connections in the bundle */
- struct Curl_llist conn_list; /* The connectdata members of the bundle */
-};
-
-/* Init the cache, pass multi only if cache is owned by it.
+/* Init the pool, pass multi only if pool is owned by it.
* returns 1 on error, 0 is fine.
*/
-int Curl_conncache_init(struct conncache *,
- struct Curl_multi *multi,
- size_t size);
-void Curl_conncache_destroy(struct conncache *connc);
-
-/* return the correct bundle, to a host or a proxy */
-struct connectbundle *Curl_conncache_find_bundle(struct Curl_easy *data,
- struct connectdata *conn,
- struct conncache *connc);
-/* returns number of connections currently held in the connection cache */
-size_t Curl_conncache_size(struct Curl_easy *data);
-
-bool Curl_conncache_return_conn(struct Curl_easy *data,
- struct connectdata *conn);
-CURLcode Curl_conncache_add_conn(struct Curl_easy *data) WARN_UNUSED_RESULT;
-void Curl_conncache_remove_conn(struct Curl_easy *data,
- struct connectdata *conn,
- bool lock);
-bool Curl_conncache_foreach(struct Curl_easy *data,
- struct conncache *connc,
- void *param,
- int (*func)(struct Curl_easy *data,
- struct connectdata *conn,
- void *param));
-
-struct connectdata *
-Curl_conncache_find_first_connection(struct conncache *connc);
-
-struct connectdata *
-Curl_conncache_extract_bundle(struct Curl_easy *data,
- struct connectbundle *bundle);
-struct connectdata *
-Curl_conncache_extract_oldest(struct Curl_easy *data);
-void Curl_conncache_close_all_connections(struct conncache *connc);
-void Curl_conncache_print(struct conncache *connc);
+int Curl_cpool_init(struct cpool *cpool,
+ Curl_cpool_disconnect_cb *disconnect_cb,
+ struct Curl_multi *multi,
+ struct Curl_share *share,
+ size_t size);
+
+/* Destroy all connections and free all members */
+void Curl_cpool_destroy(struct cpool *connc);
+
+/* Init the transfer to be used within its connection pool.
+ * Assigns `data->id`. */
+void Curl_cpool_xfer_init(struct Curl_easy *data);
/**
- * Tear down the connection. If `aborted` is FALSE, the connection
- * will be shut down first before discarding. If the shutdown
- * is not immediately complete, the connection
- * will be placed into the cache is shutdown queue.
+ * Get the connection with the given id from the transfer's pool.
*/
-void Curl_conncache_disconnect(struct Curl_easy *data,
- struct connectdata *conn,
- bool aborted);
+struct connectdata *Curl_cpool_get_conn(struct Curl_easy *data,
+ curl_off_t conn_id);
+
+CURLcode Curl_cpool_add_conn(struct Curl_easy *data,
+ struct connectdata *conn) WARN_UNUSED_RESULT;
/**
- * Add sockets and POLLIN/OUT flags for connections handled by the cache.
+ * Return if the pool has reached its configured limits for adding
+ * the given connection. Will try to discard the oldest, idle
+ * connections to make space.
*/
-CURLcode Curl_conncache_add_pollfds(struct conncache *connc,
- struct curl_pollfds *cpfds);
-CURLcode Curl_conncache_add_waitfds(struct conncache *connc,
- struct curl_waitfds *cwfds);
+#define CPOOL_LIMIT_OK 0
+#define CPOOL_LIMIT_DEST 1
+#define CPOOL_LIMIT_TOTAL 2
+int Curl_cpool_check_limits(struct Curl_easy *data,
+ struct connectdata *conn);
+
+/* Return of conn is suitable. If so, stops iteration. */
+typedef bool Curl_cpool_conn_match_cb(struct connectdata *conn,
+ void *userdata);
+
+/* Act on the result of the find, may override it. */
+typedef bool Curl_cpool_done_match_cb(bool result, void *userdata);
+
+/**
+ * Find a connection in the pool matching `destination`.
+ * All callbacks are invoked while the pool's lock is held.
+ * @param data current transfer
+ * @param destination match agaonst `conn->destination` in pool
+ * @param dest_len destination length, including terminating NUL
+ * @param conn_cb must be present, called for each connection in the
+ * bundle until it returns TRUE
+ * @param result_cb if not NULL, is called at the end with the result
+ * of the `conn_cb` or FALSE if never called.
+ * @return combined result of last conn_db and result_cb or FALSE if no
+ connections were present.
+ */
+bool Curl_cpool_find(struct Curl_easy *data,
+ const char *destination, size_t dest_len,
+ Curl_cpool_conn_match_cb *conn_cb,
+ Curl_cpool_done_match_cb *done_cb,
+ void *userdata);
+
+/*
+ * A connection (already in the pool) is now idle. Do any
+ * cleanups in regard to the pool's limits.
+ *
+ * Return TRUE if idle connection kept in pool, FALSE if closed.
+ */
+bool Curl_cpool_conn_now_idle(struct Curl_easy *data,
+ struct connectdata *conn);
/**
- * Perform maintenance on connections in the cache. Specifically,
+ * Remove the connection from the pool and tear it down.
+ * If `aborted` is FALSE, the connection will be shut down first
+ * before closing and destroying it.
+ * If the shutdown is not immediately complete, the connection
+ * will be placed into the pool's shutdown queue.
+ */
+void Curl_cpool_disconnect(struct Curl_easy *data,
+ struct connectdata *conn,
+ bool aborted);
+
+/**
+ * This function scans the data's connection pool for half-open/dead
+ * connections, closes and removes them.
+ * The cleanup is done at most once per second.
+ *
+ * When called, this transfer has no connection attached.
+ */
+void Curl_cpool_prune_dead(struct Curl_easy *data);
+
+/**
+ * Perform upkeep actions on connections in the transfer's pool.
+ */
+CURLcode Curl_cpool_upkeep(void *data);
+
+typedef void Curl_cpool_conn_do_cb(struct connectdata *conn,
+ struct Curl_easy *data,
+ void *cbdata);
+
+/**
+ * Invoke the callback on the pool's connection with the
+ * given connection id (if it exists).
+ */
+void Curl_cpool_do_by_id(struct Curl_easy *data,
+ curl_off_t conn_id,
+ Curl_cpool_conn_do_cb *cb, void *cbdata);
+
+/**
+ * Invoked the callback for the given data + connection under the
+ * connection pool's lock.
+ * The callback is always invoked, even if the transfer has no connection
+ * pool associated.
+ */
+void Curl_cpool_do_locked(struct Curl_easy *data,
+ struct connectdata *conn,
+ Curl_cpool_conn_do_cb *cb, void *cbdata);
+
+/**
+ * Add sockets and POLLIN/OUT flags for connections handled by the pool.
+ */
+CURLcode Curl_cpool_add_pollfds(struct cpool *connc,
+ struct curl_pollfds *cpfds);
+CURLcode Curl_cpool_add_waitfds(struct cpool *connc,
+ struct curl_waitfds *cwfds);
+
+/**
+ * Perform maintenance on connections in the pool. Specifically,
* progress the shutdown of connections in the queue.
*/
-void Curl_conncache_multi_perform(struct Curl_multi *multi);
+void Curl_cpool_multi_perform(struct Curl_multi *multi);
+
+void Curl_cpool_multi_socket(struct Curl_multi *multi,
+ curl_socket_t s, int ev_bitmask);
-void Curl_conncache_multi_socket(struct Curl_multi *multi,
- curl_socket_t s, int ev_bitmask);
-void Curl_conncache_multi_close_all(struct Curl_multi *multi);
#endif /* HEADER_CURL_CONNCACHE_H */
lib/connect.c+7 -35
@@ -312,23 +312,6 @@ bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen,
return FALSE;
}
-struct connfind {
- curl_off_t id_tofind;
- struct connectdata *found;
-};
-
-static int conn_is_conn(struct Curl_easy *data,
- struct connectdata *conn, void *param)
-{
- struct connfind *f = (struct connfind *)param;
- (void)data;
- if(conn->connection_id == f->id_tofind) {
- f->found = conn;
- return 1;
- }
- return 0;
-}
-
/*
* Used to extract socket and connectdata struct for the most recent
* transfer on the given Curl_easy.
@@ -345,30 +328,19 @@ curl_socket_t Curl_getconnectinfo(struct Curl_easy *data,
* - that is associated with a multi handle, and whose connection
* was detached with CURLOPT_CONNECT_ONLY
*/
- if((data->state.lastconnect_id != -1) && (data->multi_easy || data->multi)) {
- struct connectdata *c;
- struct connfind find;
- find.id_tofind = data->state.lastconnect_id;
- find.found = NULL;
-
- Curl_conncache_foreach(data,
- data->share && (data->share->specifier
- & (1<< CURL_LOCK_DATA_CONNECT))?
- &data->share->conn_cache:
- data->multi_easy?
- &data->multi_easy->conn_cache:
- &data->multi->conn_cache, &find, conn_is_conn);
-
- if(!find.found) {
+ if(data->state.lastconnect_id != -1) {
+ struct connectdata *conn;
+
+ conn = Curl_cpool_get_conn(data, data->state.lastconnect_id);
+ if(!conn) {
data->state.lastconnect_id = -1;
return CURL_SOCKET_BAD;
}
- c = find.found;
if(connp)
/* only store this if the caller cares for it */
- *connp = c;
- return c->sock[FIRSTSOCKET];
+ *connp = conn;
+ return conn->sock[FIRSTSOCKET];
}
return CURL_SOCKET_BAD;
}
lib/easy.c+3 -65
@@ -940,8 +940,7 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data)
Curl_dyn_init(&outcurl->state.headerb, CURL_MAX_HTTP_HEADER);
- /* the connection cache is setup on demand */
- outcurl->state.conn_cache = NULL;
+ /* the connection pool is setup on demand */
outcurl->state.lastconnect_id = -1;
outcurl->state.recent_conn_id = -1;
outcurl->id = -1;
@@ -1317,54 +1316,11 @@ CURLcode curl_easy_send(struct Curl_easy *data, const void *buffer,
return result;
}
-/*
- * Wrapper to call functions in Curl_conncache_foreach()
- *
- * Returns always 0.
- */
-static int conn_upkeep(struct Curl_easy *data,
- struct connectdata *conn,
- void *param)
-{
- struct curltime *now = param;
-
- if(Curl_timediff(*now, conn->keepalive) <= data->set.upkeep_interval_ms)
- return 0;
-
- /* briefly attach for action */
- Curl_attach_connection(data, conn);
- if(conn->handler->connection_check) {
- /* Do a protocol-specific keepalive check on the connection. */
- conn->handler->connection_check(data, conn, CONNCHECK_KEEPALIVE);
- }
- else {
- /* Do the generic action on the FIRSTSOCKET filter chain */
- Curl_conn_keep_alive(data, conn, FIRSTSOCKET);
- }
- Curl_detach_connection(data);
-
- conn->keepalive = *now;
- return 0; /* continue iteration */
-}
-
-static CURLcode upkeep(struct conncache *conn_cache, void *data)
-{
- struct curltime now = Curl_now();
- /* Loop over every connection and make connection alive. */
- Curl_conncache_foreach(data,
- conn_cache,
- &now,
- conn_upkeep);
- return CURLE_OK;
-}
-
/*
* Performs connection upkeep for the given session handle.
*/
CURLcode curl_easy_upkeep(struct Curl_easy *data)
{
- struct conncache *conn_cache;
-
/* Verify that we got an easy handle we can work with. */
if(!GOOD_EASY_HANDLE(data))
return CURLE_BAD_FUNCTION_ARGUMENT;
@@ -1372,24 +1328,6 @@ CURLcode curl_easy_upkeep(struct Curl_easy *data)
if(Curl_is_in_callback(data))
return CURLE_RECURSIVE_API_CALL;
- /* determine the connection cache that will next be used by the easy handle.
- if the easy handle is currently in a multi then data->state.conn_cache
- should point to the in-use cache. */
- DEBUGASSERT(!data->multi || data->state.conn_cache);
- conn_cache =
- data->state.conn_cache ?
- data->state.conn_cache :
- (data->share && (data->share->specifier & (1<< CURL_LOCK_DATA_CONNECT))) ?
- &data->share->conn_cache :
- data->multi_easy ?
- &data->multi_easy->conn_cache : NULL;
-
- if(conn_cache) {
- /* Use the common function to keep connections alive. */
- return upkeep(conn_cache, data);
- }
- else {
- /* No connections, so just return success */
- return CURLE_OK;
- }
+ /* Use the common function to keep connections alive. */
+ return Curl_cpool_upkeep(data);
}
lib/hostip.c+1 -2
@@ -1449,8 +1449,7 @@ CURLcode Curl_once_resolved(struct Curl_easy *data, bool *protocol_done)
if(result) {
Curl_detach_connection(data);
- Curl_conncache_remove_conn(data, conn, TRUE);
- Curl_disconnect(data, conn, TRUE);
+ Curl_cpool_disconnect(data, conn, TRUE);
}
return result;
}
lib/http.c+0 -6
@@ -3241,9 +3241,6 @@ CURLcode Curl_http_statusline(struct Curl_easy *data,
else if(k->httpversion == 20 ||
(k->upgr101 == UPGR101_H2 && k->httpcode == 101)) {
DEBUGF(infof(data, "HTTP/2 found, allow multiplexing"));
- /* HTTP/2 cannot avoid multiplexing since it is a core functionality
- of the protocol */
- conn->bundle->multiuse = BUNDLE_MULTIPLEX;
}
k->http_bodyless = k->httpcode >= 100 && k->httpcode < 200;
@@ -3393,9 +3390,6 @@ static CURLcode http_on_response(struct Curl_easy *data,
if(conn->httpversion != 20)
infof(data, "Lying server, not serving HTTP/2");
}
- if(conn->httpversion < 20) {
- conn->bundle->multiuse = BUNDLE_NO_MULTIUSE;
- }
if(k->httpcode < 200 && last_hd) {
/* Intermediate responses might trigger processing of more
lib/http2.c+0 -3
@@ -2837,7 +2837,6 @@ CURLcode Curl_http2_switch(struct Curl_easy *data,
conn->httpversion = 20; /* we know we are on HTTP/2 now */
conn->bits.multiplex = TRUE; /* at least potentially multiplexed */
- conn->bundle->multiuse = BUNDLE_MULTIPLEX;
Curl_multi_connchanged(data->multi);
if(cf->next) {
@@ -2861,7 +2860,6 @@ CURLcode Curl_http2_switch_at(struct Curl_cfilter *cf, struct Curl_easy *data)
cf_h2 = cf->next;
cf->conn->httpversion = 20; /* we know we are on HTTP/2 now */
cf->conn->bits.multiplex = TRUE; /* at least potentially multiplexed */
- cf->conn->bundle->multiuse = BUNDLE_MULTIPLEX;
Curl_multi_connchanged(data->multi);
if(cf_h2->next) {
@@ -2914,7 +2912,6 @@ CURLcode Curl_http2_upgrade(struct Curl_easy *data,
conn->httpversion = 20; /* we know we are on HTTP/2 now */
conn->bits.multiplex = TRUE; /* at least potentially multiplexed */
- conn->bundle->multiuse = BUNDLE_MULTIPLEX;
Curl_multi_connchanged(data->multi);
if(cf->next) {
lib/llist.c+7 -0
@@ -254,3 +254,10 @@ struct Curl_llist_node *Curl_node_prev(struct Curl_llist_node *n)
}
#endif
+
+struct Curl_llist *Curl_node_llist(struct Curl_llist_node *n)
+{
+ DEBUGASSERT(n);
+ DEBUGASSERT(!n->_list || n->_init == NODEINIT);
+ return n->_list;
+}
lib/llist.h+3 -0
@@ -83,4 +83,7 @@ struct Curl_llist_node *Curl_node_next(struct Curl_llist_node *n);
Curl_llist_node */
struct Curl_llist_node *Curl_node_prev(struct Curl_llist_node *n);
+/* Curl_node_llist() return the list the node is in or NULL. */
+struct Curl_llist *Curl_node_llist(struct Curl_llist_node *n);
+
#endif /* HEADER_CURL_LLIST_H */
lib/multi.c+138 -190
@@ -411,7 +411,8 @@ struct Curl_multi *Curl_multi_handle(size_t hashsize, /* socket hash */
Curl_hash_init(&multi->proto_hash, 23,
Curl_hash_str, Curl_str_key_compare, ph_freeentry);
- if(Curl_conncache_init(&multi->conn_cache, multi, chashsize))
+ if(Curl_cpool_init(&multi->cpool, Curl_on_disconnect,
+ multi, NULL, chashsize))
goto error;
Curl_llist_init(&multi->msglist, NULL);
@@ -443,7 +444,7 @@ error:
sockhash_destroy(&multi->sockhash);
Curl_hash_destroy(&multi->proto_hash);
Curl_hash_destroy(&multi->hostcache);
- Curl_conncache_destroy(&multi->conn_cache);
+ Curl_cpool_destroy(&multi->cpool);
free(multi);
return NULL;
}
@@ -511,7 +512,7 @@ CURLMcode curl_multi_add_handle(struct Curl_multi *multi,
/*
* No failure allowed in this function beyond this point. No modification of
* easy nor multi handle allowed before this except for potential multi's
- * connection cache growing which will not be undone in this function no
+ * connection pool growing which will not be undone in this function no
* matter what.
*/
if(data->set.errorbuffer)
@@ -548,13 +549,6 @@ CURLMcode curl_multi_add_handle(struct Curl_multi *multi,
data->dns.hostcachetype = HCACHE_MULTI;
}
- /* Point to the shared or multi handle connection cache */
- if(data->share && (data->share->specifier & (1<< CURL_LOCK_DATA_CONNECT)))
- data->state.conn_cache = &data->share->conn_cache;
- else
- data->state.conn_cache = &multi->conn_cache;
- data->state.lastconnect_id = -1;
-
#ifdef USE_LIBPSL
/* Do the same for PSL. */
if(data->share && (data->share->specifier & (1 << CURL_LOCK_DATA_PSL)))
@@ -572,28 +566,12 @@ CURLMcode curl_multi_add_handle(struct Curl_multi *multi,
/* increase the alive-counter */
multi->num_alive++;
- CONNCACHE_LOCK(data);
- /* The closure handle only ever has default timeouts set. To improve the
- state somewhat we clone the timeouts from each added handle so that the
- closure handle always has the same timeouts as the most recently added
- easy handle. */
- data->state.conn_cache->closure_handle->set.timeout = data->set.timeout;
- data->state.conn_cache->closure_handle->set.server_response_timeout =
- data->set.server_response_timeout;
- data->state.conn_cache->closure_handle->set.no_signal =
- data->set.no_signal;
-
- /* the identifier inside the connection cache */
- data->id = data->state.conn_cache->next_easy_id++;
- if(data->state.conn_cache->next_easy_id <= 0)
- data->state.conn_cache->next_easy_id = 0;
/* the identifier inside the multi instance */
data->mid = multi->next_easy_mid++;
if(multi->next_easy_mid <= 0)
multi->next_easy_mid = 0;
- CONNCACHE_UNLOCK(data);
-
+ Curl_cpool_xfer_init(data);
multi_warn_debug(multi, data);
return CURLM_OK;
@@ -615,6 +593,91 @@ static void debug_print_sock_hash(void *p)
}
#endif
+struct multi_done_ctx {
+ BIT(premature);
+};
+
+static void multi_done_locked(struct connectdata *conn,
+ struct Curl_easy *data,
+ void *userdata)
+{
+ struct multi_done_ctx *mdctx = userdata;
+
+ Curl_detach_connection(data);
+
+ if(CONN_INUSE(conn)) {
+ /* Stop if still used. */
+ DEBUGF(infof(data, "Connection still in use %zu, "
+ "no more multi_done now!",
+ Curl_llist_count(&conn->easyq)));
+ return;
+ }
+
+ data->state.done = TRUE; /* called just now! */
+ data->state.recent_conn_id = conn->connection_id;
+
+ if(conn->dns_entry)
+ Curl_resolv_unlink(data, &conn->dns_entry); /* done with this */
+ Curl_hostcache_prune(data);
+
+ /* if data->set.reuse_forbid is TRUE, it means the libcurl client has
+ forced us to close this connection. This is ignored for requests taking
+ place in a NTLM/NEGOTIATE authentication handshake
+
+ if conn->bits.close is TRUE, it means that the connection should be
+ closed in spite of all our efforts to be nice, due to protocol
+ restrictions in our or the server's end
+
+ if premature is TRUE, it means this connection was said to be DONE before
+ the entire request operation is complete and thus we cannot know in what
+ state it is for reusing, so we are forced to close it. In a perfect world
+ we can add code that keep track of if we really must close it here or not,
+ but currently we have no such detail knowledge.
+ */
+
+ if((data->set.reuse_forbid
+#if defined(USE_NTLM)
+ && !(conn->http_ntlm_state == NTLMSTATE_TYPE2 ||
+ conn->proxy_ntlm_state == NTLMSTATE_TYPE2)
+#endif
+#if defined(USE_SPNEGO)
+ && !(conn->http_negotiate_state == GSS_AUTHRECV ||
+ conn->proxy_negotiate_state == GSS_AUTHRECV)
+#endif
+ ) || conn->bits.close
+ || (mdctx->premature && !Curl_conn_is_multiplex(conn, FIRSTSOCKET))) {
+ DEBUGF(infof(data, "multi_done, not reusing connection=%"
+ CURL_FORMAT_CURL_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)));
+ connclose(conn, "disconnecting");
+ Curl_cpool_disconnect(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 #%" CURL_FORMAT_CURL_OFF_T
+ " to host %s left intact", conn->connection_id, host);
+ }
+ else {
+ /* connection was removed from the cpool and destroyed. */
+ data->state.lastconnect_id = -1;
+ }
+ }
+}
+
static CURLcode multi_done(struct Curl_easy *data,
CURLcode status, /* an error if this is called
after an error was detected */
@@ -622,6 +685,9 @@ static CURLcode multi_done(struct Curl_easy *data,
{
CURLcode result, r2;
struct connectdata *conn = data->conn;
+ struct multi_done_ctx mdctx;
+
+ memset(&mdctx, 0, sizeof(mdctx));
#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
DEBUGF(infof(data, "multi_done[%s]: status: %d prem: %d done: %d",
@@ -684,104 +750,22 @@ static CURLcode multi_done(struct Curl_easy *data,
if(!result)
result = Curl_req_done(&data->req, data, premature);
- CONNCACHE_LOCK(data);
- Curl_detach_connection(data);
- if(CONN_INUSE(conn)) {
- /* Stop if still used. */
- CONNCACHE_UNLOCK(data);
- DEBUGF(infof(data, "Connection still in use %zu, "
- "no more multi_done now!",
- Curl_llist_count(&conn->easyq)));
- return CURLE_OK;
- }
-
- data->state.done = TRUE; /* called just now! */
-
- if(conn->dns_entry)
- Curl_resolv_unlink(data, &conn->dns_entry); /* done with this */
- Curl_hostcache_prune(data);
-
- /* if data->set.reuse_forbid is TRUE, it means the libcurl client has
- forced us to close this connection. This is ignored for requests taking
- place in a NTLM/NEGOTIATE authentication handshake
-
- if conn->bits.close is TRUE, it means that the connection should be
- closed in spite of all our efforts to be nice, due to protocol
- restrictions in our or the server's end
-
- if premature is TRUE, it means this connection was said to be DONE before
- the entire request operation is complete and thus we cannot know in what
- state it is for reusing, so we are forced to close it. In a perfect world
- we can add code that keep track of if we really must close it here or not,
- but currently we have no such detail knowledge.
- */
-
- data->state.recent_conn_id = conn->connection_id;
- if((data->set.reuse_forbid
-#if defined(USE_NTLM)
- && !(conn->http_ntlm_state == NTLMSTATE_TYPE2 ||
- conn->proxy_ntlm_state == NTLMSTATE_TYPE2)
-#endif
-#if defined(USE_SPNEGO)
- && !(conn->http_negotiate_state == GSS_AUTHRECV ||
- conn->proxy_negotiate_state == GSS_AUTHRECV)
-#endif
- ) || conn->bits.close
- || (premature && !Curl_conn_is_multiplex(conn, FIRSTSOCKET))) {
- DEBUGF(infof(data, "multi_done, not reusing connection=%"
- CURL_FORMAT_CURL_OFF_T ", forbid=%d"
- ", close=%d, premature=%d, conn_multiplex=%d",
- conn->connection_id,
- data->set.reuse_forbid, conn->bits.close, premature,
- Curl_conn_is_multiplex(conn, FIRSTSOCKET)));
- connclose(conn, "disconnecting");
- Curl_conncache_remove_conn(data, conn, FALSE);
- CONNCACHE_UNLOCK(data);
- Curl_disconnect(data, conn, premature);
- }
- else {
- char buffer[256];
- 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;
- /* create string before returning the connection */
- curl_off_t connection_id = conn->connection_id;
- msnprintf(buffer, sizeof(buffer),
- "Connection #%" CURL_FORMAT_CURL_OFF_T " to host %s left intact",
- connection_id, host);
- /* the connection is no longer in use by this transfer */
- CONNCACHE_UNLOCK(data);
- if(Curl_conncache_return_conn(data, conn)) {
- /* remember the most recently used connection */
- data->state.lastconnect_id = connection_id;
- data->state.recent_conn_id = connection_id;
- infof(data, "%s", buffer);
- }
- else
- data->state.lastconnect_id = -1;
- }
+ /* Under the potential connection pool's share lock, decide what to
+ * do with the transfer's connection. */
+ mdctx.premature = premature;
+ Curl_cpool_do_locked(data, data->conn, multi_done_locked, &mdctx);
return result;
}
-static int close_connect_only(struct Curl_easy *data,
- struct connectdata *conn, void *param)
+static void close_connect_only(struct connectdata *conn,
+ struct Curl_easy *data,
+ void *userdata)
{
- (void)param;
- if(data->state.lastconnect_id != conn->connection_id)
- return 0;
-
- if(!conn->connect_only)
- return 1;
-
- connclose(conn, "Removing connect-only easy handle");
-
- return 1;
+ (void)userdata;
+ (void)data;
+ if(conn->connect_only)
+ connclose(conn, "Removing connect-only easy handle");
}
CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
@@ -881,15 +865,14 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
curl_socket_t s;
s = Curl_getconnectinfo(data, &c);
if((s != CURL_SOCKET_BAD) && c) {
- Curl_conncache_remove_conn(data, c, TRUE);
- Curl_disconnect(data, c, TRUE);
+ Curl_cpool_disconnect(data, c, TRUE);
}
}
if(data->state.lastconnect_id != -1) {
/* Mark any connect-only connection for closure */
- Curl_conncache_foreach(data, data->state.conn_cache,
- NULL, close_connect_only);
+ Curl_cpool_do_by_id(data, data->state.lastconnect_id,
+ close_connect_only, NULL);
}
#ifdef USE_LIBPSL
@@ -898,10 +881,6 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
data->psl = NULL;
#endif
- /* as this was using a shared connection cache we clear the pointer to that
- since we are not part of that multi handle anymore */
- data->state.conn_cache = NULL;
-
/* make sure there is no pending message in the queue sent from this easy
handle */
for(e = Curl_llist_head(&multi->msglist); e; e = Curl_node_next(e)) {
@@ -920,7 +899,6 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
/* NOTE NOTE NOTE
We do not touch the easy handle here! */
multi->num_easy--; /* one less to care about now */
-
process_pending_handles(multi);
if(removed_timer) {
@@ -1223,7 +1201,7 @@ CURLMcode curl_multi_waitfds(struct Curl_multi *multi,
}
}
- if(Curl_conncache_add_waitfds(&multi->conn_cache, &cwfds)) {
+ if(Curl_cpool_add_waitfds(&multi->cpool, &cwfds)) {
result = CURLM_OUT_OF_MEMORY;
goto out;
}
@@ -1300,7 +1278,7 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
}
}
- if(Curl_conncache_add_pollfds(&multi->conn_cache, &cpfds)) {
+ if(Curl_cpool_add_pollfds(&multi->cpool, &cpfds)) {
result = CURLM_OUT_OF_MEMORY;
goto out;
}
@@ -1945,8 +1923,14 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
WAITDO or DO! */
rc = CURLM_CALL_MULTI_PERFORM;
- if(connected)
+ if(connected) {
+ if(!data->conn->bits.reuse &&
+ Curl_conn_is_multiplex(data->conn, FIRSTSOCKET)) {
+ /* new connection, can multiplex, wake pending handles */
+ process_pending_handles(data->multi);
+ }
multistate(data, MSTATE_PROTOCONNECT);
+ }
else {
multistate(data, MSTATE_CONNECTING);
}
@@ -2055,6 +2039,11 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
DEBUGASSERT(data->conn);
result = Curl_conn_connect(data, FIRSTSOCKET, FALSE, &connected);
if(connected && !result) {
+ if(!data->conn->bits.reuse &&
+ Curl_conn_is_multiplex(data->conn, FIRSTSOCKET)) {
+ /* new connection, can multiplex, wake pending handles */
+ process_pending_handles(data->multi);
+ }
rc = CURLM_CALL_MULTI_PERFORM;
multistate(data, MSTATE_PROTOCONNECT);
}
@@ -2511,10 +2500,6 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
if(data->conn) {
CURLcode res;
- if(data->conn->bits.multiplex)
- /* Check if we can move pending requests to connection */
- process_pending_handles(multi); /* multiplexing */
-
/* post-transfer command */
res = multi_done(data, result, FALSE);
@@ -2589,12 +2574,7 @@ statemachine_end:
We do not have to do this in every case block above where a
failure is detected */
Curl_detach_connection(data);
-
- /* remove connection from cache */
- Curl_conncache_remove_conn(data, conn, TRUE);
-
- /* disconnect properly */
- Curl_disconnect(data, conn, dead_connection);
+ Curl_cpool_disconnect(data, conn, dead_connection);
}
}
else if(data->mstate == MSTATE_CONNECT) {
@@ -2677,8 +2657,8 @@ CURLMcode curl_multi_perform(struct Curl_multi *multi, int *running_handles)
pointer now */
n = Curl_node_next(e);
- if(data != multi->conn_cache.closure_handle) {
- /* connection cache handle is processed below */
+ if(data != multi->cpool.idata) {
+ /* connection pool handle is processed below */
sigpipe_apply(data, &pipe_st);
result = multi_runsingle(multi, &now, data);
if(result)
@@ -2686,8 +2666,8 @@ CURLMcode curl_multi_perform(struct Curl_multi *multi, int *running_handles)
}
}
- sigpipe_apply(multi->conn_cache.closure_handle, &pipe_st);
- Curl_conncache_multi_perform(multi);
+ sigpipe_apply(multi->cpool.idata, &pipe_st);
+ Curl_cpool_multi_perform(multi);
sigpipe_restore(&pipe_st);
@@ -2777,8 +2757,6 @@ CURLMcode curl_multi_cleanup(struct Curl_multi *multi)
data->dns.hostcachetype = HCACHE_NONE;
}
- /* Clear the pointer to the connection cache */
- data->state.conn_cache = NULL;
data->multi = NULL; /* clear the association */
#ifdef USE_LIBPSL
@@ -2787,12 +2765,10 @@ CURLMcode curl_multi_cleanup(struct Curl_multi *multi)
#endif
}
- /* Close all the connections in the connection cache */
- Curl_conncache_multi_close_all(multi);
+ Curl_cpool_destroy(&multi->cpool);
sockhash_destroy(&multi->sockhash);
Curl_hash_destroy(&multi->proto_hash);
- Curl_conncache_destroy(&multi->conn_cache);
Curl_hash_destroy(&multi->hostcache);
Curl_psl_destroy(&multi->psl);
@@ -3143,7 +3119,7 @@ struct multi_run_ctx {
struct curltime now;
size_t run_xfers;
SIGPIPE_MEMBER(pipe_st);
- bool run_conn_cache;
+ bool run_cpool;
};
static CURLMcode multi_run_expired(struct multi_run_ctx *mrc)
@@ -3170,8 +3146,8 @@ static CURLMcode multi_run_expired(struct multi_run_ctx *mrc)
continue;
(void)add_next_timeout(mrc->now, multi, data);
- if(data == multi->conn_cache.closure_handle) {
- mrc->run_conn_cache = TRUE;
+ if(data == multi->cpool.idata) {
+ mrc->run_cpool = TRUE;
continue;
}
@@ -3220,7 +3196,7 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
result = singlesocket(multi, Curl_node_elem(e));
}
}
- mrc.run_conn_cache = TRUE;
+ mrc.run_cpool = TRUE;
goto out;
}
@@ -3234,8 +3210,8 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
asked to get removed, so thus we better survive stray socket actions
and just move on. */
/* The socket might come from a connection that is being shut down
- * by the multi's conncache. */
- Curl_conncache_multi_socket(multi, s, ev_bitmask);
+ * by the multi's connection pool. */
+ Curl_cpool_multi_socket(multi, s, ev_bitmask);
}
else {
struct Curl_hash_iterator iter;
@@ -3249,8 +3225,8 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
DEBUGASSERT(data);
DEBUGASSERT(data->magic == CURLEASY_MAGIC_NUMBER);
- if(data == multi->conn_cache.closure_handle)
- mrc.run_conn_cache = TRUE;
+ if(data == multi->cpool.idata)
+ mrc.run_cpool = TRUE;
else {
/* Expire with out current now, so we will get it below when
* asking the splaytree for expired transfers. */
@@ -3275,9 +3251,9 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
}
out:
- if(mrc.run_conn_cache) {
- sigpipe_apply(multi->conn_cache.closure_handle, &mrc.pipe_st);
- Curl_conncache_multi_perform(multi);
+ if(mrc.run_cpool) {
+ sigpipe_apply(multi->cpool.idata, &mrc.pipe_st);
+ Curl_cpool_multi_perform(multi);
}
sigpipe_restore(&mrc.pipe_st);
@@ -3733,34 +3709,6 @@ CURLMcode curl_multi_assign(struct Curl_multi *multi, curl_socket_t s,
return CURLM_OK;
}
-size_t Curl_multi_max_host_connections(struct Curl_multi *multi)
-{
- return multi ? (size_t)multi->max_host_connections : 0;
-}
-
-size_t Curl_multi_max_total_connections(struct Curl_multi *multi)
-{
- return multi ? (size_t)multi->max_total_connections : 0;
-}
-
-/*
- * When information about a connection has appeared, call this!
- */
-
-void Curl_multiuse_state(struct Curl_easy *data,
- int bundlestate) /* use BUNDLE_* defines */
-{
- struct connectdata *conn;
- DEBUGASSERT(data);
- DEBUGASSERT(data->multi);
- conn = data->conn;
- DEBUGASSERT(conn);
- DEBUGASSERT(conn->bundle);
-
- conn->bundle->multiuse = bundlestate;
- process_pending_handles(data->multi);
-}
-
static void move_pending_to_connect(struct Curl_multi *multi,
struct Curl_easy *data)
{
lib/multihandle.h+1 -1
@@ -138,7 +138,7 @@ struct Curl_multi {
struct Curl_hash proto_hash;
/* Shared connection cache (bundles)*/
- struct conncache conn_cache;
+ struct cpool cpool;
long max_host_connections; /* if >0, a fixed limit of the maximum number
of connections per host */
lib/multiif.h+0 -9
@@ -63,15 +63,6 @@ struct Curl_multi *Curl_multi_handle(size_t hashsize,
/* mask for checking if read and/or write is set for index x */
#define GETSOCK_MASK_RW(x) (GETSOCK_READSOCK(x)|GETSOCK_WRITESOCK(x))
-/* Return the value of the CURLMOPT_MAX_HOST_CONNECTIONS option */
-size_t Curl_multi_max_host_connections(struct Curl_multi *multi);
-
-/* Return the value of the CURLMOPT_MAX_TOTAL_CONNECTIONS option */
-size_t Curl_multi_max_total_connections(struct Curl_multi *multi);
-
-void Curl_multiuse_state(struct Curl_easy *data,
- int bundlestate); /* use BUNDLE_* defines */
-
/*
* Curl_multi_closed()
*
lib/share.c+6 -6
@@ -31,6 +31,7 @@
#include "psl.h"
#include "vtls/vtls.h"
#include "hsts.h"
+#include "url.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
@@ -120,10 +121,11 @@ curl_share_setopt(struct Curl_share *share, CURLSHoption option, ...)
break;
case CURL_LOCK_DATA_CONNECT:
- if(!share->conn_cache.hash.table) {
- if(Curl_conncache_init(&share->conn_cache, NULL, 103)) {
+ /* It is safe to set this option several times on a share. */
+ if(!share->cpool.idata) {
+ if(Curl_cpool_init(&share->cpool, Curl_on_disconnect,
+ NULL, share, 103))
res = CURLSHE_NOMEM;
- }
}
break;
@@ -228,9 +230,7 @@ curl_share_cleanup(struct Curl_share *share)
}
if(share->specifier & (1 << CURL_LOCK_DATA_CONNECT)) {
- /* avoid the hash if it was never initialized */
- Curl_conncache_close_all_connections(&share->conn_cache);
- Curl_conncache_destroy(&share->conn_cache);
+ Curl_cpool_destroy(&share->cpool);
}
Curl_hash_destroy(&share->hostcache);
lib/share.h+4 -1
@@ -34,6 +34,9 @@
#define CURL_GOOD_SHARE 0x7e117a1e
#define GOOD_SHARE_HANDLE(x) ((x) && (x)->magic == CURL_GOOD_SHARE)
+#define CURL_SHARE_KEEP_CONNECT(s) \
+ ((s) && ((s)->specifier & (1<< CURL_LOCK_DATA_CONNECT)))
+
/* this struct is libcurl-private, do not export details */
struct Curl_share {
unsigned int magic; /* CURL_GOOD_SHARE */
@@ -43,7 +46,7 @@ struct Curl_share {
curl_lock_function lockfunc;
curl_unlock_function unlockfunc;
void *clientdata;
- struct conncache conn_cache;
+ struct cpool cpool;
struct Curl_hash hostcache;
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
struct CookieInfo *cookies;
lib/url.c+463 -501
@@ -597,13 +597,14 @@ void Curl_conn_free(struct Curl_easy *data, struct connectdata *conn)
#ifdef USE_UNIX_SOCKETS
Curl_safefree(conn->unix_domain_socket);
#endif
+ Curl_safefree(conn->destination);
free(conn); /* free all the connection oriented data */
}
/*
* Disconnects the given connection. Note the connection may not be the
- * primary connection, like when freeing room in the connection cache or
+ * primary connection, like when freeing room in the connection pool or
* killing of a dead old connection.
*
* A connection needs an easy handle when closing down. We support this passed
@@ -613,14 +614,14 @@ void Curl_conn_free(struct Curl_easy *data, struct connectdata *conn)
* This function MUST NOT reset state in the Curl_easy struct if that
* is not strictly bound to the life-time of *this* particular connection.
*/
-void Curl_disconnect(struct Curl_easy *data,
- struct connectdata *conn, bool aborted)
+bool Curl_on_disconnect(struct Curl_easy *data,
+ struct connectdata *conn, bool aborted)
{
/* there must be a connection to close */
DEBUGASSERT(conn);
- /* it must be removed from the connection cache */
- DEBUGASSERT(!conn->bundle);
+ /* it must be removed from the connection pool */
+ DEBUGASSERT(!conn->bits.in_cpool);
/* there must be an associated transfer */
DEBUGASSERT(data);
@@ -632,15 +633,6 @@ void Curl_disconnect(struct Curl_easy *data,
CURL_FORMAT_CURL_OFF_T ", aborted=%d)",
conn->connection_id, aborted));
- /*
- * If this connection is not marked to force-close, leave it open if there
- * are other users of it
- */
- if(CONN_INUSE(conn) && !aborted) {
- DEBUGF(infof(data, "Curl_disconnect when inuse: %zu", CONN_INUSE(conn)));
- return;
- }
-
if(conn->dns_entry)
Curl_resolv_unlink(data, &conn->dns_entry);
@@ -654,30 +646,28 @@ void Curl_disconnect(struct Curl_easy *data,
/* treat the connection as aborted in CONNECT_ONLY situations */
aborted = TRUE;
- Curl_conncache_disconnect(data, conn, aborted);
+ return aborted;
}
/*
- * IsMultiplexingPossible()
+ * Curl_xfer_may_multiplex()
*
- * Return a bitmask with the available multiplexing options for the given
- * requested connection.
+ * Return a TRUE, iff the transfer can be done over an (appropriate)
+ * multiplexed connection.
*/
-static int IsMultiplexingPossible(const struct Curl_easy *handle,
- const struct connectdata *conn)
+static bool Curl_xfer_may_multiplex(const struct Curl_easy *data,
+ const struct connectdata *conn)
{
- int avail = 0;
-
/* If an HTTP protocol and multiplexing is enabled */
if((conn->handler->protocol & PROTO_FAMILY_HTTP) &&
(!conn->bits.protoconnstart || !conn->bits.close)) {
- if(Curl_multiplex_wanted(handle->multi) &&
- (handle->state.httpwant >= CURL_HTTP_VERSION_2))
- /* allows HTTP/2 */
- avail |= CURLPIPE_MULTIPLEX;
+ if(Curl_multiplex_wanted(data->multi) &&
+ (data->state.httpwant >= CURL_HTTP_VERSION_2))
+ /* allows HTTP/2 or newer */
+ return TRUE;
}
- return avail;
+ return FALSE;
}
#ifndef CURL_DISABLE_PROXY
@@ -751,23 +741,24 @@ static bool conn_maxage(struct Curl_easy *data,
}
/*
- * This function checks if the given connection is dead and prunes it from
- * the connection cache if so.
- *
- * When this is called as a Curl_conncache_foreach() callback, the connection
- * cache lock is held!
- *
- * Returns TRUE if the connection was dead and pruned.
+ * Return TRUE iff the given connection is considered dead.
*/
-static bool prune_if_dead(struct connectdata *conn,
- struct Curl_easy *data)
+bool Curl_conn_seems_dead(struct connectdata *conn,
+ struct Curl_easy *data,
+ struct curltime *pnow)
{
+ DEBUGASSERT(!data->conn);
if(!CONN_INUSE(conn)) {
/* The check for a dead socket makes sense only if the connection is not in
use */
bool dead;
- struct curltime now = Curl_now();
- if(conn_maxage(data, conn, now)) {
+ struct curltime now;
+ if(!pnow) {
+ now = Curl_now();
+ pnow = &now;
+ }
+
+ if(conn_maxage(data, conn, *pnow)) {
/* avoid check if already too old */
dead = TRUE;
}
@@ -807,64 +798,40 @@ static bool prune_if_dead(struct connectdata *conn,
}
if(dead) {
- /* remove connection from cache */
+ /* remove connection from cpool */
infof(data, "Connection %" CURL_FORMAT_CURL_OFF_T " seems to be dead",
conn->connection_id);
- Curl_conncache_remove_conn(data, conn, FALSE);
return TRUE;
}
}
return FALSE;
}
-/*
- * Wrapper to use prune_if_dead() function in Curl_conncache_foreach()
- *
- */
-static int call_prune_if_dead(struct Curl_easy *data,
- struct connectdata *conn, void *param)
-{
- struct connectdata **pruned = (struct connectdata **)param;
- if(prune_if_dead(conn, data)) {
- /* stop the iteration here, pass back the connection that was pruned */
- *pruned = conn;
- return 1;
- }
- return 0; /* continue iteration */
-}
-
-/*
- * This function scans the connection cache for half-open/dead connections,
- * closes and removes them. The cleanup is done at most once per second.
- *
- * When called, this transfer has no connection attached.
- */
-static void prune_dead_connections(struct Curl_easy *data)
+CURLcode Curl_conn_upkeep(struct Curl_easy *data,
+ struct connectdata *conn,
+ struct curltime *now)
{
- struct curltime now = Curl_now();
- timediff_t elapsed;
-
- DEBUGASSERT(!data->conn); /* no connection */
- CONNCACHE_LOCK(data);
- elapsed =
- Curl_timediff(now, data->state.conn_cache->last_cleanup);
- CONNCACHE_UNLOCK(data);
-
- if(elapsed >= 1000L) {
- struct connectdata *pruned = NULL;
- while(Curl_conncache_foreach(data, data->state.conn_cache, &pruned,
- call_prune_if_dead)) {
- /* unlocked */
-
- /* connection previously removed from cache in prune_if_dead() */
+ CURLcode result = CURLE_OK;
+ if(Curl_timediff(*now, conn->keepalive) <= data->set.upkeep_interval_ms)
+ return result;
- /* disconnect it, do not treat as aborted */
- Curl_disconnect(data, pruned, FALSE);
- }
- CONNCACHE_LOCK(data);
- data->state.conn_cache->last_cleanup = now;
- CONNCACHE_UNLOCK(data);
+ /* briefly attach for action */
+ Curl_attach_connection(data, conn);
+ if(conn->handler->connection_check) {
+ /* Do a protocol-specific keepalive check on the connection. */
+ unsigned int rc;
+ rc = conn->handler->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);
}
+ Curl_detach_connection(data);
+
+ conn->keepalive = *now;
+ return result;
}
#ifdef USE_SSH
@@ -878,425 +845,417 @@ static bool ssh_config_matches(struct connectdata *one,
#define ssh_config_matches(x,y) FALSE
#endif
-/*
- * Given one filled in connection struct (named needle), this function should
- * detect if there already is one that has all the significant details
- * exactly the same and thus should be used instead.
- *
- * If there is a match, this function returns TRUE - and has marked the
- * connection as 'in-use'. It must later be called with ConnectionDone() to
- * return back to 'idle' (unused) state.
- *
- * The force_reuse flag is set if the connection must be used.
- */
-static bool
-ConnectionExists(struct Curl_easy *data,
- struct connectdata *needle,
- struct connectdata **usethis,
- bool *force_reuse,
- bool *waitpipe)
+struct url_conn_match {
+ struct connectdata *found;
+ struct Curl_easy *data;
+ struct connectdata *needle;
+ BIT(may_multiplex);
+ BIT(want_ntlm_http);
+ BIT(want_proxy_ntlm_http);
+
+ BIT(wait_pipe);
+ BIT(force_reuse);
+ BIT(seen_pending_conn);
+ BIT(seen_single_use_conn);
+ BIT(seen_multiplex_conn);
+};
+
+static bool url_match_conn(struct connectdata *conn, void *userdata)
{
- struct connectdata *chosen = NULL;
- bool foundPendingCandidate = FALSE;
- bool canmultiplex = FALSE;
- struct connectbundle *bundle;
- struct Curl_llist_node *curr;
+ struct url_conn_match *match = userdata;
+ struct Curl_easy *data = match->data;
+ struct connectdata *needle = match->needle;
-#ifdef USE_NTLM
- bool wantNTLMhttp = ((data->state.authhost.want & CURLAUTH_NTLM) &&
- (needle->handler->protocol & PROTO_FAMILY_HTTP));
-#ifndef CURL_DISABLE_PROXY
- bool wantProxyNTLMhttp = (needle->bits.proxy_user_passwd &&
- ((data->state.authproxy.want &
- CURLAUTH_NTLM) &&
- (needle->handler->protocol & PROTO_FAMILY_HTTP)));
-#else
- bool wantProxyNTLMhttp = FALSE;
-#endif
-#endif
- /* plain HTTP with upgrade */
- bool h2upgrade = (data->state.httpwant == CURL_HTTP_VERSION_2_0) &&
- (needle->handler->protocol & CURLPROTO_HTTP);
+ /* Check if `conn` can be used for transfer `data` */
- *usethis = NULL;
- *force_reuse = FALSE;
- *waitpipe = FALSE;
+ if(conn->connect_only || conn->bits.close)
+ /* connect-only or to-be-closed connections will not be reused */
+ return FALSE;
- /* Look up the bundle with all the connections to this particular host.
- Locks the connection cache, beware of early returns! */
- bundle = Curl_conncache_find_bundle(data, needle, data->state.conn_cache);
- if(!bundle) {
- CONNCACHE_UNLOCK(data);
+ if(data->set.ipver != CURL_IPRESOLVE_WHATEVER
+ && data->set.ipver != conn->ip_version) {
+ /* skip because the connection is not via the requested IP version */
return FALSE;
}
- infof(data, "Found bundle for host: %p [%s]",
- (void *)bundle, (bundle->multiuse == BUNDLE_MULTIPLEX ?
- "can multiplex" : "serially"));
-
- /* We can only multiplex iff the transfer allows it AND we know
- * that the server we want to talk to supports it as well. */
- canmultiplex = FALSE;
- if(IsMultiplexingPossible(data, needle)) {
- if(bundle->multiuse == BUNDLE_UNKNOWN) {
- if(data->set.pipewait) {
- infof(data, "Server does not support multiplex yet, wait");
- *waitpipe = TRUE;
- CONNCACHE_UNLOCK(data);
- return FALSE; /* no reuse */
- }
- infof(data, "Server does not support multiplex (yet)");
- }
- else if(bundle->multiuse == BUNDLE_MULTIPLEX) {
- if(Curl_multiplex_wanted(data->multi))
- canmultiplex = TRUE;
- else
- infof(data, "Could multiplex, but not asked to");
- }
- else if(bundle->multiuse == BUNDLE_NO_MULTIUSE) {
- infof(data, "Can not multiplex, even if we wanted to");
- }
- }
-
- curr = Curl_llist_head(&bundle->conn_list);
- while(curr) {
- struct connectdata *check = Curl_node_elem(curr);
- /* Get next node now. We might remove a dead `check` connection which
- * would invalidate `curr` as well. */
- curr = Curl_node_next(curr);
-
- /* Note that if we use an HTTP proxy in normal mode (no tunneling), we
- * check connections to that proxy and not to the actual remote server.
- */
- if(check->connect_only || check->bits.close)
- /* connect-only or to-be-closed connections will not be reused */
- continue;
- if(data->set.ipver != CURL_IPRESOLVE_WHATEVER
- && data->set.ipver != check->ip_version) {
- /* skip because the connection is not via the requested IP version */
- continue;
- }
-
- if(!canmultiplex) {
- if(Curl_resolver_asynch() &&
- /* remote_ip[0] is NUL only if the resolving of the name has not
- completed yet and until then we do not reuse this connection */
- !check->primary.remote_ip[0])
- continue;
- }
+ if(needle->localdev || needle->localport) {
+ /* If we are bound to a specific local end (IP+port), we must not
+ reuse a random other one, although if we did not ask for a
+ particular one we can reuse one that was bound.
+
+ This comparison is a bit rough and too strict. Since the input
+ parameters can be specified in numerous ways and still end up the
+ same it would take a lot of processing to make it really accurate.
+ Instead, this matching will assume that reuses of bound connections
+ will most likely also reuse the exact same binding parameters and
+ missing out a few edge cases should not hurt anyone very much.
+ */
+ if((conn->localport != needle->localport) ||
+ (conn->localportrange != needle->localportrange) ||
+ (needle->localdev &&
+ (!conn->localdev || strcmp(conn->localdev, needle->localdev))))
+ return FALSE;
+ }
+
+ if(needle->bits.conn_to_host != conn->bits.conn_to_host)
+ /* do not mix connections that use the "connect to host" feature and
+ * connections that do not use this feature */
+ return FALSE;
- if(CONN_INUSE(check)) {
- if(!canmultiplex) {
- /* transfer cannot be multiplexed and check is in use */
- continue;
- }
- else {
- /* Could multiplex, but not when check belongs to another multi */
- struct Curl_llist_node *e = Curl_llist_head(&check->easyq);
- struct Curl_easy *entry = Curl_node_elem(e);
- if(entry->multi != data->multi)
- continue;
- }
- }
+ if(needle->bits.conn_to_port != conn->bits.conn_to_port)
+ /* do not mix connections that use the "connect to port" feature and
+ * connections that do not use this feature */
+ return FALSE;
- if(!Curl_conn_is_connected(check, FIRSTSOCKET)) {
- foundPendingCandidate = TRUE;
+ if(!Curl_conn_is_connected(conn, FIRSTSOCKET)) {
+ if(match->may_multiplex) {
+ match->seen_pending_conn = TRUE;
/* Do not pick a connection that has not connected yet */
infof(data, "Connection #%" CURL_FORMAT_CURL_OFF_T
- " is not open enough, cannot reuse", check->connection_id);
- continue;
+ " is not open enough, cannot reuse", conn->connection_id);
}
+ /* Do not pick a connection that has not connected yet */
+ return FALSE;
+ }
+ /* `conn` is connected. If it has transfers, can we add ours to it? */
- /* `check` is connected. if it is in use and does not support multiplex,
- * we cannot use it. */
- if(!check->bits.multiplex && CONN_INUSE(check))
- continue;
+ if(CONN_INUSE(conn)) {
+ if(!conn->bits.multiplex) {
+ /* conn busy and conn cannot take more transfers */
+ match->seen_single_use_conn = TRUE;
+ return FALSE;
+ }
+ match->seen_multiplex_conn = TRUE;
+ if(!match->may_multiplex)
+ /* conn busy and transfer cannot be multiplexed */
+ return FALSE;
+ else {
+ /* transfer and conn multiplex. Are they on the same multi? */
+ struct Curl_llist_node *e = Curl_llist_head(&conn->easyq);
+ struct Curl_easy *entry = Curl_node_elem(e);
+ if(entry->multi != data->multi)
+ return FALSE;
+ }
+ }
+ /* `conn` is connected and we could add the transfer to it, if
+ * all the other criteria do match. */
+ /* Does `conn` use the correct protocol? */
#ifdef USE_UNIX_SOCKETS
- if(needle->unix_domain_socket) {
- if(!check->unix_domain_socket)
- continue;
- if(strcmp(needle->unix_domain_socket, check->unix_domain_socket))
- continue;
- if(needle->bits.abstract_unix_socket !=
- check->bits.abstract_unix_socket)
- continue;
- }
- else if(check->unix_domain_socket)
- continue;
-#endif
-
- if((needle->handler->flags&PROTOPT_SSL) !=
- (check->handler->flags&PROTOPT_SSL))
- /* do not do mixed SSL and non-SSL connections */
- if(get_protocol_family(check->handler) !=
- needle->handler->protocol || !check->bits.tls_upgraded)
- /* except protocols that have been upgraded via TLS */
- continue;
-
- if(needle->bits.conn_to_host != check->bits.conn_to_host)
- /* do not mix connections that use the "connect to host" feature and
- * connections that do not use this feature */
- continue;
-
- if(needle->bits.conn_to_port != check->bits.conn_to_port)
- /* do not mix connections that use the "connect to port" feature and
- * connections that do not use this feature */
- continue;
+ if(needle->unix_domain_socket) {
+ if(!conn->unix_domain_socket)
+ return FALSE;
+ if(strcmp(needle->unix_domain_socket, conn->unix_domain_socket))
+ return FALSE;
+ if(needle->bits.abstract_unix_socket != conn->bits.abstract_unix_socket)
+ return FALSE;
+ }
+ else if(conn->unix_domain_socket)
+ return FALSE;
+#endif
+
+ if((needle->handler->flags&PROTOPT_SSL) !=
+ (conn->handler->flags&PROTOPT_SSL))
+ /* do not do mixed SSL and non-SSL connections */
+ if(get_protocol_family(conn->handler) !=
+ needle->handler->protocol || !conn->bits.tls_upgraded)
+ /* except protocols that have been upgraded via TLS */
+ return FALSE;
#ifndef CURL_DISABLE_PROXY
- if(needle->bits.httpproxy != check->bits.httpproxy ||
- needle->bits.socksproxy != check->bits.socksproxy)
- continue;
-
- if(needle->bits.socksproxy &&
- !socks_proxy_info_matches(&needle->socks_proxy,
- &check->socks_proxy))
- continue;
-
- if(needle->bits.httpproxy) {
- if(needle->bits.tunnel_proxy != check->bits.tunnel_proxy)
- continue;
-
- if(!proxy_info_matches(&needle->http_proxy, &check->http_proxy))
- continue;
-
- if(IS_HTTPS_PROXY(needle->http_proxy.proxytype)) {
- /* https proxies come in different types, http/1.1, h2, ... */
- if(needle->http_proxy.proxytype != check->http_proxy.proxytype)
- continue;
- /* match SSL config to proxy */
- if(!Curl_ssl_conn_config_match(data, check, TRUE)) {
- DEBUGF(infof(data,
- "Connection #%" CURL_FORMAT_CURL_OFF_T
- " has different SSL proxy parameters, cannot reuse",
- check->connection_id));
- continue;
- }
- /* the SSL config to the server, which may apply here is checked
- * further below */
+ if(needle->bits.httpproxy != conn->bits.httpproxy ||
+ needle->bits.socksproxy != conn->bits.socksproxy)
+ return FALSE;
+
+ if(needle->bits.socksproxy &&
+ !socks_proxy_info_matches(&needle->socks_proxy,
+ &conn->socks_proxy))
+ return FALSE;
+
+ if(needle->bits.httpproxy) {
+ if(needle->bits.tunnel_proxy != conn->bits.tunnel_proxy)
+ return FALSE;
+
+ if(!proxy_info_matches(&needle->http_proxy, &conn->http_proxy))
+ return FALSE;
+
+ if(IS_HTTPS_PROXY(needle->http_proxy.proxytype)) {
+ /* https proxies come in different types, http/1.1, h2, ... */
+ if(needle->http_proxy.proxytype != conn->http_proxy.proxytype)
+ return FALSE;
+ /* match SSL config to proxy */
+ if(!Curl_ssl_conn_config_match(data, conn, TRUE)) {
+ DEBUGF(infof(data,
+ "Connection #%" CURL_FORMAT_CURL_OFF_T
+ " has different SSL proxy parameters, cannot reuse",
+ conn->connection_id));
+ return FALSE;
}
+ /* the SSL config to the server, which may apply here is checked
+ * further below */
}
+ }
#endif
- if(h2upgrade && !check->httpversion && canmultiplex) {
- if(data->set.pipewait) {
- infof(data, "Server upgrade does not support multiplex yet, wait");
- *waitpipe = TRUE;
- CONNCACHE_UNLOCK(data);
- return FALSE; /* no reuse */
- }
- infof(data, "Server upgrade cannot be used");
- continue; /* cannot be used atm */
- }
-
- if(needle->localdev || needle->localport) {
- /* If we are bound to a specific local end (IP+port), we must not
- reuse a random other one, although if we did not ask for a
- particular one we can reuse one that was bound.
-
- This comparison is a bit rough and too strict. Since the input
- parameters can be specified in numerous ways and still end up the
- same it would take a lot of processing to make it really accurate.
- Instead, this matching will assume that reuses of bound connections
- will most likely also reuse the exact same binding parameters and
- missing out a few edge cases should not hurt anyone very much.
- */
- if((check->localport != needle->localport) ||
- (check->localportrange != needle->localportrange) ||
- (needle->localdev &&
- (!check->localdev || strcmp(check->localdev, needle->localdev))))
- continue;
- }
-
- if(!(needle->handler->flags & PROTOPT_CREDSPERREQUEST)) {
- /* This protocol requires credentials per connection,
- so verify that we are using the same name and password as well */
- if(Curl_timestrcmp(needle->user, check->user) ||
- Curl_timestrcmp(needle->passwd, check->passwd) ||
- Curl_timestrcmp(needle->sasl_authzid, check->sasl_authzid) ||
- Curl_timestrcmp(needle->oauth_bearer, check->oauth_bearer)) {
- /* one of them was different */
- continue;
- }
+ if(match->may_multiplex &&
+ (data->state.httpwant == CURL_HTTP_VERSION_2_0) &&
+ (needle->handler->protocol & CURLPROTO_HTTP) &&
+ !conn->httpversion) {
+ if(data->set.pipewait) {
+ infof(data, "Server upgrade does not support multiplex yet, wait");
+ match->found = NULL;
+ match->wait_pipe = TRUE;
+ return TRUE; /* stop searching, we want to wait */
+ }
+ infof(data, "Server upgrade cannot be used");
+ return FALSE;
+ }
+
+ if(!(needle->handler->flags & PROTOPT_CREDSPERREQUEST)) {
+ /* This protocol requires credentials per connection,
+ so verify that we are using the same name and password as well */
+ if(Curl_timestrcmp(needle->user, conn->user) ||
+ Curl_timestrcmp(needle->passwd, conn->passwd) ||
+ Curl_timestrcmp(needle->sasl_authzid, conn->sasl_authzid) ||
+ Curl_timestrcmp(needle->oauth_bearer, conn->oauth_bearer)) {
+ /* one of them was different */
+ return FALSE;
}
+ }
- /* GSS delegation differences do not actually affect every connection
- and auth method, but this check takes precaution before efficiency */
- if(needle->gssapi_delegation != check->gssapi_delegation)
- continue;
+ /* GSS delegation differences do not actually affect every connection
+ and auth method, but this check takes precaution before efficiency */
+ if(needle->gssapi_delegation != conn->gssapi_delegation)
+ return FALSE;
- /* If looking for HTTP and the HTTP version we want is less
- * than the HTTP version of the check connection, continue looking */
- if((needle->handler->protocol & PROTO_FAMILY_HTTP) &&
- (((check->httpversion >= 20) &&
- (data->state.httpwant < CURL_HTTP_VERSION_2_0))
- || ((check->httpversion >= 30) &&
- (data->state.httpwant < CURL_HTTP_VERSION_3))))
- continue;
+ /* If looking for HTTP and the HTTP version we want is less
+ * than the HTTP version of conn, continue looking */
+ if((needle->handler->protocol & PROTO_FAMILY_HTTP) &&
+ (((conn->httpversion >= 20) &&
+ (data->state.httpwant < CURL_HTTP_VERSION_2_0))
+ || ((conn->httpversion >= 30) &&
+ (data->state.httpwant < CURL_HTTP_VERSION_3))))
+ return FALSE;
#ifdef USE_SSH
- else if(get_protocol_family(needle->handler) & PROTO_FAMILY_SSH) {
- if(!ssh_config_matches(needle, check))
- continue;
- }
+ else if(get_protocol_family(needle->handler) & PROTO_FAMILY_SSH) {
+ if(!ssh_config_matches(needle, conn))
+ return FALSE;
+ }
#endif
#ifndef CURL_DISABLE_FTP
- else if(get_protocol_family(needle->handler) & PROTO_FAMILY_FTP) {
- /* Also match ACCOUNT, ALTERNATIVE-TO-USER, USE_SSL and CCC options */
- if(Curl_timestrcmp(needle->proto.ftpc.account,
- check->proto.ftpc.account) ||
- Curl_timestrcmp(needle->proto.ftpc.alternative_to_user,
- check->proto.ftpc.alternative_to_user) ||
- (needle->proto.ftpc.use_ssl != check->proto.ftpc.use_ssl) ||
- (needle->proto.ftpc.ccc != check->proto.ftpc.ccc))
- continue;
- }
+ else if(get_protocol_family(needle->handler) & PROTO_FAMILY_FTP) {
+ /* Also match ACCOUNT, ALTERNATIVE-TO-USER, USE_SSL and CCC options */
+ if(Curl_timestrcmp(needle->proto.ftpc.account,
+ conn->proto.ftpc.account) ||
+ Curl_timestrcmp(needle->proto.ftpc.alternative_to_user,
+ conn->proto.ftpc.alternative_to_user) ||
+ (needle->proto.ftpc.use_ssl != conn->proto.ftpc.use_ssl) ||
+ (needle->proto.ftpc.ccc != conn->proto.ftpc.ccc))
+ return FALSE;
+ }
#endif
- /* Additional match requirements if talking TLS OR
- * not talking to an HTTP proxy OR using a tunnel through a proxy */
- if((needle->handler->flags&PROTOPT_SSL)
+ /* Additional match requirements if talking TLS OR
+ * not talking to an HTTP proxy OR using a tunnel through a proxy */
+ if((needle->handler->flags&PROTOPT_SSL)
#ifndef CURL_DISABLE_PROXY
- || !needle->bits.httpproxy || needle->bits.tunnel_proxy
-#endif
- ) {
- /* Talking the same protocol scheme or a TLS upgraded protocol in the
- * same protocol family? */
- if(!strcasecompare(needle->handler->scheme, check->handler->scheme) &&
- (get_protocol_family(check->handler) !=
- needle->handler->protocol || !check->bits.tls_upgraded))
- continue;
-
- /* If needle has "conn_to_*" set, check must match this */
- if((needle->bits.conn_to_host && !strcasecompare(
- needle->conn_to_host.name, check->conn_to_host.name)) ||
- (needle->bits.conn_to_port &&
- needle->conn_to_port != check->conn_to_port))
- continue;
-
- /* hostname and port must match */
- if(!strcasecompare(needle->host.name, check->host.name) ||
- needle->remote_port != check->remote_port)
- continue;
-
- /* If talking TLS, check needs to use the same SSL options. */
- if((needle->handler->flags & PROTOPT_SSL) &&
- !Curl_ssl_conn_config_match(data, check, FALSE)) {
- DEBUGF(infof(data,
- "Connection #%" CURL_FORMAT_CURL_OFF_T
- " has different SSL parameters, cannot reuse",
- check->connection_id));
- continue;
- }
+ || !needle->bits.httpproxy || needle->bits.tunnel_proxy
+#endif
+ ) {
+ /* Talking the same protocol scheme or a TLS upgraded protocol in the
+ * same protocol family? */
+ if(!strcasecompare(needle->handler->scheme, conn->handler->scheme) &&
+ (get_protocol_family(conn->handler) !=
+ needle->handler->protocol || !conn->bits.tls_upgraded))
+ return FALSE;
+
+ /* If needle has "conn_to_*" set, conn must match this */
+ if((needle->bits.conn_to_host && !strcasecompare(
+ needle->conn_to_host.name, conn->conn_to_host.name)) ||
+ (needle->bits.conn_to_port &&
+ needle->conn_to_port != conn->conn_to_port))
+ return FALSE;
+
+ /* hostname and port must match */
+ if(!strcasecompare(needle->host.name, conn->host.name) ||
+ needle->remote_port != conn->remote_port)
+ return FALSE;
+
+ /* If talking TLS, conn needs to use the same SSL options. */
+ if((needle->handler->flags & PROTOPT_SSL) &&
+ !Curl_ssl_conn_config_match(data, conn, FALSE)) {
+ DEBUGF(infof(data,
+ "Connection #%" CURL_FORMAT_CURL_OFF_T
+ " has different SSL parameters, cannot reuse",
+ conn->connection_id));
+ return FALSE;
}
+ }
#if defined(USE_NTLM)
- /* If we are looking for an HTTP+NTLM connection, check if this is
- already authenticating with the right credentials. If not, keep
- looking so that we can reuse NTLM connections if
- possible. (Especially we must not reuse the same connection if
- partway through a handshake!) */
- if(wantNTLMhttp) {
- if(Curl_timestrcmp(needle->user, check->user) ||
- Curl_timestrcmp(needle->passwd, check->passwd)) {
-
- /* we prefer a credential match, but this is at least a connection
- that can be reused and "upgraded" to NTLM */
- if(check->http_ntlm_state == NTLMSTATE_NONE)
- chosen = check;
- continue;
- }
- }
- else if(check->http_ntlm_state != NTLMSTATE_NONE) {
- /* Connection is using NTLM auth but we do not want NTLM */
- continue;
- }
+ /* If we are looking for an HTTP+NTLM connection, check if this is
+ already authenticating with the right credentials. If not, keep
+ looking so that we can reuse NTLM connections if
+ possible. (Especially we must not reuse the same connection if
+ partway through a handshake!) */
+ if(match->want_ntlm_http) {
+ if(Curl_timestrcmp(needle->user, conn->user) ||
+ Curl_timestrcmp(needle->passwd, conn->passwd)) {
+
+ /* we prefer a credential match, but this is at least a connection
+ that can be reused and "upgraded" to NTLM */
+ if(conn->http_ntlm_state == NTLMSTATE_NONE)
+ match->found = conn;
+ return FALSE;
+ }
+ }
+ else if(conn->http_ntlm_state != NTLMSTATE_NONE) {
+ /* Connection is using NTLM auth but we do not want NTLM */
+ return FALSE;
+ }
#ifndef CURL_DISABLE_PROXY
- /* Same for Proxy NTLM authentication */
- if(wantProxyNTLMhttp) {
- /* Both check->http_proxy.user and check->http_proxy.passwd can be
- * NULL */
- if(!check->http_proxy.user || !check->http_proxy.passwd)
- continue;
-
- if(Curl_timestrcmp(needle->http_proxy.user,
- check->http_proxy.user) ||
- Curl_timestrcmp(needle->http_proxy.passwd,
- check->http_proxy.passwd))
- continue;
- }
- else if(check->proxy_ntlm_state != NTLMSTATE_NONE) {
- /* Proxy connection is using NTLM auth but we do not want NTLM */
- continue;
- }
-#endif
- if(wantNTLMhttp || wantProxyNTLMhttp) {
- /* Credentials are already checked, we may use this connection.
- * With NTLM being weird as it is, we MUST use a
- * connection where it has already been fully negotiated.
- * If it has not, we keep on looking for a better one. */
- chosen = check;
-
- if((wantNTLMhttp &&
- (check->http_ntlm_state != NTLMSTATE_NONE)) ||
- (wantProxyNTLMhttp &&
- (check->proxy_ntlm_state != NTLMSTATE_NONE))) {
- /* We must use this connection, no other */
- *force_reuse = TRUE;
- break;
- }
- /* Continue look up for a better connection */
- continue;
+ /* Same for Proxy NTLM authentication */
+ if(match->want_proxy_ntlm_http) {
+ /* Both conn->http_proxy.user and conn->http_proxy.passwd can be
+ * NULL */
+ if(!conn->http_proxy.user || !conn->http_proxy.passwd)
+ return FALSE;
+
+ if(Curl_timestrcmp(needle->http_proxy.user,
+ conn->http_proxy.user) ||
+ Curl_timestrcmp(needle->http_proxy.passwd,
+ conn->http_proxy.passwd))
+ return FALSE;
+ }
+ else if(conn->proxy_ntlm_state != NTLMSTATE_NONE) {
+ /* Proxy connection is using NTLM auth but we do not want NTLM */
+ return FALSE;
+ }
+#endif
+ if(match->want_ntlm_http || match->want_proxy_ntlm_http) {
+ /* Credentials are already checked, we may use this connection.
+ * With NTLM being weird as it is, we MUST use a
+ * connection where it has already been fully negotiated.
+ * If it has not, we keep on looking for a better one. */
+ match->found = conn;
+
+ if((match->want_ntlm_http &&
+ (conn->http_ntlm_state != NTLMSTATE_NONE)) ||
+ (match->want_proxy_ntlm_http &&
+ (conn->proxy_ntlm_state != NTLMSTATE_NONE))) {
+ /* We must use this connection, no other */
+ match->force_reuse = TRUE;
+ return TRUE;
}
+ /* Continue look up for a better connection */
+ return FALSE;
+ }
#endif
- if(CONN_INUSE(check)) {
- DEBUGASSERT(canmultiplex);
- DEBUGASSERT(check->bits.multiplex);
- /* If multiplexed, make sure we do not go over concurrency limit */
- if(CONN_INUSE(check) >=
- Curl_multi_max_concurrent_streams(data->multi)) {
- infof(data, "client side MAX_CONCURRENT_STREAMS reached"
- ", skip (%zu)", CONN_INUSE(check));
- continue;
- }
- if(CONN_INUSE(check) >=
- Curl_conn_get_max_concurrent(data, check, FIRSTSOCKET)) {
- infof(data, "MAX_CONCURRENT_STREAMS reached, skip (%zu)",
- CONN_INUSE(check));
- continue;
- }
- /* When not multiplexed, we have a match here! */
- infof(data, "Multiplexed connection found");
+ if(CONN_INUSE(conn)) {
+ DEBUGASSERT(match->may_multiplex);
+ DEBUGASSERT(conn->bits.multiplex);
+ /* If multiplexed, make sure we do not go over concurrency limit */
+ if(CONN_INUSE(conn) >=
+ Curl_multi_max_concurrent_streams(data->multi)) {
+ infof(data, "client side MAX_CONCURRENT_STREAMS reached"
+ ", skip (%zu)", CONN_INUSE(conn));
+ return FALSE;
}
- else if(prune_if_dead(check, data)) {
- /* disconnect it, do not treat as aborted */
- Curl_disconnect(data, check, FALSE);
- continue;
+ if(CONN_INUSE(conn) >=
+ Curl_conn_get_max_concurrent(data, conn, FIRSTSOCKET)) {
+ infof(data, "MAX_CONCURRENT_STREAMS reached, skip (%zu)",
+ CONN_INUSE(conn));
+ return FALSE;
}
+ /* When not multiplexed, we have a match here! */
+ infof(data, "Multiplexed connection found");
+ }
+ else if(Curl_conn_seems_dead(conn, data, NULL)) {
+ /* removed and disconnect. Do not treat as aborted. */
+ Curl_cpool_disconnect(data, conn, FALSE);
+ return FALSE;
+ }
- /* We have found a connection. Let's stop searching. */
- chosen = check;
- break;
- } /* loop over connection bundle */
+ /* We have found a connection. Let's stop searching. */
+ match->found = conn;
+ return TRUE;
+}
- if(chosen) {
- /* mark it as used before releasing the lock */
- Curl_attach_connection(data, chosen);
- CONNCACHE_UNLOCK(data);
- *usethis = chosen;
- return TRUE; /* yes, we found one to use! */
+static bool url_match_result(bool result, void *userdata)
+{
+ struct url_conn_match *match = userdata;
+ (void)result;
+ if(match->found) {
+ /* Attach it now while still under lock, so the connection does
+ * no longer appear idle and can be reaped. */
+ Curl_attach_connection(match->data, match->found);
+ return TRUE;
}
- CONNCACHE_UNLOCK(data);
-
- if(foundPendingCandidate && data->set.pipewait) {
- infof(data,
+ else if(match->seen_single_use_conn && !match->seen_multiplex_conn) {
+ /* We've seen a single-use, existing connection to the destination and
+ * no multiplexed one. It seems safe to assume that the server does
+ * not support multiplexing. */
+ match->wait_pipe = FALSE;
+ }
+ else if(match->seen_pending_conn && match->data->set.pipewait) {
+ infof(match->data,
"Found pending candidate for reuse and CURLOPT_PIPEWAIT is set");
- *waitpipe = TRUE;
+ match->wait_pipe = TRUE;
}
+ match->force_reuse = FALSE;
+ return FALSE;
+}
- return FALSE; /* no matching connecting exists */
+/*
+ * Given one filled in connection struct (named needle), this function should
+ * detect if there already is one that has all the significant details
+ * exactly the same and thus should be used instead.
+ *
+ * If there is a match, this function returns TRUE - and has marked the
+ * connection as 'in-use'. It must later be called with ConnectionDone() to
+ * return back to 'idle' (unused) state.
+ *
+ * The force_reuse flag is set if the connection must be used.
+ */
+static bool
+ConnectionExists(struct Curl_easy *data,
+ struct connectdata *needle,
+ struct connectdata **usethis,
+ bool *force_reuse,
+ bool *waitpipe)
+{
+ struct url_conn_match match;
+ bool result;
+
+ memset(&match, 0, sizeof(match));
+ match.data = data;
+ match.needle = needle;
+ match.may_multiplex = Curl_xfer_may_multiplex(data, needle);
+
+#ifdef USE_NTLM
+ match.want_ntlm_http = ((data->state.authhost.want & CURLAUTH_NTLM) &&
+ (needle->handler->protocol & PROTO_FAMILY_HTTP));
+#ifndef CURL_DISABLE_PROXY
+ match.want_proxy_ntlm_http =
+ (needle->bits.proxy_user_passwd &&
+ (data->state.authproxy.want & CURLAUTH_NTLM) &&
+ (needle->handler->protocol & PROTO_FAMILY_HTTP));
+#endif
+#endif
+
+ /* Find a connection in the pool that matches what "data + needle"
+ * requires. If a suitable candidate is found, it is attached to "data". */
+ result = Curl_cpool_find(data, needle->destination, needle->destination_len,
+ url_match_conn, url_match_result, &match);
+
+ /* wait_pipe is TRUE if we encounter a bundle that is undecided. There
+ * is no matching connection then, yet. */
+ *usethis = match.found;
+ *force_reuse = match.force_reuse;
+ *waitpipe = match.wait_pipe;
+ return result;
}
/*
@@ -2001,6 +1960,8 @@ static CURLcode setup_connection_internals(struct Curl_easy *data,
struct connectdata *conn)
{
const struct Curl_handler *p;
+ const char *hostname;
+ int port;
CURLcode result;
/* Perform setup complement if some. */
@@ -2020,6 +1981,34 @@ static CURLcode setup_connection_internals(struct Curl_easy *data,
was very likely already set to the proxy port */
conn->primary.remote_port = p->defport;
+ /* Now create the destination name */
+#ifndef CURL_DISABLE_PROXY
+ if(conn->bits.httpproxy && !conn->bits.tunnel_proxy) {
+ hostname = conn->http_proxy.host.name;
+ port = conn->primary.remote_port;
+ }
+ else
+#endif
+ {
+ port = conn->remote_port;
+ if(conn->bits.conn_to_host)
+ hostname = conn->conn_to_host.name;
+ else
+ hostname = conn->host.name;
+ }
+
+#ifdef USE_IPV6
+ conn->destination = aprintf("%u/%d/%s", conn->scope_id, port, hostname);
+#else
+ conn->destination = aprintf("%d/%s", port, hostname);
+#endif
+ if(!conn->destination)
+ return CURLE_OUT_OF_MEMORY;
+
+ conn->destination_len = strlen(conn->destination) + 1;
+ Curl_strntolower(conn->destination, conn->destination,
+ conn->destination_len - 1);
+
return CURLE_OK;
}
@@ -3219,7 +3208,7 @@ static void reuse_conn(struct Curl_easy *data,
}
#endif
- /* Finding a connection for reuse in the cache matches, among other
+ /* Finding a connection for reuse in the cpool matches, among other
* things on the "remote-relevant" hostname. This is not necessarily
* the authority of the URL, e.g. conn->host. For example:
* - we use a proxy (not tunneling). we want to send all requests
@@ -3281,8 +3270,6 @@ static CURLcode create_conn(struct Curl_easy *data,
bool connections_available = TRUE;
bool force_reuse = FALSE;
bool waitpipe = FALSE;
- size_t max_host_connections = Curl_multi_max_host_connections(data->multi);
- size_t max_total_connections = Curl_multi_max_total_connections(data->multi);
*async = FALSE;
*in_connect = NULL;
@@ -3453,7 +3440,7 @@ static CURLcode create_conn(struct Curl_easy *data,
/* Setup a "faked" transfer that will do nothing */
if(!result) {
Curl_attach_connection(data, conn);
- result = Curl_conncache_add_conn(data);
+ result = Curl_cpool_add_conn(data, conn);
if(result)
goto out;
@@ -3489,7 +3476,8 @@ static CURLcode create_conn(struct Curl_easy *data,
if(result)
goto out;
- prune_dead_connections(data);
+ /* FIXME: do we really want to run this every time we add a transfer? */
+ Curl_cpool_prune_dead(data);
/*************************************************************
* Check the current list of connections to see if we can
@@ -3548,41 +3536,12 @@ static CURLcode create_conn(struct Curl_easy *data,
"soon", and we wait for that */
connections_available = FALSE;
else {
- /* this gets a lock on the conncache */
- struct connectbundle *bundle =
- Curl_conncache_find_bundle(data, conn, data->state.conn_cache);
-
- if(max_host_connections > 0 && bundle &&
- (bundle->num_connections >= max_host_connections)) {
- struct connectdata *conn_candidate;
-
- /* The bundle is full. Extract the oldest connection. */
- conn_candidate = Curl_conncache_extract_bundle(data, bundle);
- CONNCACHE_UNLOCK(data);
-
- if(conn_candidate)
- Curl_disconnect(data, conn_candidate, FALSE);
- else {
- infof(data, "No more connections allowed to host: %zu",
- max_host_connections);
- connections_available = FALSE;
- }
- }
- else
- CONNCACHE_UNLOCK(data);
-
- }
-
- if(connections_available &&
- (max_total_connections > 0) &&
- (Curl_conncache_size(data) >= max_total_connections)) {
- struct connectdata *conn_candidate;
-
- /* The cache is full. Let's see if we can kill a connection. */
- conn_candidate = Curl_conncache_extract_oldest(data);
- if(conn_candidate)
- Curl_disconnect(data, conn_candidate, FALSE);
- else
+ switch(Curl_cpool_check_limits(data, conn)) {
+ case CPOOL_LIMIT_DEST:
+ infof(data, "No more connections allowed to host");
+ connections_available = FALSE;
+ break;
+ case CPOOL_LIMIT_TOTAL:
#ifndef CURL_DISABLE_DOH
if(data->set.dohfor_mid >= 0)
infof(data, "Allowing DoH to override max connection limit");
@@ -3592,6 +3551,10 @@ static CURLcode create_conn(struct Curl_easy *data,
infof(data, "No connections available in cache");
connections_available = FALSE;
}
+ break;
+ default:
+ break;
+ }
}
if(!connections_available) {
@@ -3615,7 +3578,7 @@ static CURLcode create_conn(struct Curl_easy *data,
}
Curl_attach_connection(data, conn);
- result = Curl_conncache_add_conn(data);
+ result = Curl_cpool_add_conn(data, conn);
if(result)
goto out;
}
@@ -3755,8 +3718,7 @@ CURLcode Curl_connect(struct Curl_easy *data,
/* We are not allowed to return failure with memory left allocated in the
connectdata struct, free those here */
Curl_detach_connection(data);
- Curl_conncache_remove_conn(data, conn, TRUE);
- Curl_disconnect(data, conn, TRUE);
+ Curl_cpool_disconnect(data, conn, TRUE);
}
return result;
lib/url.h+17 -2
@@ -37,8 +37,8 @@ void Curl_freeset(struct Curl_easy *data);
CURLcode Curl_uc_to_curlcode(CURLUcode uc);
CURLcode Curl_close(struct Curl_easy **datap); /* opposite of curl_open() */
CURLcode Curl_connect(struct Curl_easy *, bool *async, bool *protocol_connect);
-void Curl_disconnect(struct Curl_easy *data,
- struct connectdata *, bool aborted);
+bool Curl_on_disconnect(struct Curl_easy *data,
+ struct connectdata *, bool aborted);
CURLcode Curl_setup_conn(struct Curl_easy *data,
bool *protocol_done);
void Curl_conn_free(struct Curl_easy *data, struct connectdata *conn);
@@ -65,6 +65,21 @@ void Curl_verboseconnect(struct Curl_easy *data, struct connectdata *conn,
int sockindex);
#endif
+/**
+ * Return TRUE iff the given connection is considered dead.
+ * @param nowp NULL or pointer to time being checked against.
+ */
+bool Curl_conn_seems_dead(struct connectdata *conn,
+ struct Curl_easy *data,
+ struct curltime *nowp);
+
+/**
+ * Perform upkeep operations on the connection.
+ */
+CURLcode Curl_conn_upkeep(struct Curl_easy *data,
+ struct connectdata *conn,
+ struct curltime *now);
+
#if defined(USE_HTTP2) || defined(USE_HTTP3)
void Curl_data_priority_clear_state(struct Curl_easy *data);
#else
lib/urldata.h+10 -13
@@ -555,6 +555,7 @@ struct ConnectBits {
BIT(aborted); /* connection was aborted, e.g. in unclean state */
BIT(shutdown_handler); /* connection shutdown: handler shut down */
BIT(shutdown_filters); /* connection shutdown: filters shut down */
+ BIT(in_cpool); /* connection is kept in a connection pool */
};
struct hostname {
@@ -802,12 +803,12 @@ struct ldapconninfo;
* unique for an entire connection.
*/
struct connectdata {
- struct Curl_llist_node bundle_node; /* conncache */
+ struct Curl_llist_node cpool_node; /* conncache lists */
curl_closesocket_callback fclosesocket; /* function closing the socket(s) */
void *closesocket_client;
- /* This is used by the connection cache logic. If this returns TRUE, this
+ /* This is used by the connection pool logic. If this returns TRUE, this
handle is still used by one or more easy handles and can only used by any
other easy handle without careful consideration (== only for
multiplexing) and it cannot be used by another multi handle! */
@@ -816,6 +817,8 @@ struct connectdata {
/**** Fields set when inited and not modified again */
curl_off_t connection_id; /* Contains a unique number to make it easier to
track the connections in the log output */
+ char *destination; /* string carrying normalized hostname+port+scope */
+ size_t destination_len; /* strlen(destination) + 1 */
/* 'dns_entry' is the particular host we use. This points to an entry in the
DNS cache and it will not get pruned while locked. It gets unlocked in
@@ -851,7 +854,7 @@ struct connectdata {
char *oauth_bearer; /* OAUTH2 bearer, allocated */
struct curltime now; /* "current" time */
struct curltime created; /* creation time */
- struct curltime lastused; /* when returned to the connection cache */
+ struct curltime lastused; /* when returned to the connection poolas idle */
curl_socket_t sock[2]; /* two sockets, the second is used for the data
transfer when doing FTP */
Curl_recv *recv[2];
@@ -971,7 +974,6 @@ struct connectdata {
unsigned int unused:1; /* avoids empty union */
} proto;
- struct connectbundle *bundle; /* The bundle we are member of */
#ifdef USE_UNIX_SOCKETS
char *unix_domain_socket;
#endif
@@ -1050,7 +1052,7 @@ struct PureInfo {
even when the session handle is no longer associated with a connection,
and also allow curl_easy_reset() to clear this information from the
session handle without disturbing information which is still alive, and
- that might be reused, in the connection cache. */
+ that might be reused, in the connection pool. */
struct ip_quadruple primary;
int conn_remote_port; /* this is the "remote port", which is the port
number of the used URL, independent of proxy or
@@ -1218,8 +1220,6 @@ struct urlpieces {
};
struct UrlState {
- /* Points to the connection cache */
- struct conncache *conn_cache;
/* buffers to store authentication data in, as parsed from input options */
struct curltime keeps_speed; /* for the progress meter really */
@@ -1369,9 +1369,6 @@ struct UrlState {
unsigned char select_bits; /* != 0 -> bitmask of socket events for this
transfer overriding anything the socket may
report */
-#ifdef DEBUGBUILD
- BIT(conncache_lock);
-#endif
/* when curl_easy_perform() is called, the multi handle is "owned" by
the easy handle so curl_easy_cleanup() on such an easy handle will
also close the multi handle! */
@@ -1907,13 +1904,13 @@ struct Curl_easy {
/* First a simple identifier to easier detect if a user mix up this easy
handle with a multi handle. Set this to CURLEASY_MAGIC_NUMBER */
unsigned int magic;
- /* once an easy handle is tied to a connection cache
+ /* once an easy handle is tied to a connection pool
a non-negative number to distinguish this transfer from
- other using the same cache. For easier tracking
+ other using the same pool. For easier tracking
in log output.
This may wrap around after LONG_MAX to 0 again, so it
has no uniqueness guarantee for very large processings.
- Note: it has no uniqueness either IFF more than one connection cache
+ Note: it has no uniqueness either IFF more than one connection pool
is used by the libcurl application. */
curl_off_t id;
/* once an easy handle is added to a multi, either explicitly by the
lib/vquic/curl_msh3.c+0 -1
@@ -911,7 +911,6 @@ static CURLcode cf_msh3_connect(struct Curl_cfilter *cf,
CURL_TRC_CF(data, cf, "handshake succeeded");
cf->conn->bits.multiplex = TRUE; /* at least potentially multiplexed */
cf->conn->httpversion = 30;
- cf->conn->bundle->multiuse = BUNDLE_MULTIPLEX;
cf->connected = TRUE;
cf->conn->alpn = CURL_HTTP_VERSION_3;
*done = TRUE;
lib/vquic/curl_ngtcp2.c+0 -1
@@ -1628,7 +1628,6 @@ static CURLcode qng_verify_peer(struct Curl_cfilter *cf,
cf->conn->bits.multiplex = TRUE; /* at least potentially multiplexed */
cf->conn->httpversion = 30;
- cf->conn->bundle->multiuse = BUNDLE_MULTIPLEX;
return Curl_vquic_tls_verify_peer(&ctx->tls, cf, data, &ctx->peer);
}
lib/vquic/curl_osslq.c+0 -1
@@ -562,7 +562,6 @@ static CURLcode cf_osslq_verify_peer(struct Curl_cfilter *cf,
cf->conn->bits.multiplex = TRUE; /* at least potentially multiplexed */
cf->conn->httpversion = 30;
- cf->conn->bundle->multiuse = BUNDLE_MULTIPLEX;
return Curl_vquic_tls_verify_peer(&ctx->tls, cf, data, &ctx->peer);
}
lib/vquic/curl_quiche.c+0 -1
@@ -1380,7 +1380,6 @@ static CURLcode cf_quiche_verify_peer(struct Curl_cfilter *cf,
cf->conn->bits.multiplex = TRUE; /* at least potentially multiplexed */
cf->conn->httpversion = 30;
- cf->conn->bundle->multiuse = BUNDLE_MULTIPLEX;
return Curl_vquic_tls_verify_peer(&ctx->tls, cf, data, &ctx->peer);
}
lib/vtls/sectransp.c+0 -3
@@ -2108,9 +2108,6 @@ check_handshake:
else
infof(data, VTLS_INFOF_NO_ALPN);
- Curl_multiuse_state(data, cf->conn->alpn == CURL_HTTP_VERSION_2 ?
- BUNDLE_MULTIPLEX : BUNDLE_NO_MULTIUSE);
-
/* chosenProtocol is a reference to the string within alpnArr
and does not need to be freed separately */
if(alpnArr)
lib/vtls/vtls.c+0 -6
@@ -2222,7 +2222,6 @@ CURLcode Curl_alpn_set_negotiated(struct Curl_cfilter *cf,
const unsigned char *proto,
size_t proto_len)
{
- int can_multi = 0;
unsigned char *palpn =
#ifndef CURL_DISABLE_PROXY
(cf->conn->bits.tunnel_proxy && Curl_ssl_cf_is_proxy(cf))?
@@ -2241,14 +2240,12 @@ CURLcode Curl_alpn_set_negotiated(struct Curl_cfilter *cf,
else if(proto_len == ALPN_H2_LENGTH &&
!memcmp(ALPN_H2, proto, ALPN_H2_LENGTH)) {
*palpn = CURL_HTTP_VERSION_2;
- can_multi = 1;
}
#endif
#ifdef USE_HTTP3
else if(proto_len == ALPN_H3_LENGTH &&
!memcmp(ALPN_H3, proto, ALPN_H3_LENGTH)) {
*palpn = CURL_HTTP_VERSION_3;
- can_multi = 1;
}
#endif
else {
@@ -2267,9 +2264,6 @@ CURLcode Curl_alpn_set_negotiated(struct Curl_cfilter *cf,
}
out:
- if(!Curl_ssl_cf_is_proxy(cf))
- Curl_multiuse_state(data, can_multi?
- BUNDLE_MULTIPLEX : BUNDLE_NO_MULTIUSE);
return CURLE_OK;
}
tests/data/test1554+48 -58
@@ -19,67 +19,57 @@ Content-Length: 29
run 1: foobar and so on fun!
</data>
<datacheck>
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
+-> Mutex lock SHARE
+<- Mutex unlock SHARE
+-> Mutex lock CONNECT
+<- Mutex unlock CONNECT
+-> Mutex lock CONNECT
+<- Mutex unlock CONNECT
+-> Mutex lock CONNECT
+<- Mutex unlock CONNECT
+-> Mutex lock CONNECT
+<- Mutex unlock CONNECT
run 1: foobar and so on fun!
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
+-> Mutex lock CONNECT
+<- Mutex unlock CONNECT
+-> Mutex lock CONNECT
+<- Mutex unlock CONNECT
+-> Mutex lock SHARE
+<- Mutex unlock SHARE
+-> Mutex lock SHARE
+<- Mutex unlock SHARE
+-> Mutex lock CONNECT
+<- Mutex unlock CONNECT
+-> Mutex lock CONNECT
+<- Mutex unlock CONNECT
+-> Mutex lock CONNECT
+<- Mutex unlock CONNECT
run 1: foobar and so on fun!
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
+-> Mutex lock CONNECT
+<- Mutex unlock CONNECT
+-> Mutex lock CONNECT
+<- Mutex unlock CONNECT
+-> Mutex lock SHARE
+<- Mutex unlock SHARE
+-> Mutex lock SHARE
+<- Mutex unlock SHARE
+-> Mutex lock CONNECT
+<- Mutex unlock CONNECT
+-> Mutex lock CONNECT
+<- Mutex unlock CONNECT
+-> Mutex lock CONNECT
+<- Mutex unlock CONNECT
run 1: foobar and so on fun!
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
--> Mutex lock
-<- Mutex unlock
+-> Mutex lock CONNECT
+<- Mutex unlock CONNECT
+-> Mutex lock CONNECT
+<- Mutex unlock CONNECT
+-> Mutex lock SHARE
+<- Mutex unlock SHARE
+-> Mutex lock SHARE
+-> Mutex lock CONNECT
+<- Mutex unlock CONNECT
+<- Mutex unlock SHARE
</datacheck>
</reply>
tests/libtest/lib1554.c+14 -2
@@ -24,6 +24,18 @@
#include "test.h"
#include "memdebug.h"
+static const char *ldata_names[] = {
+ "NONE",
+ "SHARE",
+ "COOKIE",
+ "DNS",
+ "SESSION",
+ "CONNECT",
+ "PSL",
+ "HSTS",
+ "NULL",
+};
+
static void my_lock(CURL *handle, curl_lock_data data,
curl_lock_access laccess, void *useptr)
{
@@ -31,7 +43,7 @@ static void my_lock(CURL *handle, curl_lock_data data,
(void)data;
(void)laccess;
(void)useptr;
- printf("-> Mutex lock\n");
+ printf("-> Mutex lock %s\n", ldata_names[data]);
}
static void my_unlock(CURL *handle, curl_lock_data data, void *useptr)
@@ -39,7 +51,7 @@ static void my_unlock(CURL *handle, curl_lock_data data, void *useptr)
(void)handle;
(void)data;
(void)useptr;
- printf("<- Mutex unlock\n");
+ printf("<- Mutex unlock %s\n", ldata_names[data]);
}
/* test function */