public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/curl] f45: curl-8.21.0-9
@ 2026-11-03  9:10 Jan Macku
  0 siblings, 0 replies; only message in thread
From: Jan Macku @ 2026-11-03  9:10 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/curl
            Branch : f45
            Commit : 3579be21b348acb7bce6447cad67bf0ba7009381
            Author : Jan Macku <jamacku@redhat.com>
            Date   : 2026-11-02T15:24:22+01:00
            Stats  : +3105/-3018 in 21 file(s)
            URL    : https://src.fedoraproject.org/rpms/curl/c/3579be21b348acb7bce6447cad67bf0ba7009381?branch=f45

            Log:
            curl-8.21.0-9

Resolves: CVE-2026-92392

---
diff --git a/0001-curl-8.21.0-lib-add-multi_wakeup_internal.patch b/0001-curl-8.21.0-lib-add-multi_wakeup_internal.patch
deleted file mode 100644
index a3fa19f..0000000
--- a/0001-curl-8.21.0-lib-add-multi_wakeup_internal.patch
+++ /dev/null
@@ -1,343 +0,0 @@
-From 57811ff4ebbc490dd58c2477f5cc3604eb79368e Mon Sep 17 00:00:00 2001
-From: Stefan Eissing <stefan@eissing.org>
-Date: Wed, 8 Jul 2026 10:34:51 +0200
-Subject: [PATCH] lib: add multi_wakeup_internal
-
-For threaded resolving, added an additional socket/eventfd pair to the
-multi handle for notifications from threads. The original "double use"
-of the standard wakeup pair did lead to regressions for apps.
-
-The API definition of curl_multi_poll/wait/wakeup is pretty tight
-regarding what effects what and adding notifications on top of that
-broke what apps perceived to be the contract.
-
-Fixes #22272
-Reported-by: Sergei Zimmerman
-Closes #22274
-
-(cherry picked from commit 009fd378e8f01c97ebe67a14a41a06d56430f3df)
----
- lib/asyn-thrdd.c           |  8 +++---
- lib/multi.c                | 36 ++++++++++++++++++++++----
- lib/multihandle.h          | 13 +++++++++-
- lib/multiif.h              |  4 +++
- tests/data/Makefile.am     |  2 +-
- tests/data/test2414        | 30 +++++++++++++++++++++
- tests/libtest/Makefile.inc |  2 +-
- tests/libtest/lib2414.c    | 53 ++++++++++++++++++++++++++++++++++++++
- 8 files changed, 136 insertions(+), 12 deletions(-)
- create mode 100644 tests/data/test2414
- create mode 100644 tests/libtest/lib2414.c
-
-diff --git a/lib/asyn-thrdd.c b/lib/asyn-thrdd.c
-index aeadec11a4..90f91ff998 100644
---- a/lib/asyn-thrdd.c
-+++ b/lib/asyn-thrdd.c
-@@ -407,7 +407,7 @@ static void async_thrdd_item_process(void *arg)
- 
- #endif /* HAVE_GETADDRINFO */
- 
--#ifdef ENABLE_WAKEUP
-+#ifdef ENABLE_INTERNAL_WAKEUP
- static void async_thrdd_event(const struct curl_thrdq *tqueue,
-                               Curl_thrdq_event ev,
-                               void *user_data)
-@@ -416,7 +416,7 @@ static void async_thrdd_event(const struct curl_thrdq *tqueue,
-   (void)tqueue;
-   switch(ev) {
-   case CURL_THRDQ_EV_ITEM_DONE:
--    (void)curl_multi_wakeup(multi);
-+    Curl_multi_wakeup_internal(multi);
-     break;
-   default:
-     break;
-@@ -663,7 +663,7 @@ CURLcode Curl_async_pollset(struct Curl_easy *data,
- #endif
- 
-   if(!async->done) {
--#ifndef ENABLE_WAKEUP
-+#ifndef ENABLE_INTERNAL_WAKEUP
-     timediff_t stutter_ms, elapsed_ms;
-     elapsed_ms = curlx_ptimediff_ms(Curl_pgrs_now(data), &async->start);
-     if(elapsed_ms < 3)
-@@ -706,7 +706,7 @@ CURLcode Curl_async_take_result(struct Curl_easy *data,
-   if(thrdd->rr.channel)
-     (void)Curl_ares_perform(thrdd->rr.channel, 0);
- #endif
--#ifndef ENABLE_WAKEUP
-+#ifndef ENABLE_INTERNAL_WAKEUP
-   Curl_async_thrdd_multi_process(data->multi);
- #endif
- 
-diff --git a/lib/multi.c b/lib/multi.c
-index d6ae111d8e..1ae679565e 100644
---- a/lib/multi.c
-+++ b/lib/multi.c
-@@ -268,6 +268,10 @@ struct Curl_multi *Curl_multi_handle(uint32_t xfer_table_size,
-   multi->wakeup_pair[0] = CURL_SOCKET_BAD;
-   multi->wakeup_pair[1] = CURL_SOCKET_BAD;
- #endif
-+#ifdef ENABLE_INTERNAL_WAKEUP
-+  multi->wakeup_internal[0] = CURL_SOCKET_BAD;
-+  multi->wakeup_internal[1] = CURL_SOCKET_BAD;
-+#endif
- 
-   if(Curl_mntfy_resize(multi) ||
-      Curl_uint32_bset_resize(&multi->process, xfer_table_size) ||
-@@ -315,6 +319,10 @@ struct Curl_multi *Curl_multi_handle(uint32_t xfer_table_size,
-   if(Curl_wakeup_init(multi->wakeup_pair, TRUE) < 0)
-     goto error;
- #endif
-+#ifdef ENABLE_INTERNAL_WAKEUP
-+  if(Curl_wakeup_init(multi->wakeup_internal, TRUE) < 0)
-+    goto error;
-+#endif
- 
-   if(Curl_probeipv6(multi))
-     goto error;
-@@ -360,6 +368,9 @@ error:
- #ifdef ENABLE_WAKEUP
-   Curl_wakeup_destroy(multi->wakeup_pair);
- #endif
-+#ifdef ENABLE_INTERNAL_WAKEUP
-+  Curl_wakeup_destroy(multi->wakeup_internal);
-+#endif
- 
-   curlx_free(multi);
-   return NULL;
-@@ -395,7 +406,7 @@ bool Curl_is_connecting(struct Curl_easy *data)
- 
- static CURLMcode multi_assess_wakeup(struct Curl_multi *multi)
- {
--#ifdef ENABLE_WAKEUP
-+#ifdef ENABLE_INTERNAL_WAKEUP
-   if(multi->socket_cb)
-     return Curl_multi_ev_assess_xfer(multi, multi->admin);
- #else
-@@ -1149,14 +1160,14 @@ CURLMcode Curl_multi_pollset(struct Curl_easy *data,
-   CURLcode result = CURLE_OK;
- 
-   Curl_pollset_reset(ps);
--#ifdef ENABLE_WAKEUP
-+#ifdef ENABLE_INTERNAL_WAKEUP
-   /* The admin handle always listens on the wakeup socket when there
-    * are transfers alive. */
-   if(data->multi && (data == data->multi->admin) &&
-      data->multi->xfers_really_alive) {
-     CURL_TRC_M(data, "adding wakeup, %u xfers really alive",
-                data->multi->xfers_really_alive);
--    result = Curl_pollset_add_in(data, ps, data->multi->wakeup_pair[0]);
-+    result = Curl_pollset_add_in(data, ps, data->multi->wakeup_internal[0]);
-   }
- #endif
-   /* If the transfer has no connection, this is fine. Happens when
-@@ -1714,6 +1725,18 @@ CURLMcode curl_multi_wakeup(CURLM *m)
-   return mresult;
- }
- 
-+#ifdef ENABLE_INTERNAL_WAKEUP
-+void Curl_multi_wakeup_internal(struct Curl_multi *multi)
-+{
-+  /* This is expected to be invocable from another thread which
-+   * does NOT outlive the multi handle. Check for sanity. */
-+  if(GOOD_MULTI_HANDLE(multi))
-+    Curl_wakeup_signal(multi->wakeup_internal);
-+  else
-+    DEBUGASSERT(0);
-+}
-+#endif
-+
- /*
-  * multi_ischanged() is called
-  *
-@@ -2740,10 +2763,10 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
-   Curl_uint32_bset_remove(&multi->dirty, data->mid);
- 
-   if(data == multi->admin) {
--#ifdef ENABLE_WAKEUP
-+#ifdef ENABLE_INTERNAL_WAKEUP
-     /* Consume any pending wakeup signals before processing.
-      * This is necessary for event based processing. See #21547 */
--    (void)Curl_wakeup_consume(multi->wakeup_pair, TRUE);
-+    (void)Curl_wakeup_consume(multi->wakeup_internal, TRUE);
- #endif
- #ifdef USE_RESOLV_THREADED
-     Curl_async_thrdd_multi_process(multi);
-@@ -3051,6 +3074,9 @@ CURLMcode curl_multi_cleanup(CURLM *m)
- #ifdef ENABLE_WAKEUP
-   Curl_wakeup_destroy(multi->wakeup_pair);
- #endif
-+#ifdef ENABLE_INTERNAL_WAKEUP
-+  Curl_wakeup_destroy(multi->wakeup_internal);
-+#endif
- 
-     multi_xfer_bufs_free(multi);
-     Curl_mntfy_cleanup(multi);
-diff --git a/lib/multihandle.h b/lib/multihandle.h
-index 19dd2ffcdf..e9bbfaea90 100644
---- a/lib/multihandle.h
-+++ b/lib/multihandle.h
-@@ -73,6 +73,11 @@ typedef enum {
- #if !defined(CURL_DISABLE_SOCKETPAIR) && !defined(USE_WINSOCK)
- #define ENABLE_WAKEUP
- #endif
-+#if !defined(CURL_DISABLE_SOCKETPAIR) && \
-+    defined(USE_RESOLV_THREADED) && \
-+    !defined(USE_WINSOCK)
-+#define ENABLE_INTERNAL_WAKEUP
-+#endif
- 
- /* value for MAXIMUM CONCURRENT STREAMS upper limit */
- #define INITIAL_MAX_CONCURRENT_STREAMS ((1U << 31) - 1)
-@@ -168,7 +173,13 @@ struct Curl_multi {
- #ifdef ENABLE_WAKEUP
-   curl_socket_t wakeup_pair[2]; /* eventfd()/pipe()/socketpair() used for
-                                    wakeup 0 is used for read, 1 is used
--                                   for write */
-+                                   for write. Used by curl_multi_wakeup() */
-+#endif
-+#ifdef ENABLE_INTERNAL_WAKEUP
-+  curl_socket_t wakeup_internal[2]; /* eventfd()/pipe()/socketpair() used for
-+                                   wakeup 0 is used for read, 1 is used
-+                                   for write. Used for internal wakeups,
-+                                   e.g. threaded resolver. */
- #endif
-   unsigned int max_concurrent_streams;
-   unsigned int maxconnects; /* if >0, a fixed limit of the maximum number of
-diff --git a/lib/multiif.h b/lib/multiif.h
-index 039db269e0..920bf0e917 100644
---- a/lib/multiif.h
-+++ b/lib/multiif.h
-@@ -164,4 +164,8 @@ void Curl_multi_clear_dirty(struct Curl_easy *data);
- 
- void Curl_multi_set_now(struct Curl_multi *multi);
- 
-+#ifdef ENABLE_INTERNAL_WAKEUP
-+void Curl_multi_wakeup_internal(struct Curl_multi *multi);
-+#endif
-+
- #endif /* HEADER_CURL_MULTIIF_H */
-diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
-index 9fb1720f7c..69bfdc9134 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -263,7 +263,7 @@ test2300 test2301 test2302 test2303 test2304 test2306 test2307 test2308 \
- test2309 test2310 test2311 \
- \
- test2400 test2401 test2402 test2403 test2404 test2405 test2406 test2407 \
--test2408 test2409 test2410 test2411 test2412 test2413 \
-+test2408 test2409 test2410 test2411 test2412 test2413 test2414 \
- \
- test2500 test2501 test2502 test2503 test2504 test2505 test2506 \
- \
-diff --git a/tests/data/test2414 b/tests/data/test2414
-new file mode 100644
-index 0000000000..197beffe8f
---- /dev/null
-+++ b/tests/data/test2414
-@@ -0,0 +1,30 @@
-+<?xml version="1.0" encoding="US-ASCII"?>
-+<testcase>
-+<info>
-+<keywords>
-+multi
-+wakeup
-+</keywords>
-+</info>
-+
-+# Client-side
-+<client>
-+<features>
-+wakeup
-+</features>
-+<server>
-+</server>
-+<tool>
-+lib%TESTNUMBER
-+</tool>
-+<name>
-+wakeup, perform and poll needs to exit
-+</name>
-+<command>
-+</command>
-+</client>
-+
-+# Verify data after the test has been "shot"
-+<verify>
-+</verify>
-+</testcase>
-diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
-index bec648542b..8d97421f4e 100644
---- a/tests/libtest/Makefile.inc
-+++ b/tests/libtest/Makefile.inc
-@@ -115,7 +115,7 @@ TESTS_C = \
-   lib2023.c lib2032.c lib2082.c \
-   lib2301.c lib2302.c lib2304.c           lib2306.c lib2308.c lib2309.c \
-   lib2402.c           lib2404.c lib2405.c \
--  lib2412.c \
-+  lib2412.c           lib2414.c \
-   lib2502.c lib2504.c lib2505.c lib2506.c \
-   lib2700.c \
-   lib3010.c lib3025.c lib3026.c lib3027.c lib3033.c lib3034.c \
-diff --git a/tests/libtest/lib2414.c b/tests/libtest/lib2414.c
-new file mode 100644
-index 0000000000..e04dff3de7
---- /dev/null
-+++ b/tests/libtest/lib2414.c
-@@ -0,0 +1,53 @@
-+/***************************************************************************
-+ *                                  _   _ ____  _
-+ *  Project                     ___| | | |  _ \| |
-+ *                             / __| | | | |_) | |
-+ *                            | (__| |_| |  _ <| |___
-+ *                             \___|\___/|_| \_\_____|
-+ *
-+ * Copyright (C) Dmitry Karpov <dkarpov1970@gmail.com>
-+ *
-+ * This software is licensed as described in the file COPYING, which
-+ * you should have received as part of this distribution. The terms
-+ * are also available at https://curl.se/docs/copyright.html.
-+ *
-+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
-+ * copies of the Software, and permit persons to whom the Software is
-+ * furnished to do so, under the terms of the COPYING file.
-+ *
-+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
-+ * KIND, either express or implied.
-+ *
-+ * SPDX-License-Identifier: curl
-+ *
-+ ***************************************************************************/
-+
-+#include "first.h"
-+#include "testtrace.h"
-+
-+static CURLcode test_lib2414(const char *URL)
-+{
-+  CURLM *multi = NULL;
-+  CURLcode result = CURLE_OK;
-+  int running;
-+
-+  (void)URL;
-+  global_init(CURL_GLOBAL_ALL);
-+
-+  multi = curl_multi_init();
-+  if(!multi) {
-+    curl_mfprintf(stderr, "curl_multi_init() failed\n");
-+    result = TEST_ERR_MAJOR_BAD;
-+    goto test_cleanup;
-+  }
-+
-+  curl_multi_wakeup(multi);
-+  curl_multi_perform(multi, &running);
-+  curl_multi_poll(multi, NULL, 0, INT_MAX, NULL);
-+
-+test_cleanup:
-+  if(multi)
-+    curl_multi_cleanup(multi);
-+  curl_global_cleanup();
-+  return result;
-+}
--- 
-2.55.0
-

diff --git a/0001-prevent-multilib-conflicts-on-the-curl-config-script.patch b/0001-prevent-multilib-conflicts-on-the-curl-config-script.patch
new file mode 100644
index 0000000..b1c3fd7
--- /dev/null
+++ b/0001-prevent-multilib-conflicts-on-the-curl-config-script.patch
@@ -0,0 +1,90 @@
+From b718e10fe474fdf8534a77111fbc83f1ac939aa1 Mon Sep 17 00:00:00 2001
+From: Kamil Dudka <kdudka@redhat.com>
+Date: Fri, 12 Apr 2013 12:04:05 +0200
+Subject: [PATCH] prevent multilib conflicts on the curl-config script
+
+fedora-only
+---
+ curl-config.in      | 23 +++++------------------
+ docs/curl-config.md |  4 +++-
+ libcurl.pc.in       |  1 +
+ 3 files changed, 9 insertions(+), 19 deletions(-)
+
+diff --git a/curl-config.in b/curl-config.in
+index a1c8185875..bb43ca8335 100644
+--- a/curl-config.in
++++ b/curl-config.in
+@@ -74,7 +74,7 @@ while test "$#" -gt 0; do
+     ;;
+ 
+   --cc)
+-    echo '@CC@'
++    echo 'gcc'
+     ;;
+ 
+   --prefix)
+@@ -149,16 +149,7 @@ while test "$#" -gt 0; do
+     ;;
+ 
+   --libs)
+-    if test "@libdir@" != '/usr/lib' && test "@libdir@" != '/usr/lib64'; then
+-      curllibdir="-L@libdir@ "
+-    else
+-      curllibdir=''
+-    fi
+-    if test '@ENABLE_SHARED@' = 'no'; then
+-      echo "${curllibdir}-lcurl @LIBCURL_PC_LIBS_PRIVATE@"
+-    else
+-      echo "${curllibdir}-lcurl"
+-    fi
++    echo '-lcurl'
+     ;;
+ 
+   --ssl-backends)
+@@ -166,16 +157,12 @@ while test "$#" -gt 0; do
+     ;;
+ 
+   --static-libs)
+-    if test '@ENABLE_STATIC@' != 'no'; then
+-      echo "@libdir@/libcurl.@libext@ @LIBCURL_PC_LDFLAGS_PRIVATE@ @LIBCURL_PC_LIBS_PRIVATE@"
+-    else
+-      echo 'curl was built with static libraries disabled' >&2
+-      exit 1
+-    fi
++    echo 'curl was built with static libraries disabled' >&2
++    exit 1
+     ;;
+ 
+   --configure)
+-    echo @CONFIGURE_OPTIONS@
++    pkg-config libcurl --variable=configure_options | sed 's/^"//;s/"$//'
+     ;;
+ 
+   *)
+diff --git a/docs/curl-config.md b/docs/curl-config.md
+index 12ad245b79..fa0e03d273 100644
+--- a/docs/curl-config.md
++++ b/docs/curl-config.md
+@@ -87,7 +87,9 @@ no, one or several names. If more than one name, they appear comma-separated.
+ ## `--static-libs`
+ 
+ Shows the complete set of libs and other linker options you need in order to
+-link your application with libcurl statically. (Added in 7.17.1)
++link your application with libcurl statically. Note that Fedora/RHEL libcurl
++packages do not provide any static libraries, thus cannot be linked statically.
++(Added in 7.17.1)
+ 
+ ## `--version`
+ 
+diff --git a/libcurl.pc.in b/libcurl.pc.in
+index c0ba5244a8..f3645e1748 100644
+--- a/libcurl.pc.in
++++ b/libcurl.pc.in
+@@ -28,6 +28,7 @@ libdir=@libdir@
+ includedir=@includedir@
+ supported_protocols="@SUPPORT_PROTOCOLS@"
+ supported_features="@SUPPORT_FEATURES@"
++configure_options=@CONFIGURE_OPTIONS@
+ 
+ Name: libcurl
+ URL: https://curl.se/

diff --git a/0002-curl-8.21.0-CVE-2026-18924.patch b/0002-curl-8.21.0-CVE-2026-18924.patch
deleted file mode 100644
index aa41faf..0000000
--- a/0002-curl-8.21.0-CVE-2026-18924.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-From ba8251ada2ae2e01fdd09776ac84041193aa3509 Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Wed, 5 Aug 2026 10:02:53 +0200
-Subject: [PATCH 1/2] http2: make server push transfers inherit share from
- parent
-
-Reported-by: Stephan Zeisberg
-Closes #22488
-
-(cherry picked from commit 90325ff0444cbdff368bda5d26d6405a0bb6ee43)
----
- lib/http2.c | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/lib/http2.c b/lib/http2.c
-index a820439ef4..a0c147cdc1 100644
---- a/lib/http2.c
-+++ b/lib/http2.c
-@@ -46,6 +46,7 @@
- #include "bufref.h"
- #include "curlx/dynbuf.h"
- #include "headers.h"
-+#include "curl_share.h"
- 
- #if NGHTTP2_VERSION_NUM < 0x010f00
- #error "nghttp2 1.15.0 or greater required"
-@@ -704,6 +705,8 @@ static struct Curl_easy *h2_duphandle(struct Curl_cfilter *cf,
-     struct h2_stream_ctx *second_stream;
-     http2_data_setup(cf, second, &second_stream);
-     second->state.priority.weight = data->state.priority.weight;
-+    if(data->share)
-+      (void)Curl_share_easy_link(second, data->share);
-   }
-   return second;
- }
--- 
-2.55.0
-

diff --git a/0002-lib-add-multi_wakeup_internal.patch b/0002-lib-add-multi_wakeup_internal.patch
new file mode 100644
index 0000000..c91aef7
--- /dev/null
+++ b/0002-lib-add-multi_wakeup_internal.patch
@@ -0,0 +1,340 @@
+From 43f2118afa58f1b294658c568516de624c8b9ce3 Mon Sep 17 00:00:00 2001
+From: Stefan Eissing <stefan@eissing.org>
+Date: Wed, 8 Jul 2026 10:34:51 +0200
+Subject: [PATCH] lib: add multi_wakeup_internal
+
+For threaded resolving, added an additional socket/eventfd pair to the
+multi handle for notifications from threads. The original "double use"
+of the standard wakeup pair did lead to regressions for apps.
+
+The API definition of curl_multi_poll/wait/wakeup is pretty tight
+regarding what effects what and adding notifications on top of that
+broke what apps perceived to be the contract.
+
+Fixes #22272
+Reported-by: Sergei Zimmerman
+Closes #22274
+
+(cherry picked from commit 009fd378e8f01c97ebe67a14a41a06d56430f3df)
+---
+ lib/asyn-thrdd.c           |  8 +++---
+ lib/multi.c                | 36 ++++++++++++++++++++++----
+ lib/multihandle.h          | 13 +++++++++-
+ lib/multiif.h              |  4 +++
+ tests/data/Makefile.am     |  2 +-
+ tests/data/test2414        | 30 +++++++++++++++++++++
+ tests/libtest/Makefile.inc |  2 +-
+ tests/libtest/lib2414.c    | 53 ++++++++++++++++++++++++++++++++++++++
+ 8 files changed, 136 insertions(+), 12 deletions(-)
+ create mode 100644 tests/data/test2414
+ create mode 100644 tests/libtest/lib2414.c
+
+diff --git a/lib/asyn-thrdd.c b/lib/asyn-thrdd.c
+index aeadec11a4..90f91ff998 100644
+--- a/lib/asyn-thrdd.c
++++ b/lib/asyn-thrdd.c
+@@ -407,7 +407,7 @@ static void async_thrdd_item_process(void *arg)
+ 
+ #endif /* HAVE_GETADDRINFO */
+ 
+-#ifdef ENABLE_WAKEUP
++#ifdef ENABLE_INTERNAL_WAKEUP
+ static void async_thrdd_event(const struct curl_thrdq *tqueue,
+                               Curl_thrdq_event ev,
+                               void *user_data)
+@@ -416,7 +416,7 @@ static void async_thrdd_event(const struct curl_thrdq *tqueue,
+   (void)tqueue;
+   switch(ev) {
+   case CURL_THRDQ_EV_ITEM_DONE:
+-    (void)curl_multi_wakeup(multi);
++    Curl_multi_wakeup_internal(multi);
+     break;
+   default:
+     break;
+@@ -663,7 +663,7 @@ CURLcode Curl_async_pollset(struct Curl_easy *data,
+ #endif
+ 
+   if(!async->done) {
+-#ifndef ENABLE_WAKEUP
++#ifndef ENABLE_INTERNAL_WAKEUP
+     timediff_t stutter_ms, elapsed_ms;
+     elapsed_ms = curlx_ptimediff_ms(Curl_pgrs_now(data), &async->start);
+     if(elapsed_ms < 3)
+@@ -706,7 +706,7 @@ CURLcode Curl_async_take_result(struct Curl_easy *data,
+   if(thrdd->rr.channel)
+     (void)Curl_ares_perform(thrdd->rr.channel, 0);
+ #endif
+-#ifndef ENABLE_WAKEUP
++#ifndef ENABLE_INTERNAL_WAKEUP
+   Curl_async_thrdd_multi_process(data->multi);
+ #endif
+ 
+diff --git a/lib/multi.c b/lib/multi.c
+index d6ae111d8e..1ae679565e 100644
+--- a/lib/multi.c
++++ b/lib/multi.c
+@@ -268,6 +268,10 @@ struct Curl_multi *Curl_multi_handle(uint32_t xfer_table_size,
+   multi->wakeup_pair[0] = CURL_SOCKET_BAD;
+   multi->wakeup_pair[1] = CURL_SOCKET_BAD;
+ #endif
++#ifdef ENABLE_INTERNAL_WAKEUP
++  multi->wakeup_internal[0] = CURL_SOCKET_BAD;
++  multi->wakeup_internal[1] = CURL_SOCKET_BAD;
++#endif
+ 
+   if(Curl_mntfy_resize(multi) ||
+      Curl_uint32_bset_resize(&multi->process, xfer_table_size) ||
+@@ -315,6 +319,10 @@ struct Curl_multi *Curl_multi_handle(uint32_t xfer_table_size,
+   if(Curl_wakeup_init(multi->wakeup_pair, TRUE) < 0)
+     goto error;
+ #endif
++#ifdef ENABLE_INTERNAL_WAKEUP
++  if(Curl_wakeup_init(multi->wakeup_internal, TRUE) < 0)
++    goto error;
++#endif
+ 
+   if(Curl_probeipv6(multi))
+     goto error;
+@@ -360,6 +368,9 @@ error:
+ #ifdef ENABLE_WAKEUP
+   Curl_wakeup_destroy(multi->wakeup_pair);
+ #endif
++#ifdef ENABLE_INTERNAL_WAKEUP
++  Curl_wakeup_destroy(multi->wakeup_internal);
++#endif
+ 
+   curlx_free(multi);
+   return NULL;
+@@ -395,7 +406,7 @@ bool Curl_is_connecting(struct Curl_easy *data)
+ 
+ static CURLMcode multi_assess_wakeup(struct Curl_multi *multi)
+ {
+-#ifdef ENABLE_WAKEUP
++#ifdef ENABLE_INTERNAL_WAKEUP
+   if(multi->socket_cb)
+     return Curl_multi_ev_assess_xfer(multi, multi->admin);
+ #else
+@@ -1149,14 +1160,14 @@ CURLMcode Curl_multi_pollset(struct Curl_easy *data,
+   CURLcode result = CURLE_OK;
+ 
+   Curl_pollset_reset(ps);
+-#ifdef ENABLE_WAKEUP
++#ifdef ENABLE_INTERNAL_WAKEUP
+   /* The admin handle always listens on the wakeup socket when there
+    * are transfers alive. */
+   if(data->multi && (data == data->multi->admin) &&
+      data->multi->xfers_really_alive) {
+     CURL_TRC_M(data, "adding wakeup, %u xfers really alive",
+                data->multi->xfers_really_alive);
+-    result = Curl_pollset_add_in(data, ps, data->multi->wakeup_pair[0]);
++    result = Curl_pollset_add_in(data, ps, data->multi->wakeup_internal[0]);
+   }
+ #endif
+   /* If the transfer has no connection, this is fine. Happens when
+@@ -1714,6 +1725,18 @@ CURLMcode curl_multi_wakeup(CURLM *m)
+   return mresult;
+ }
+ 
++#ifdef ENABLE_INTERNAL_WAKEUP
++void Curl_multi_wakeup_internal(struct Curl_multi *multi)
++{
++  /* This is expected to be invocable from another thread which
++   * does NOT outlive the multi handle. Check for sanity. */
++  if(GOOD_MULTI_HANDLE(multi))
++    Curl_wakeup_signal(multi->wakeup_internal);
++  else
++    DEBUGASSERT(0);
++}
++#endif
++
+ /*
+  * multi_ischanged() is called
+  *
+@@ -2740,10 +2763,10 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
+   Curl_uint32_bset_remove(&multi->dirty, data->mid);
+ 
+   if(data == multi->admin) {
+-#ifdef ENABLE_WAKEUP
++#ifdef ENABLE_INTERNAL_WAKEUP
+     /* Consume any pending wakeup signals before processing.
+      * This is necessary for event based processing. See #21547 */
+-    (void)Curl_wakeup_consume(multi->wakeup_pair, TRUE);
++    (void)Curl_wakeup_consume(multi->wakeup_internal, TRUE);
+ #endif
+ #ifdef USE_RESOLV_THREADED
+     Curl_async_thrdd_multi_process(multi);
+@@ -3051,6 +3074,9 @@ CURLMcode curl_multi_cleanup(CURLM *m)
+ #ifdef ENABLE_WAKEUP
+   Curl_wakeup_destroy(multi->wakeup_pair);
+ #endif
++#ifdef ENABLE_INTERNAL_WAKEUP
++  Curl_wakeup_destroy(multi->wakeup_internal);
++#endif
+ 
+     multi_xfer_bufs_free(multi);
+     Curl_mntfy_cleanup(multi);
+diff --git a/lib/multihandle.h b/lib/multihandle.h
+index 19dd2ffcdf..e9bbfaea90 100644
+--- a/lib/multihandle.h
++++ b/lib/multihandle.h
+@@ -73,6 +73,11 @@ typedef enum {
+ #if !defined(CURL_DISABLE_SOCKETPAIR) && !defined(USE_WINSOCK)
+ #define ENABLE_WAKEUP
+ #endif
++#if !defined(CURL_DISABLE_SOCKETPAIR) && \
++    defined(USE_RESOLV_THREADED) && \
++    !defined(USE_WINSOCK)
++#define ENABLE_INTERNAL_WAKEUP
++#endif
+ 
+ /* value for MAXIMUM CONCURRENT STREAMS upper limit */
+ #define INITIAL_MAX_CONCURRENT_STREAMS ((1U << 31) - 1)
+@@ -168,7 +173,13 @@ struct Curl_multi {
+ #ifdef ENABLE_WAKEUP
+   curl_socket_t wakeup_pair[2]; /* eventfd()/pipe()/socketpair() used for
+                                    wakeup 0 is used for read, 1 is used
+-                                   for write */
++                                   for write. Used by curl_multi_wakeup() */
++#endif
++#ifdef ENABLE_INTERNAL_WAKEUP
++  curl_socket_t wakeup_internal[2]; /* eventfd()/pipe()/socketpair() used for
++                                   wakeup 0 is used for read, 1 is used
++                                   for write. Used for internal wakeups,
++                                   e.g. threaded resolver. */
+ #endif
+   unsigned int max_concurrent_streams;
+   unsigned int maxconnects; /* if >0, a fixed limit of the maximum number of
+diff --git a/lib/multiif.h b/lib/multiif.h
+index 039db269e0..920bf0e917 100644
+--- a/lib/multiif.h
++++ b/lib/multiif.h
+@@ -164,4 +164,8 @@ void Curl_multi_clear_dirty(struct Curl_easy *data);
+ 
+ void Curl_multi_set_now(struct Curl_multi *multi);
+ 
++#ifdef ENABLE_INTERNAL_WAKEUP
++void Curl_multi_wakeup_internal(struct Curl_multi *multi);
++#endif
++
+ #endif /* HEADER_CURL_MULTIIF_H */
+diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
+index 9fb1720f7c..69bfdc9134 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -263,7 +263,7 @@ test2300 test2301 test2302 test2303 test2304 test2306 test2307 test2308 \
+ test2309 test2310 test2311 \
+ \
+ test2400 test2401 test2402 test2403 test2404 test2405 test2406 test2407 \
+-test2408 test2409 test2410 test2411 test2412 test2413 \
++test2408 test2409 test2410 test2411 test2412 test2413 test2414 \
+ \
+ test2500 test2501 test2502 test2503 test2504 test2505 test2506 \
+ \
+diff --git a/tests/data/test2414 b/tests/data/test2414
+new file mode 100644
+index 0000000000..197beffe8f
+--- /dev/null
++++ b/tests/data/test2414
+@@ -0,0 +1,30 @@
++<?xml version="1.0" encoding="US-ASCII"?>
++<testcase>
++<info>
++<keywords>
++multi
++wakeup
++</keywords>
++</info>
++
++# Client-side
++<client>
++<features>
++wakeup
++</features>
++<server>
++</server>
++<tool>
++lib%TESTNUMBER
++</tool>
++<name>
++wakeup, perform and poll needs to exit
++</name>
++<command>
++</command>
++</client>
++
++# Verify data after the test has been "shot"
++<verify>
++</verify>
++</testcase>
+diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
+index bec648542b..8d97421f4e 100644
+--- a/tests/libtest/Makefile.inc
++++ b/tests/libtest/Makefile.inc
+@@ -115,7 +115,7 @@ TESTS_C = \
+   lib2023.c lib2032.c lib2082.c \
+   lib2301.c lib2302.c lib2304.c           lib2306.c lib2308.c lib2309.c \
+   lib2402.c           lib2404.c lib2405.c \
+-  lib2412.c \
++  lib2412.c           lib2414.c \
+   lib2502.c lib2504.c lib2505.c lib2506.c \
+   lib2700.c \
+   lib3010.c lib3025.c lib3026.c lib3027.c lib3033.c lib3034.c \
+diff --git a/tests/libtest/lib2414.c b/tests/libtest/lib2414.c
+new file mode 100644
+index 0000000000..e04dff3de7
+--- /dev/null
++++ b/tests/libtest/lib2414.c
+@@ -0,0 +1,53 @@
++/***************************************************************************
++ *                                  _   _ ____  _
++ *  Project                     ___| | | |  _ \| |
++ *                             / __| | | | |_) | |
++ *                            | (__| |_| |  _ <| |___
++ *                             \___|\___/|_| \_\_____|
++ *
++ * Copyright (C) Dmitry Karpov <dkarpov1970@gmail.com>
++ *
++ * This software is licensed as described in the file COPYING, which
++ * you should have received as part of this distribution. The terms
++ * are also available at https://curl.se/docs/copyright.html.
++ *
++ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
++ * copies of the Software, and permit persons to whom the Software is
++ * furnished to do so, under the terms of the COPYING file.
++ *
++ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
++ * KIND, either express or implied.
++ *
++ * SPDX-License-Identifier: curl
++ *
++ ***************************************************************************/
++
++#include "first.h"
++#include "testtrace.h"
++
++static CURLcode test_lib2414(const char *URL)
++{
++  CURLM *multi = NULL;
++  CURLcode result = CURLE_OK;
++  int running;
++
++  (void)URL;
++  global_init(CURL_GLOBAL_ALL);
++
++  multi = curl_multi_init();
++  if(!multi) {
++    curl_mfprintf(stderr, "curl_multi_init() failed\n");
++    result = TEST_ERR_MAJOR_BAD;
++    goto test_cleanup;
++  }
++
++  curl_multi_wakeup(multi);
++  curl_multi_perform(multi, &running);
++  curl_multi_poll(multi, NULL, 0, INT_MAX, NULL);
++
++test_cleanup:
++  if(multi)
++    curl_multi_cleanup(multi);
++  curl_global_cleanup();
++  return result;
++}

diff --git a/0003-curl-8.21.0-CVE-2026-19931.patch b/0003-curl-8.21.0-CVE-2026-19931.patch
deleted file mode 100644
index 30c46d8..0000000
--- a/0003-curl-8.21.0-CVE-2026-19931.patch
+++ /dev/null
@@ -1,2159 +0,0 @@
-From 02b0a2f84f35abf458b6ed3e81d2abbc41eb2c8d Mon Sep 17 00:00:00 2001
-From: Stefan Eissing <stefan@eissing.org>
-Date: Thu, 13 Aug 2026 13:23:53 +0200
-Subject: [PATCH 2/2] connections: use admin handles only for maintenance
-
-Maintenance tasks like connection upkeep, liveliness checks and cache
-eviction must only run on an admin handle, not the application transfer
-from the calling context.
-
-Then application transfers will get only attached to the connections
-they actually work on. This makes `data->state.recent_conn_id`
-meaningful for checks if a subsequent address is finding the previous
-connection again.
-
-One thing led to another:
-- add Curl_get_admin(data), to obtain an admin handle for
-  an application handle, inheriting some properties for
-  connection operation.
-- rename `Curl_easy *data` parameter to `Curl_easy *admin`
-  where only admin handles should be passed. Add DEBUGASSERTs
-  in the called function.
-- rename `Curl_conn_terminate()` to `Curl_conn_close()`
-  because this makes connections enter the shutdown close
-  where possible.
-- rename `Curl_cshutdn_terminate()` to `Curl_conn_terminate()`
-  since this definitely kills the connection and does not
-  involve a `cshutdn` instance.
-- add Curl_share_lock_share(), Curl_share_unlock_share()
-  so it possible to operate on a share without the passed
-  easy handle having the share set.
-  This catches a case where a shared needed to be locked
-  but was not before. Adjust test1554 results.
-
-Fixes #22567
-Reported-by: cybertron10 on github
-Closes #22572
-
-(cherry picked from commit 7103a93b05bc69ea98ed9d05d02fa9eeba533f2f)
----
- lib/conncache.c     | 411 +++++++++++++++++++++++++++++---------------
- lib/conncache.h     |  31 ++--
- lib/cshutdn.c       | 176 +++++++++----------
- lib/cshutdn.h       |  29 ++--
- lib/curl_share.c    |  27 ++-
- lib/curl_share.h    |   8 +
- lib/curl_trc.c      |   3 +-
- lib/easy.c          |  11 +-
- lib/getinfo.c       |   3 +-
- lib/multi.c         |  59 ++++---
- lib/multiif.h       |   3 +-
- lib/url.c           | 157 ++++++++++++-----
- lib/url.h           |   6 +
- lib/urldata.h       |   5 +-
- tests/data/test1554 |   8 +
- 15 files changed, 591 insertions(+), 346 deletions(-)
-
-diff --git a/lib/conncache.c b/lib/conncache.c
-index 5ba2368622..82bea4db45 100644
---- a/lib/conncache.c
-+++ b/lib/conncache.c
-@@ -42,7 +42,7 @@
-   do {                                                                  \
-     if(c) {                                                             \
-       if(CURL_SHARE_KEEP_CONNECT((c)->share))                           \
--        Curl_share_lock((d), CURL_LOCK_DATA_CONNECT,                    \
-+        Curl_share_lock_share((c)->share, (d), CURL_LOCK_DATA_CONNECT,  \
-                         CURL_LOCK_ACCESS_SINGLE);                       \
-       DEBUGASSERT(!(c)->locked);                                        \
-       (c)->locked = TRUE;                                               \
-@@ -55,7 +55,7 @@
-       DEBUGASSERT((c)->locked);                                         \
-       (c)->locked = FALSE;                                              \
-       if(CURL_SHARE_KEEP_CONNECT((c)->share))                           \
--        Curl_share_unlock((d), CURL_LOCK_DATA_CONNECT);                 \
-+        Curl_share_unlock_share((c)->share, (d), CURL_LOCK_DATA_CONNECT); \
-     }                                                                   \
-   } while(0)
- 
-@@ -111,16 +111,12 @@ static void cpool_bundle_free_entry(void *freethis)
- }
- 
- void Curl_cpool_init(struct cpool *cpool,
--                     struct Curl_easy *idata,
-                      struct Curl_share *share,
-                      size_t size)
- {
-   Curl_hash_init(&cpool->dest2bundle, size, Curl_hash_str,
-                  curlx_str_key_compare, cpool_bundle_free_entry);
- 
--  DEBUGASSERT(idata);
--
--  cpool->idata = idata;
-   cpool->share = share;
-   cpool->initialized = TRUE;
- }
-@@ -186,6 +182,8 @@ static void cpool_discard_conn(struct cpool *cpool,
-                                struct connectdata *conn,
-                                bool aborted)
- {
-+  struct cshutdn *cshutdn;
-+  struct Curl_easy *admin;
-   bool done = FALSE;
- 
-   DEBUGASSERT(data);
-@@ -193,12 +191,13 @@ static void cpool_discard_conn(struct cpool *cpool,
-   DEBUGASSERT(cpool);
-   DEBUGASSERT(!conn->bits.in_cpool);
- 
-+  admin = Curl_get_admin(data);
-   /*
-    * If this connection is not marked to force-close, leave it open if there
-    * are other users of it
-    */
-   if(CONN_INUSE(conn) && !aborted) {
--    CURL_TRC_M(data, "[CPOOL] not discarding #%" FMT_OFF_T
-+    CURL_TRC_M(admin, "[CPOOL] not discarding #%" FMT_OFF_T
-                " still in use by %u transfers", conn->connection_id,
-                conn->attached_xfers);
-     return;
-@@ -219,35 +218,36 @@ static void cpool_discard_conn(struct cpool *cpool,
-     done = TRUE;
-   if(!done) {
-     /* Attempt to shutdown the connection right away. */
--    Curl_cshutdn_run_once(cpool->idata, conn, &done);
-+    Curl_conn_shutdown_once(admin, conn, &done);
-   }
- 
--  if(done || !data->multi)
--    Curl_cshutdn_terminate(cpool->idata, conn, FALSE);
-+  cshutdn = Curl_cshutdn_get(data);
-+  if(done || !cshutdn)
-+    Curl_conn_terminate(admin, conn, FALSE);
-   else
--    Curl_cshutdn_add(&data->multi->cshutdn, conn, cpool->num_conn);
-+    Curl_cshutdn_add(cshutdn, conn, cpool->num_conn);
- }
- 
--void Curl_cpool_destroy(struct cpool *cpool)
-+void Curl_cpool_destroy(struct cpool *cpool, struct Curl_easy *admin)
- {
--  if(cpool && cpool->initialized && cpool->idata) {
-+  if(cpool && cpool->initialized && admin) {
-     struct connectdata *conn;
-     struct Curl_sigpipe_ctx pipe_ctx;
- 
--    CURL_TRC_M(cpool->idata, "%s[CPOOL] destroy, %zu connections",
-+    CURL_TRC_M(admin, "%s[CPOOL] destroy, %zu connections",
-                cpool->share ? "[SHARE] " : "", cpool->num_conn);
-     /* Move all connections to the shutdown list */
-     sigpipe_init(&pipe_ctx);
--    CPOOL_LOCK(cpool, cpool->idata);
-+    CPOOL_LOCK(cpool, admin);
-     conn = cpool_get_first(cpool);
-     if(conn)
--      sigpipe_apply(cpool->idata, &pipe_ctx);
-+      sigpipe_apply(admin, &pipe_ctx);
-     while(conn) {
-       cpool_remove_conn(cpool, conn);
--      cpool_discard_conn(cpool, cpool->idata, conn, FALSE);
-+      cpool_discard_conn(cpool, admin, conn, FALSE);
-       conn = cpool_get_first(cpool);
-     }
--    CPOOL_UNLOCK(cpool, cpool->idata);
-+    CPOOL_UNLOCK(cpool, admin);
-     sigpipe_restore(&pipe_ctx);
-     Curl_hash_destroy(&cpool->dest2bundle);
-   }
-@@ -255,17 +255,22 @@ void Curl_cpool_destroy(struct cpool *cpool)
- 
- static struct cpool *cpool_get_instance(struct Curl_easy *data)
- {
--  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;
--  }
-+  /* admin handles do not necessarily find the correct pool */
-+  DEBUGASSERT(data->mid);
-+  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;
-   return NULL;
- }
- 
-+struct cpool *Curl_cpool_get_instance(struct Curl_easy *data)
-+{
-+  return cpool_get_instance(data);
-+}
-+
- void Curl_cpool_xfer_init(struct Curl_easy *data)
- {
-   struct cpool *cpool = cpool_get_instance(data);
-@@ -367,10 +372,89 @@ static struct connectdata *cpool_get_oldest_idle(struct cpool *cpool,
-   return oldest_idle;
- }
- 
-+static void cpool_conn_close(struct cpool *cpool,
-+                             struct Curl_easy *data,
-+                             struct connectdata *conn,
-+                             bool aborted)
-+{
-+  struct Curl_easy *admin;
-+  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, "conn terminate when inuse: %u", conn->attached_xfers));
-+    return;
-+  }
-+
-+  /* This method may be called while we are under lock, e.g. from a
-+   * user callback in find. */
-+  admin = Curl_get_admin(data);
-+  do_lock = !CPOOL_IS_LOCKED(cpool);
-+  if(do_lock)
-+    CPOOL_LOCK(cpool, admin);
-+
-+  if(conn->bits.in_cpool) {
-+    cpool_remove_conn(cpool, conn);
-+    DEBUGASSERT(!conn->bits.in_cpool);
-+  }
-+
-+  /* treat the connection as aborted in CONNECT_ONLY situations,
-+   * so no graceful shutdown is attempted. */
-+  if(conn->bits.connect_only)
-+    aborted = TRUE;
-+
-+  if(data->multi) {
-+    /* Add it to the multi's cpool for shutdown handling */
-+    infof(data, "%s connection #%" FMT_OFF_T,
-+          aborted ? "closing" : "shutting down", conn->connection_id);
-+    cpool_discard_conn(&data->multi->cpool, data, conn, aborted);
-+  }
-+  else {
-+    /* No multi available, terminate */
-+    infof(data, "closing connection #%" FMT_OFF_T, conn->connection_id);
-+    Curl_conn_terminate(admin, conn, !aborted);
-+  }
-+
-+  if(do_lock)
-+    CPOOL_UNLOCK(cpool, admin);
-+}
-+
-+void Curl_conn_close(struct Curl_easy *data,
-+                     struct connectdata *conn,
-+                     bool aborted)
-+{
-+  struct cpool *cpool = cpool_get_instance(data);
-+  cpool_conn_close(cpool, data, conn, aborted);
-+}
-+
-+/* Evict an idle connection to make room in the pool. A pool owned by
-+ * a share has no multi that could perform a controlled shutdown of the
-+ * connection; terminate it right away. Otherwise, hand it to the
-+ * transfer's multi for shutdown. Expects the pool to be locked. */
-+static void cpool_evict_conn(struct cpool *cpool,
-+                             struct Curl_easy *admin,
-+                             struct connectdata *conn)
-+{
-+  if(cpool->share) {
-+    cpool_remove_conn(cpool, conn);
-+    Curl_conn_terminate(admin, conn, TRUE);
-+  }
-+  else
-+    cpool_conn_close(cpool, admin, conn, FALSE);
-+}
- int Curl_cpool_check_limits(struct Curl_easy *data,
-                             struct connectdata *conn)
- {
-   struct cpool *cpool = cpool_get_instance(data);
-+  struct cshutdn *cshutdn = Curl_cshutdn_get(data);
-+  struct Curl_easy *admin;
-   struct cpool_bundle *bundle;
-   size_t dest_limit = 0;
-   size_t total_limit = 0;
-@@ -380,25 +464,26 @@ int Curl_cpool_check_limits(struct Curl_easy *data,
-   if(!cpool)
-     return CPOOL_LIMIT_OK;
- 
--  if(cpool->idata->multi) {
--    dest_limit = cpool->idata->multi->max_host_connections;
--    total_limit = cpool->idata->multi->max_total_connections;
-+  if(data->multi) {
-+    dest_limit = data->multi->max_host_connections;
-+    total_limit = data->multi->max_total_connections;
-   }
- 
-   if(!dest_limit && !total_limit)
-     return CPOOL_LIMIT_OK;
- 
--  CPOOL_LOCK(cpool, cpool->idata);
-+  admin = Curl_get_admin(data);
-+  CPOOL_LOCK(cpool, admin);
-   if(dest_limit) {
-     size_t live;
- 
-     bundle = cpool_find_bundle(cpool, conn);
-     live = bundle ? Curl_llist_count(&bundle->conns) : 0;
--    shutdowns = Curl_cshutdn_dest_count(data, conn->destination);
-+    shutdowns = Curl_cshutdn_dest_count(cshutdn, conn->destination);
-     while((live + shutdowns) >= dest_limit) {
-       if(shutdowns) {
-         /* close one connection in shutdown right away, if we can */
--        if(!Curl_cshutdn_close_oldest(data, conn->destination))
-+        if(!Curl_cshutdn_close_oldest(cshutdn, conn->destination))
-           break;
-       }
-       else if(!bundle)
-@@ -412,17 +497,17 @@ int Curl_cpool_check_limits(struct Curl_easy *data,
-         if(!oldest_idle)
-           break;
-         /* disconnect the old conn and continue */
--        CURL_TRC_M(data, "Discarding connection #%" FMT_OFF_T
-+        CURL_TRC_M(admin, "Discarding connection #%" FMT_OFF_T
-                    " from %zu to reach destination limit of %zu",
-                    oldest_idle->connection_id,
-                    Curl_llist_count(&bundle->conns), dest_limit);
--        Curl_conn_terminate(cpool->idata, oldest_idle, FALSE);
-+        cpool_evict_conn(cpool, admin, oldest_idle);
- 
-         /* in case the bundle was destroyed in disconnect, look it up again */
-         bundle = cpool_find_bundle(cpool, conn);
-         live = bundle ? Curl_llist_count(&bundle->conns) : 0;
-       }
--      shutdowns = Curl_cshutdn_dest_count(cpool->idata, conn->destination);
-+      shutdowns = Curl_cshutdn_dest_count(cshutdn, conn->destination);
-     }
-     if((live + shutdowns) >= dest_limit) {
-       res = CPOOL_LIMIT_DEST;
-@@ -431,11 +516,11 @@ int Curl_cpool_check_limits(struct Curl_easy *data,
-   }
- 
-   if(total_limit) {
--    shutdowns = Curl_cshutdn_count(cpool->idata);
-+    shutdowns = Curl_cshutdn_count(cshutdn);
-     while((cpool->num_conn + shutdowns) >= total_limit) {
-       if(shutdowns) {
-         /* close one connection in shutdown right away, if we can */
--        if(!Curl_cshutdn_close_oldest(data, NULL))
-+        if(!Curl_cshutdn_close_oldest(cshutdn, NULL))
-           break;
-       }
-       else {
-@@ -444,13 +529,13 @@ int Curl_cpool_check_limits(struct Curl_easy *data,
-         if(!oldest_idle)
-           break;
-         /* disconnect the old conn and continue */
--        CURL_TRC_M(data, "Discarding connection #%"
-+        CURL_TRC_M(admin, "Discarding connection #%"
-                    FMT_OFF_T " from %zu to reach total "
-                    "limit of %zu",
-                    oldest_idle->connection_id, cpool->num_conn, total_limit);
--        Curl_conn_terminate(cpool->idata, oldest_idle, FALSE);
-+        cpool_evict_conn(cpool, admin, oldest_idle);
-       }
--      shutdowns = Curl_cshutdn_count(cpool->idata);
-+      shutdowns = Curl_cshutdn_count(cshutdn);
-     }
-     if((cpool->num_conn + shutdowns) >= total_limit) {
-       res = CPOOL_LIMIT_TOTAL;
-@@ -459,7 +544,7 @@ int Curl_cpool_check_limits(struct Curl_easy *data,
-   }
- 
- out:
--  CPOOL_UNLOCK(cpool, cpool->idata);
-+  CPOOL_UNLOCK(cpool, admin);
-   return res;
- }
- 
-@@ -512,7 +597,8 @@ out:
- static bool cpool_foreach(struct Curl_easy *data,
-                           struct cpool *cpool,
-                           void *param,
--                          int (*func)(struct Curl_easy *data,
-+                          int (*func)(struct cpool *cpool,
-+                                      struct Curl_easy *data,
-                                       struct connectdata *conn, void *param))
- {
-   struct Curl_hash_iterator iter;
-@@ -536,7 +622,7 @@ static bool cpool_foreach(struct Curl_easy *data,
-       struct connectdata *conn = Curl_node_elem(curr);
-       curr = Curl_node_next(curr);
- 
--      if(func(data, conn, param) == 1) {
-+      if(func(cpool, data, conn, param) == 1) {
-         return TRUE;
-       }
-     }
-@@ -556,6 +642,7 @@ bool Curl_cpool_conn_now_idle(struct Curl_easy *data,
-   unsigned int maxconnects;
-   struct connectdata *oldest_idle = NULL;
-   struct cpool *cpool = cpool_get_instance(data);
-+  struct Curl_easy *admin;
-   bool kept = TRUE;
- 
-   if(!data || !data->multi)
-@@ -573,8 +660,10 @@ bool Curl_cpool_conn_now_idle(struct Curl_easy *data,
-   if(cpool && maxconnects) {
-     /* may be called form a callback already under lock */
-     bool do_lock = !CPOOL_IS_LOCKED(cpool);
-+
-+    admin = Curl_get_admin(data);
-     if(do_lock)
--      CPOOL_LOCK(cpool, data);
-+      CPOOL_LOCK(cpool, admin);
-     if(cpool->num_conn > maxconnects) {
-       infof(data, "Connection pool is full, closing the oldest of %zu/%u",
-             cpool->num_conn, maxconnects);
-@@ -582,11 +671,11 @@ bool Curl_cpool_conn_now_idle(struct Curl_easy *data,
-       oldest_idle = cpool_get_oldest_idle(cpool, Curl_pgrs_now(data));
-       kept = (oldest_idle != conn);
-       if(oldest_idle) {
--        Curl_conn_terminate(data, oldest_idle, FALSE);
-+        cpool_evict_conn(cpool, admin, oldest_idle);
-       }
-     }
-     if(do_lock)
--      CPOOL_UNLOCK(cpool, data);
-+      CPOOL_UNLOCK(cpool, admin);
-   }
- 
-   return kept;
-@@ -632,78 +721,25 @@ bool Curl_cpool_find(struct Curl_easy *data,
-   return found;
- }
- 
--void Curl_conn_terminate(struct Curl_easy *data,
--                         struct connectdata *conn,
--                         bool aborted)
--{
--  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, "conn terminate when inuse: %u", conn->attached_xfers));
--    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, data);
--
--  if(conn->bits.in_cpool) {
--    cpool_remove_conn(cpool, conn);
--    DEBUGASSERT(!conn->bits.in_cpool);
--  }
--
--  /* treat the connection as aborted in CONNECT_ONLY situations,
--   * so no graceful shutdown is attempted. */
--  if(conn->bits.connect_only)
--    aborted = TRUE;
--
--  if(data->multi) {
--    /* Add it to the multi's cpool for shutdown handling */
--    infof(data, "%s connection #%" FMT_OFF_T,
--          aborted ? "closing" : "shutting down", conn->connection_id);
--    cpool_discard_conn(&data->multi->cpool, data, conn, aborted);
--  }
--  else {
--    /* No multi available, terminate */
--    infof(data, "closing connection #%" FMT_OFF_T, conn->connection_id);
--    Curl_cshutdn_terminate(cpool->idata, conn, !aborted);
--  }
--
--  if(do_lock)
--    CPOOL_UNLOCK(cpool, data);
--}
--
- struct cpool_reaper_ctx {
--  size_t checked;
-   size_t reaped;
-+  struct curltime now;
- };
- 
--static int cpool_reap_dead_cb(struct Curl_easy *data,
-+static int cpool_reap_dead_cb(struct cpool *cpool,
-+                              struct Curl_easy *admin,
-                               struct connectdata *conn, void *param)
- {
-   struct cpool_reaper_ctx *reaper = param;
--  bool terminate = !CONN_INUSE(conn) && conn->bits.no_reuse;
- 
--  if(!terminate) {
--    reaper->checked++;
--    terminate = Curl_conn_seems_dead(conn, data);
--  }
--  if(terminate) {
--    /* stop the iteration here, pass back the connection that was pruned */
--    reaper->reaped++;
--    Curl_conn_terminate(data, conn, FALSE);
--    return 1;
-+  if(!CONN_INUSE(conn)) {
-+    if(conn->bits.no_reuse || conn->bits.close ||
-+       !Curl_cpool_conn_seems_healthy(conn, admin, &reaper->now)) {
-+      /* terminate conn and stop the iteration */
-+      reaper->reaped++;
-+      cpool_conn_close(cpool, admin, conn, FALSE);
-+      return 1;
-+    }
-   }
-   return 0; /* continue iteration */
- }
-@@ -715,46 +751,67 @@ static int cpool_reap_dead_cb(struct Curl_easy *data,
-  *
-  * When called, this transfer has no connection attached.
-  */
--void Curl_cpool_prune_dead(struct Curl_easy *data)
-+void Curl_cpool_prune_dead(struct cpool *cpool,
-+                           struct Curl_easy *data)
- {
--  struct cpool *cpool = cpool_get_instance(data);
--  struct cpool_reaper_ctx reaper;
-+  struct Curl_easy *admin;
-   timediff_t elapsed;
- 
-   if(!cpool)
-     return;
- 
--  memset(&reaper, 0, sizeof(reaper));
--  CPOOL_LOCK(cpool, data);
--  elapsed = curlx_ptimediff_ms(Curl_pgrs_now(data), &cpool->last_cleanup);
-+  admin = Curl_get_admin(data);
-+  CPOOL_LOCK(cpool, admin);
-+  elapsed = curlx_ptimediff_ms(Curl_pgrs_now(admin), &cpool->last_cleanup);
- 
-   if(elapsed >= 1000L) {
--    while(cpool_foreach(data, cpool, &reaper, cpool_reap_dead_cb))
-+    struct cpool_reaper_ctx reaper;
-+
-+    memset(&reaper, 0, sizeof(reaper));
-+    reaper.now = *Curl_pgrs_now(admin);
-+    while(cpool_foreach(admin, cpool, &reaper, cpool_reap_dead_cb))
-       ;
--    cpool->last_cleanup = *Curl_pgrs_now(data);
-+    cpool->last_cleanup = *Curl_pgrs_now(admin);
-   }
--  CPOOL_UNLOCK(cpool, data);
-+  CPOOL_UNLOCK(cpool, admin);
- }
- 
--static int conn_upkeep(struct Curl_easy *data,
-+static int conn_upkeep(struct cpool *cpool,
-+                       struct Curl_easy *admin,
-                        struct connectdata *conn,
-                        void *param)
- {
-   (void)param;
--  Curl_conn_upkeep(data, conn);
-+  if(curlx_ptimediff_ms(Curl_pgrs_now(admin), &conn->keepalive) >=
-+     admin->set.upkeep_interval_ms) {
-+    CURLcode result;
-+
-+    /* briefly attach for action */
-+    Curl_attach_connection(admin, conn, FALSE);
-+    result = Curl_conn_keep_alive(admin, conn, FIRSTSOCKET);
-+    conn->keepalive = *Curl_pgrs_now(admin);
-+    Curl_detach_connection(admin);
-+
-+    if(result && !CONN_INUSE(conn)) {
-+      cpool_conn_close(cpool, admin, conn, FALSE);
-+      return 1;
-+    }
-+  }
-   return 0; /* continue iteration */
- }
- 
- CURLcode Curl_cpool_upkeep(struct Curl_easy *data)
- {
-   struct cpool *cpool = cpool_get_instance(data);
-+  struct Curl_easy *admin = Curl_get_admin(data);
- 
-   if(!cpool)
-     return CURLE_OK;
- 
--  CPOOL_LOCK(cpool, data);
--  cpool_foreach(data, cpool, NULL, conn_upkeep);
--  CPOOL_UNLOCK(cpool, data);
-+  CPOOL_LOCK(cpool, admin);
-+  while(cpool_foreach(admin, cpool, NULL, conn_upkeep))
-+    ;
-+  CPOOL_UNLOCK(cpool, admin);
-   return CURLE_OK;
- }
- 
-@@ -763,10 +820,12 @@ struct cpool_find_ctx {
-   struct connectdata *conn;
- };
- 
--static int cpool_find_conn(struct Curl_easy *data,
-+static int cpool_find_conn(struct cpool *cpool,
-+                           struct Curl_easy *data,
-                            struct connectdata *conn, void *param)
- {
-   struct cpool_find_ctx *fctx = param;
-+  (void)cpool;
-   (void)data;
-   if(conn->connection_id == fctx->id) {
-     fctx->conn = conn;
-@@ -797,10 +856,12 @@ struct cpool_do_conn_ctx {
-   void *cbdata;
- };
- 
--static int cpool_do_conn(struct Curl_easy *data,
-+static int cpool_do_conn(struct cpool *cpool,
-+                         struct Curl_easy *data,
-                          struct connectdata *conn, void *param)
- {
-   struct cpool_do_conn_ctx *dctx = param;
-+  (void)cpool;
- 
-   if(conn->connection_id == dctx->id) {
-     dctx->cb(conn, data, dctx->cbdata);
-@@ -839,39 +900,113 @@ void Curl_cpool_do_locked(struct Curl_easy *data,
-     cb(conn, data, cbdata);
- }
- 
--static int cpool_mark_stale(struct Curl_easy *data,
-+static int cpool_mark_stale(struct cpool *cpool,
-+                            struct Curl_easy *admin,
-                             struct connectdata *conn, void *param)
- {
--  (void)data;
-+  (void)cpool;
-+  (void)admin;
-   (void)param;
-   conn->bits.no_reuse = TRUE;
-   return 0;
- }
- 
--static int cpool_reap_no_reuse(struct Curl_easy *data,
-+static int cpool_reap_no_reuse(struct cpool *cpool,
-+                               struct Curl_easy *admin,
-                                struct connectdata *conn, void *param)
- {
-   (void)param;
-   if(!CONN_INUSE(conn) && conn->bits.no_reuse) {
--    Curl_conn_terminate(data, conn, FALSE);
-+    cpool_conn_close(cpool, admin, conn, FALSE);
-     return 1;
-   }
-   return 0; /* continue iteration */
- }
- 
--void Curl_cpool_nw_changed(struct Curl_easy *data)
-+void Curl_cpool_nw_changed(struct cpool *cpool, struct Curl_easy *admin)
- {
--  struct cpool *cpool = cpool_get_instance(data);
--
--  if(cpool) {
--    CPOOL_LOCK(cpool, data);
--    cpool_foreach(data, cpool, NULL, cpool_mark_stale);
--    while(cpool_foreach(data, cpool, NULL, cpool_reap_no_reuse))
-+  if(cpool && admin) {
-+    CPOOL_LOCK(cpool, admin);
-+    cpool_foreach(admin, cpool, NULL, cpool_mark_stale);
-+    while(cpool_foreach(admin, cpool, NULL, cpool_reap_no_reuse))
-       ;
--    CPOOL_UNLOCK(cpool, data);
-+    CPOOL_UNLOCK(cpool, admin);
-   }
- }
- 
-+/* A connection has to have been idle for less than 'conn_max_idle_ms'
-+   (the success rate is too low after this), or created less than
-+   'conn_max_age_ms' ago, to be subject for reuse. */
-+static bool cpool_conn_maxage(struct Curl_easy *data,
-+                              struct connectdata *conn,
-+                              const struct curltime *pnow)
-+{
-+  timediff_t age_ms;
-+
-+  if(data->set.conn_max_idle_ms) {
-+    age_ms = curlx_ptimediff_ms(pnow, &conn->lastused);
-+    if(age_ms > data->set.conn_max_idle_ms) {
-+      infof(data, "Too old connection (%" FMT_TIMEDIFF_T
-+            " ms idle, max idle is %" FMT_TIMEDIFF_T " ms), disconnect it",
-+            age_ms, data->set.conn_max_idle_ms);
-+      return TRUE;
-+    }
-+  }
-+
-+  if(data->set.conn_max_age_ms) {
-+    age_ms = curlx_ptimediff_ms(pnow, &conn->created);
-+    if(age_ms > data->set.conn_max_age_ms) {
-+      infof(data,
-+            "Too old connection (created %" FMT_TIMEDIFF_T
-+            " ms ago, max lifetime is %" FMT_TIMEDIFF_T " ms), disconnect it",
-+            age_ms, data->set.conn_max_age_ms);
-+      return TRUE;
-+    }
-+  }
-+
-+  return FALSE;
-+}
-+
-+bool Curl_cpool_conn_seems_healthy(struct connectdata *conn,
-+                                   struct Curl_easy *data,
-+                                   const struct curltime *pnow)
-+{
-+  struct Curl_easy *admin;
-+  bool healthy = TRUE;
-+
-+  DEBUGASSERT(!data->conn);
-+  if(!CONN_INUSE(conn) && cpool_conn_maxage(data, conn, pnow)) /* too old? */
-+    return FALSE;
-+  if(curlx_ptimediff_ms(pnow, &conn->lastchecked) < 1000)
-+    return TRUE;
-+
-+  admin = Curl_get_admin(data);
-+  if(conn->scheme->run->connection_is_dead) {
-+    Curl_attach_connection(admin, conn, FALSE);
-+    healthy = !conn->scheme->run->connection_is_dead(admin, conn);
-+    Curl_detach_connection(admin);
-+  }
-+  else {
-+    bool input_pending = FALSE;
-+
-+    Curl_attach_connection(admin, conn, FALSE);
-+    healthy = Curl_conn_is_alive(admin, conn, &input_pending);
-+    Curl_detach_connection(admin);
-+    if(healthy && input_pending &&
-+       !CONN_INUSE(conn) && !Curl_conn_is_multiplex(conn, FIRSTSOCKET)) {
-+      /* Non-multiplexed connections without attached transfers should
-+       * not have input pending. The input might be a TLS Notify Close,
-+       * for all we know. */
-+      DEBUGF(infof(data, "connection has no transfer but input, not healthy"));
-+      healthy = FALSE;
-+    }
-+  }
-+
-+  if(healthy)
-+    conn->lastchecked = *pnow;
-+  return healthy;
-+}
-+
- #if 0
- /* Useful for debugging the connection pool */
- void Curl_cpool_print(struct cpool *cpool)
-diff --git a/lib/conncache.h b/lib/conncache.h
-index 71940d724c..97832ac250 100644
---- a/lib/conncache.h
-+++ b/lib/conncache.h
-@@ -34,7 +34,7 @@ struct Curl_multi;
- struct Curl_share;
- 
- /**
-- * Terminate the connection, e.g. close and destroy.
-+ * Close and destroy the connection.
-  * If the connection is in a cpool, remove it.
-  * If a `cshutdn` is available (e.g. data has a multi handle),
-  * pass the connection to that for controlled shutdown.
-@@ -42,9 +42,9 @@ struct Curl_share;
-  * Takes ownership of `conn`.
-  * `data` should not be attached to a connection.
-  */
--void Curl_conn_terminate(struct Curl_easy *data,
--                         struct connectdata *conn,
--                         bool aborted);
-+void Curl_conn_close(struct Curl_easy *data,
-+                     struct connectdata *conn,
-+                     bool aborted);
- 
- struct cpool {
-   /* the pooled connections, bundled per destination */
-@@ -53,22 +53,24 @@ struct cpool {
-   curl_off_t next_connection_id;
-   curl_off_t next_easy_id;
-   struct curltime last_cleanup;
--  struct Curl_easy *idata; /* internal handle for maintenance */
-   struct Curl_share *share; /* != NULL if pool belongs to share */
-   BIT(locked);
-   BIT(initialized);
- };
- 
-+/* Get connection pool instance for data or NULL if none exists */
-+struct cpool *Curl_cpool_get_instance(struct Curl_easy *data);
-+
- /* Init the pool, pass multi only if pool is owned by it.
-  * Cannot fail.
-  */
- void Curl_cpool_init(struct cpool *cpool,
--                     struct Curl_easy *idata,
-                      struct Curl_share *share,
-                      size_t size);
- 
- /* Destroy all connections and free all members */
--void Curl_cpool_destroy(struct cpool *cpool);
-+void Curl_cpool_destroy(struct cpool *cpool,
-+                        struct Curl_easy *admin);
- 
- /* Init the transfer to be used within its connection pool.
-  * Assigns `data->id`. */
-@@ -126,13 +128,12 @@ bool Curl_cpool_conn_now_idle(struct Curl_easy *data,
-                               struct connectdata *conn);
- 
- /**
-- * This function scans the data's connection pool for half-open/dead
-+ * Scans the 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);
-+void Curl_cpool_prune_dead(struct cpool *cpool,
-+                           struct Curl_easy *data);
- 
- /**
-  * Perform upkeep actions on connections in the transfer's pool.
-@@ -162,6 +163,12 @@ void Curl_cpool_do_locked(struct Curl_easy *data,
-                           Curl_cpool_conn_do_cb *cb, void *cbdata);
- 
- /* Close all unused connections, prevent reuse of existing ones. */
--void Curl_cpool_nw_changed(struct Curl_easy *data);
-+void Curl_cpool_nw_changed(struct cpool *cpool, struct Curl_easy *admin);
-+
-+/* Return TRUE iff the given connection is considered healthy, e.g.
-+ * usable for more transfers. */
-+bool Curl_cpool_conn_seems_healthy(struct connectdata *conn,
-+                                   struct Curl_easy *data,
-+                                   const struct curltime *pnow);
- 
- #endif /* HEADER_CURL_CONNCACHE_H */
-diff --git a/lib/cshutdn.c b/lib/cshutdn.c
-index cc77e401fd..dfd3c904ce 100644
---- a/lib/cshutdn.c
-+++ b/lib/cshutdn.c
-@@ -38,6 +38,13 @@
- #include "curlx/strparse.h"
- 
- 
-+struct cshutdn *Curl_cshutdn_get(struct Curl_easy *data)
-+{
-+  if(data && data->multi)
-+    return &data->multi->cshutdn;
-+  return NULL;
-+}
-+
- static void cshutdn_run_conn_handler(struct Curl_easy *data,
-                                      struct connectdata *conn)
- {
-@@ -107,22 +114,22 @@ static void cshutdn_run_once(struct Curl_easy *data,
-     conn->bits.shutdown_filters = TRUE;
- }
- 
--void Curl_cshutdn_run_once(struct Curl_easy *data,
-+void Curl_conn_shutdown_once(struct Curl_easy *admin,
-                            struct connectdata *conn,
-                            bool *done)
- {
--  DEBUGASSERT(!data->conn);
--  Curl_attach_connection(data, conn);
--  cshutdn_run_once(data, conn, done);
--  CURL_TRC_M(data, "[SHUTDOWN] shutdown, done=%d", *done);
--  Curl_detach_connection(data);
-+  DEBUGASSERT(!admin->conn);
-+  DEBUGASSERT(!admin->mid);
-+  Curl_attach_connection(admin, conn, FALSE);
-+  cshutdn_run_once(admin, conn, done);
-+  CURL_TRC_M(admin, "[SHUTDOWN] shutdown, done=%d", *done);
-+  Curl_detach_connection(admin);
- }
- 
--void Curl_cshutdn_terminate(struct Curl_easy *data,
--                            struct connectdata *conn,
--                            bool do_shutdown)
-+void Curl_conn_terminate(struct Curl_easy *admin,
-+                         struct connectdata *conn,
-+                         bool do_shutdown)
- {
--  struct Curl_easy *admin = data;
-   bool done;
- 
-   /* there must be a connection to close */
-@@ -130,16 +137,10 @@ void Curl_cshutdn_terminate(struct Curl_easy *data,
-   /* it must be removed from the connection pool */
-   DEBUGASSERT(!conn->bits.in_cpool);
-   /* the transfer must be detached from the connection */
--  DEBUGASSERT(data && !data->conn);
-+  DEBUGASSERT(admin && !admin->conn);
-+  DEBUGASSERT(!admin->mid);
- 
--  /* If we can obtain an internal admin handle, use that to attach
--   * and terminate the connection. Some protocol will try to mess with
--   * `data` during shutdown and we do not want that with a `data` from
--   * the application. */
--  if(data->multi && data->multi->admin)
--    admin = data->multi->admin;
--
--  Curl_attach_connection(admin, conn);
-+  Curl_attach_connection(admin, conn, FALSE);
- 
-   cshutdn_run_conn_handler(admin, conn);
-   if(do_shutdown) {
-@@ -154,18 +155,17 @@ void Curl_cshutdn_terminate(struct Curl_easy *data,
-   Curl_conn_cf_discard_all(admin, conn, FIRSTSOCKET);
-   Curl_detach_connection(admin);
- 
--  if(data->multi)
--    Curl_multi_ev_conn_done(data->multi, data, conn);
-+  if(admin->multi)
-+    Curl_multi_ev_conn_done(admin->multi, admin, conn);
-   Curl_conn_free(admin, conn);
- 
--  if(data->multi) {
--    CURL_TRC_M(data, "[SHUTDOWN] trigger multi connchanged");
--    Curl_multi_connchanged(data->multi);
-+  if(admin->multi) {
-+    CURL_TRC_M(admin, "[SHUTDOWN] trigger multi connchanged");
-+    Curl_multi_connchanged(admin->multi);
-   }
- }
- 
- static bool cshutdn_destroy_oldest(struct cshutdn *cshutdn,
--                                   struct Curl_easy *data,
-                                    const char *destination)
- {
-   struct Curl_llist_node *e;
-@@ -184,20 +184,19 @@ static bool cshutdn_destroy_oldest(struct cshutdn *cshutdn,
-     conn = Curl_node_elem(e);
-     Curl_node_remove(e);
-     sigpipe_init(&sigpipe_ctx);
--    sigpipe_apply(data, &sigpipe_ctx);
--    Curl_cshutdn_terminate(data, conn, FALSE);
-+    sigpipe_apply(cshutdn->multi->admin, &sigpipe_ctx);
-+    Curl_conn_terminate(cshutdn->multi->admin, conn, FALSE);
-     sigpipe_restore(&sigpipe_ctx);
-     return TRUE;
-   }
-   return FALSE;
- }
- 
--bool Curl_cshutdn_close_oldest(struct Curl_easy *data,
-+bool Curl_cshutdn_close_oldest(struct cshutdn *cshutdn,
-                                const char *destination)
- {
--  if(data && data->multi) {
--    struct cshutdn *csd = &data->multi->cshutdn;
--    return cshutdn_destroy_oldest(csd, data, destination);
-+  if(cshutdn) {
-+    return cshutdn_destroy_oldest(cshutdn, destination);
-   }
-   return FALSE;
- }
-@@ -205,7 +204,6 @@ bool Curl_cshutdn_close_oldest(struct Curl_easy *data,
- #define NUM_POLLS_ON_STACK 10
- 
- static CURLcode cshutdn_wait(struct cshutdn *cshutdn,
--                             struct Curl_easy *data,
-                              int timeout_ms)
- {
-   struct pollfd a_few_on_stack[NUM_POLLS_ON_STACK];
-@@ -214,7 +212,7 @@ static CURLcode cshutdn_wait(struct cshutdn *cshutdn,
- 
-   Curl_pollfds_init(&cpfds, a_few_on_stack, NUM_POLLS_ON_STACK);
- 
--  result = Curl_cshutdn_add_pollfds(cshutdn, data, &cpfds);
-+  result = Curl_cshutdn_add_pollfds(cshutdn, &cpfds);
-   if(result)
-     goto out;
- 
-@@ -226,11 +224,11 @@ out:
- }
- 
- static void cshutdn_perform(struct cshutdn *cshutdn,
--                            struct Curl_easy *data,
-                             struct Curl_sigpipe_ctx *sigpipe_ctx)
- {
-   struct Curl_llist_node *e = Curl_llist_head(&cshutdn->list);
-   struct Curl_llist_node *enext;
-+  struct Curl_easy *admin = cshutdn->multi->admin;
-   struct connectdata *conn;
-   timediff_t next_expire_ms = 0, ms;
-   bool done;
-@@ -238,67 +236,64 @@ static void cshutdn_perform(struct cshutdn *cshutdn,
-   if(!e)
-     return;
- 
--  CURL_TRC_M(data, "[SHUTDOWN] perform on %zu connections",
-+  CURL_TRC_M(admin, "[SHUTDOWN] perform on %zu connections",
-              Curl_llist_count(&cshutdn->list));
--  sigpipe_apply(data, sigpipe_ctx);
-+  sigpipe_apply(admin, sigpipe_ctx);
-   while(e) {
-     enext = Curl_node_next(e);
-     conn = Curl_node_elem(e);
--    Curl_cshutdn_run_once(data, conn, &done);
-+    Curl_conn_shutdown_once(admin, conn, &done);
-     if(done) {
-       Curl_node_remove(e);
--      Curl_cshutdn_terminate(data, conn, FALSE);
-+      Curl_conn_terminate(admin, conn, FALSE);
-     }
-     else {
-       /* idata has one timer list, but maybe more than one connection.
-        * Set EXPIRE_SHUTDOWN to the smallest time left for all. */
--      ms = Curl_conn_shutdown_timeleft(data, conn);
--      if(ms && ms < next_expire_ms)
-+      ms = Curl_conn_shutdown_timeleft(admin, conn);
-+      if(ms && (!next_expire_ms || (ms < next_expire_ms)))
-         next_expire_ms = ms;
-     }
-     e = enext;
-   }
- 
-   if(next_expire_ms)
--    Curl_expire_ex(data, next_expire_ms, EXPIRE_SHUTDOWN);
-+    Curl_expire_ex(admin, next_expire_ms, EXPIRE_SHUTDOWN);
- }
- 
- static void cshutdn_terminate_all(struct cshutdn *cshutdn,
--                                  struct Curl_easy *data,
-                                   int timeout_ms)
- {
--  struct curltime started = *Curl_pgrs_now(data);
-+  struct Curl_easy *admin = cshutdn->multi->admin;
-+  struct curltime started = *Curl_pgrs_now(admin);
-   struct Curl_llist_node *e;
-   struct Curl_sigpipe_ctx sigpipe_ctx;
- 
--  DEBUGASSERT(cshutdn);
--  DEBUGASSERT(data);
--
--  CURL_TRC_M(data, "[SHUTDOWN] shutdown all");
-+  CURL_TRC_M(admin, "[SHUTDOWN] shutdown all");
-   sigpipe_init(&sigpipe_ctx);
- 
-   while(Curl_llist_head(&cshutdn->list)) {
-     timediff_t spent_ms;
-     int remain_ms;
- 
--    cshutdn_perform(cshutdn, data, &sigpipe_ctx);
-+    cshutdn_perform(cshutdn, &sigpipe_ctx);
- 
-     if(!Curl_llist_head(&cshutdn->list)) {
--      CURL_TRC_M(data, "[SHUTDOWN] shutdown finished cleanly");
-+      CURL_TRC_M(admin, "[SHUTDOWN] shutdown finished cleanly");
-       break;
-     }
- 
-     /* wait for activity, timeout or "nothing" */
--    spent_ms = curlx_ptimediff_ms(Curl_pgrs_now(data), &started);
-+    spent_ms = curlx_ptimediff_ms(Curl_pgrs_now(admin), &started);
-     if(spent_ms >= (timediff_t)timeout_ms) {
--      CURL_TRC_M(data, "[SHUTDOWN] shutdown finished, %s",
-+      CURL_TRC_M(admin, "[SHUTDOWN] shutdown finished, %s",
-                  (timeout_ms > 0) ? "timeout" : "best effort done");
-       break;
-     }
- 
-     remain_ms = timeout_ms - (int)spent_ms;
--    if(cshutdn_wait(cshutdn, data, remain_ms)) {
--      CURL_TRC_M(data, "[SHUTDOWN] shutdown finished, aborted");
-+    if(cshutdn_wait(cshutdn, remain_ms)) {
-+      CURL_TRC_M(admin, "[SHUTDOWN] shutdown finished, aborted");
-       break;
-     }
-   }
-@@ -308,7 +303,7 @@ static void cshutdn_terminate_all(struct cshutdn *cshutdn,
-   while(e) {
-     struct connectdata *conn = Curl_node_elem(e);
-     Curl_node_remove(e);
--    Curl_cshutdn_terminate(data, conn, FALSE);
-+    Curl_conn_terminate(admin, conn, FALSE);
-     e = Curl_llist_head(&cshutdn->list);
-   }
-   DEBUGASSERT(!Curl_llist_count(&cshutdn->list));
-@@ -327,12 +322,13 @@ int Curl_cshutdn_init(struct cshutdn *cshutdn,
- }
- 
- void Curl_cshutdn_destroy(struct cshutdn *cshutdn,
--                          struct Curl_easy *data)
-+                          struct Curl_easy *admin)
- {
--  if(cshutdn->initialized && data) {
-+  if(cshutdn->initialized && admin) {
-     int timeout_ms = 0;
-     /* for testing, run graceful shutdown */
- #ifdef DEBUGBUILD
-+    DEBUGASSERT(!admin->mid);
-     {
-       const char *p = getenv("CURL_GRACEFUL_SHUTDOWN");
-       if(p) {
-@@ -343,29 +339,28 @@ void Curl_cshutdn_destroy(struct cshutdn *cshutdn,
-     }
- #endif
- 
--    CURL_TRC_M(data, "[SHUTDOWN] destroy, %zu connections, timeout=%dms",
-+    CURL_TRC_M(admin, "[SHUTDOWN] destroy, %zu connections, timeout=%dms",
-                Curl_llist_count(&cshutdn->list), timeout_ms);
--    cshutdn_terminate_all(cshutdn, data, timeout_ms);
-+    cshutdn_terminate_all(cshutdn, timeout_ms);
-   }
-   cshutdn->multi = NULL;
-+  cshutdn->initialized = FALSE;
- }
- 
--size_t Curl_cshutdn_count(struct Curl_easy *data)
-+size_t Curl_cshutdn_count(struct cshutdn *cshutdn)
- {
--  if(data && data->multi) {
--    struct cshutdn *csd = &data->multi->cshutdn;
--    return Curl_llist_count(&csd->list);
-+  if(cshutdn) {
-+    return Curl_llist_count(&cshutdn->list);
-   }
-   return 0;
- }
- 
--size_t Curl_cshutdn_dest_count(struct Curl_easy *data,
-+size_t Curl_cshutdn_dest_count(struct cshutdn *cshutdn,
-                                const char *destination)
- {
--  if(data && data->multi) {
--    struct cshutdn *csd = &data->multi->cshutdn;
-+  if(cshutdn) {
-     size_t n = 0;
--    struct Curl_llist_node *e = Curl_llist_head(&csd->list);
-+    struct Curl_llist_node *e = Curl_llist_head(&cshutdn->list);
-     while(e) {
-       struct connectdata *conn = Curl_node_elem(e);
-       if(!strcmp(destination, conn->destination))
-@@ -378,17 +373,17 @@ size_t Curl_cshutdn_dest_count(struct Curl_easy *data,
- }
- 
- static CURLMcode cshutdn_update_ev(struct cshutdn *cshutdn,
--                                   struct Curl_easy *data,
-                                    struct connectdata *conn)
- {
-+  struct Curl_easy *admin = cshutdn->multi->admin;
-   CURLMcode mresult;
- 
-   DEBUGASSERT(cshutdn);
-   DEBUGASSERT(cshutdn->multi->socket_cb);
- 
--  Curl_attach_connection(data, conn);
--  mresult = Curl_multi_ev_assess_conn(cshutdn->multi, data, conn);
--  Curl_detach_connection(data);
-+  Curl_attach_connection(admin, conn, FALSE);
-+  mresult = Curl_multi_ev_assess_conn(cshutdn->multi, admin, conn);
-+  Curl_detach_connection(admin);
-   return mresult;
- }
- 
-@@ -396,47 +391,46 @@ void Curl_cshutdn_add(struct cshutdn *cshutdn,
-                       struct connectdata *conn,
-                       size_t conns_in_pool)
- {
--  struct Curl_easy *data = cshutdn->multi->admin;
-+  struct Curl_easy *admin = cshutdn->multi->admin;
-   size_t max_total = cshutdn->multi->max_total_connections;
- 
-   /* Add the connection to our shutdown list for non-blocking shutdown
-    * during multi processing. */
-   if(max_total > 0 &&
-      (max_total <= (conns_in_pool + Curl_llist_count(&cshutdn->list)))) {
--    CURL_TRC_M(data, "[SHUTDOWN] discarding oldest shutdown connection "
-+    CURL_TRC_M(admin, "[SHUTDOWN] discarding oldest shutdown connection "
-                "due to connection limit of %zu", max_total);
--    cshutdn_destroy_oldest(cshutdn, data, NULL);
-+    cshutdn_destroy_oldest(cshutdn, NULL);
-   }
- 
-   if(cshutdn->multi->socket_cb) {
--    if(cshutdn_update_ev(cshutdn, data, conn)) {
--      CURL_TRC_M(data, "[SHUTDOWN] update events failed, discarding #%"
-+    if(cshutdn_update_ev(cshutdn, conn)) {
-+      CURL_TRC_M(admin, "[SHUTDOWN] update events failed, discarding #%"
-                  FMT_OFF_T, conn->connection_id);
--      Curl_cshutdn_terminate(data, conn, FALSE);
-+      Curl_conn_terminate(admin, conn, FALSE);
-       return;
-     }
-   }
- 
-   Curl_llist_append(&cshutdn->list, conn, &conn->cshutdn_node);
--  CURL_TRC_M(data, "[SHUTDOWN] added #%" FMT_OFF_T
-+  CURL_TRC_M(admin, "[SHUTDOWN] added #%" FMT_OFF_T
-              " to shutdowns, now %zu conns in shutdown",
-              conn->connection_id, Curl_llist_count(&cshutdn->list));
- }
- 
- void Curl_cshutdn_perform(struct cshutdn *cshutdn,
--                          struct Curl_easy *data,
-                           struct Curl_sigpipe_ctx *sigpipe_ctx)
- {
--  cshutdn_perform(cshutdn, data, sigpipe_ctx);
-+  cshutdn_perform(cshutdn, sigpipe_ctx);
- }
- 
- /* return fd_set info about the shutdown connections */
- void Curl_cshutdn_setfds(struct cshutdn *cshutdn,
--                         struct Curl_easy *data,
-                          fd_set *read_fd_set, fd_set *write_fd_set,
-                          int *maxfd)
- {
-   if(Curl_llist_head(&cshutdn->list)) {
-+    struct Curl_easy *admin = cshutdn->multi->admin;
-     struct Curl_llist_node *e;
-     struct easy_pollset ps;
- 
-@@ -447,9 +441,9 @@ void Curl_cshutdn_setfds(struct cshutdn *cshutdn,
-       CURLcode result;
- 
-       Curl_pollset_reset(&ps);
--      Curl_attach_connection(data, conn);
--      result = Curl_conn_adjust_pollset(data, conn, &ps);
--      Curl_detach_connection(data);
-+      Curl_attach_connection(admin, conn, FALSE);
-+      result = Curl_conn_adjust_pollset(admin, conn, &ps);
-+      Curl_detach_connection(admin);
- 
-       if(result)
-         continue;
-@@ -473,13 +467,13 @@ void Curl_cshutdn_setfds(struct cshutdn *cshutdn,
- 
- /* return information about the shutdown connections */
- unsigned int Curl_cshutdn_add_waitfds(struct cshutdn *cshutdn,
--                                      struct Curl_easy *data,
-                                       struct Curl_waitfds *cwfds)
- {
-   unsigned int need = 0;
- 
-   if(Curl_llist_head(&cshutdn->list)) {
-     struct Curl_llist_node *e;
-+    struct Curl_easy *admin = cshutdn->multi->admin;
-     struct easy_pollset ps;
-     struct connectdata *conn;
-     CURLcode result;
-@@ -488,9 +482,9 @@ unsigned int Curl_cshutdn_add_waitfds(struct cshutdn *cshutdn,
-     for(e = Curl_llist_head(&cshutdn->list); e; e = Curl_node_next(e)) {
-       conn = Curl_node_elem(e);
-       Curl_pollset_reset(&ps);
--      Curl_attach_connection(data, conn);
--      result = Curl_conn_adjust_pollset(data, conn, &ps);
--      Curl_detach_connection(data);
-+      Curl_attach_connection(admin, conn, FALSE);
-+      result = Curl_conn_adjust_pollset(admin, conn, &ps);
-+      Curl_detach_connection(admin);
- 
-       if(!result)
-         need += Curl_waitfds_add_ps(cwfds, &ps);
-@@ -501,7 +495,6 @@ unsigned int Curl_cshutdn_add_waitfds(struct cshutdn *cshutdn,
- }
- 
- CURLcode Curl_cshutdn_add_pollfds(struct cshutdn *cshutdn,
--                                  struct Curl_easy *data,
-                                   struct curl_pollfds *cpfds)
- {
-   CURLcode result = CURLE_OK;
-@@ -509,15 +502,16 @@ CURLcode Curl_cshutdn_add_pollfds(struct cshutdn *cshutdn,
-   if(Curl_llist_head(&cshutdn->list)) {
-     struct Curl_llist_node *e;
-     struct easy_pollset ps;
-+    struct Curl_easy *admin = cshutdn->multi->admin;
-     struct connectdata *conn;
- 
-     Curl_pollset_init(&ps);
-     for(e = Curl_llist_head(&cshutdn->list); e; e = Curl_node_next(e)) {
-       conn = Curl_node_elem(e);
-       Curl_pollset_reset(&ps);
--      Curl_attach_connection(data, conn);
--      result = Curl_conn_adjust_pollset(data, conn, &ps);
--      Curl_detach_connection(data);
-+      Curl_attach_connection(admin, conn, FALSE);
-+      result = Curl_conn_adjust_pollset(admin, conn, &ps);
-+      Curl_detach_connection(admin);
- 
-       if(!result)
-         result = Curl_pollfds_add_ps(cpfds, &ps);
-diff --git a/lib/cshutdn.h b/lib/cshutdn.h
-index 8479524993..a0338f6488 100644
---- a/lib/cshutdn.h
-+++ b/lib/cshutdn.h
-@@ -33,20 +33,20 @@ struct Curl_share;
- struct Curl_sigpipe_ctx;
- 
- /* Run the shutdown of the connection once.
-- * Shortly attach/detach `data` to `conn` while doing so.
-+ * Shortly attach/detach the admin handle to `conn` while doing so.
-  * `done` will be set TRUE if any error was encountered or if
-  * the connection was shut down completely. */
--void Curl_cshutdn_run_once(struct Curl_easy *data,
--                           struct connectdata *conn,
--                           bool *done);
-+void Curl_conn_shutdown_once(struct Curl_easy *admin,
-+                             struct connectdata *conn,
-+                             bool *done);
- 
- /* Terminates the connection, e.g. closes and destroys it.
-  * If `do_shutdown` is TRUE, the shutdown will be run once before
-  * terminating it.
-  * Takes ownership of `conn`. */
--void Curl_cshutdn_terminate(struct Curl_easy *data,
--                            struct connectdata *conn,
--                            bool do_shutdown);
-+void Curl_conn_terminate(struct Curl_easy *admin,
-+                         struct connectdata *conn,
-+                         bool do_shutdown);
- 
- /* A `cshutdown` is always owned by a multi handle to maintain
-  * the connections to be shut down. It registers timers and
-@@ -57,25 +57,28 @@ struct cshutdn {
-   BIT(initialized);
- };
- 
-+/* Get the cshutdn instance relevant for `data` or NULL if there is none */
-+struct cshutdn *Curl_cshutdn_get(struct Curl_easy *data);
-+
- /* Init as part of the given multi handle. */
- int Curl_cshutdn_init(struct cshutdn *cshutdn,
-                       struct Curl_multi *multi);
- 
- /* Terminate all remaining connections and free resources. */
- void Curl_cshutdn_destroy(struct cshutdn *cshutdn,
--                          struct Curl_easy *data);
-+                          struct Curl_easy *admin);
- 
- /* Number of connections being shut down. */
--size_t Curl_cshutdn_count(struct Curl_easy *data);
-+size_t Curl_cshutdn_count(struct cshutdn *cshutdn);
- 
- /* Number of connections to the destination being shut down. */
--size_t Curl_cshutdn_dest_count(struct Curl_easy *data,
-+size_t Curl_cshutdn_dest_count(struct cshutdn *cshutdn,
-                                const char *destination);
- 
- /* Close the oldest connection in shutdown to destination or,
-  * when destination is NULL for any destination.
-  * Return TRUE if a connection has been closed. */
--bool Curl_cshutdn_close_oldest(struct Curl_easy *data,
-+bool Curl_cshutdn_close_oldest(struct cshutdn *cshutdn,
-                                const char *destination);
- 
- /* Add a connection to have it shut down. Terminate the oldest
-@@ -86,21 +89,17 @@ void Curl_cshutdn_add(struct cshutdn *cshutdn,
- 
- /* Add sockets and POLLIN/OUT flags for connections being shut down. */
- CURLcode Curl_cshutdn_add_pollfds(struct cshutdn *cshutdn,
--                                  struct Curl_easy *data,
-                                   struct curl_pollfds *cpfds);
- 
- unsigned int Curl_cshutdn_add_waitfds(struct cshutdn *cshutdn,
--                                      struct Curl_easy *data,
-                                       struct Curl_waitfds *cwfds);
- 
- void Curl_cshutdn_setfds(struct cshutdn *cshutdn,
--                         struct Curl_easy *data,
-                          fd_set *read_fd_set, fd_set *write_fd_set,
-                          int *maxfd);
- 
- /* Run maintenance on all connections. */
- void Curl_cshutdn_perform(struct cshutdn *cshutdn,
--                          struct Curl_easy *data,
-                           struct Curl_sigpipe_ctx *sigpipe_ctx);
- 
- #endif /* HEADER_CURL_CSHUTDN_H */
-diff --git a/lib/curl_share.c b/lib/curl_share.c
-index 94469bc3ef..ce0b0f5083 100644
---- a/lib/curl_share.c
-+++ b/lib/curl_share.c
-@@ -35,7 +35,7 @@
- static void share_destroy(struct Curl_share *share)
- {
-   if(share->specifier & (1 << CURL_LOCK_DATA_CONNECT)) {
--    Curl_cpool_destroy(&share->cpool);
-+    Curl_cpool_destroy(&share->cpool, share->admin);
-   }
- 
-   Curl_dnscache_destroy(&share->dnscache);
-@@ -261,7 +261,7 @@ CURLSHcode curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
-     case CURL_LOCK_DATA_CONNECT:
-       /* It is safe to set this option several times on a share. */
-       if(!share->cpool.initialized) {
--        Curl_cpool_init(&share->cpool, share->admin, share, 103);
-+        Curl_cpool_init(&share->cpool, share, 103);
-       }
-       break;
- 
-@@ -368,11 +368,11 @@ CURLSHcode curl_share_cleanup(CURLSH *sh)
-   return CURLSHE_OK;
- }
- 
--CURLSHcode Curl_share_lock(struct Curl_easy *data, curl_lock_data type,
--                           curl_lock_access accesstype)
-+CURLSHcode Curl_share_lock_share(struct Curl_share *share,
-+                                 struct Curl_easy *data,
-+                                 curl_lock_data type,
-+                                 curl_lock_access accesstype)
- {
--  struct Curl_share *share = data->share;
--
-   if(!share)
-     return CURLSHE_INVALID;
- 
-@@ -385,10 +385,16 @@ CURLSHcode Curl_share_lock(struct Curl_easy *data, curl_lock_data type,
-   return CURLSHE_OK;
- }
- 
--CURLSHcode Curl_share_unlock(struct Curl_easy *data, curl_lock_data type)
-+CURLSHcode Curl_share_lock(struct Curl_easy *data, curl_lock_data type,
-+                           curl_lock_access accesstype)
- {
--  struct Curl_share *share = data->share;
-+  return Curl_share_lock_share(data->share, data, type, accesstype);
-+}
- 
-+CURLSHcode Curl_share_unlock_share(struct Curl_share *share,
-+                                   struct Curl_easy *data,
-+                                   curl_lock_data type)
-+{
-   if(!share)
-     return CURLSHE_INVALID;
- 
-@@ -400,6 +406,11 @@ CURLSHcode Curl_share_unlock(struct Curl_easy *data, curl_lock_data type)
-   return CURLSHE_OK;
- }
- 
-+CURLSHcode Curl_share_unlock(struct Curl_easy *data, curl_lock_data type)
-+{
-+  return Curl_share_unlock_share(data->share, data, type);
-+}
-+
- CURLcode Curl_share_easy_unlink(struct Curl_easy *data)
- {
-   struct Curl_share *share = data->share;
-diff --git a/lib/curl_share.h b/lib/curl_share.h
-index 1d49a8d1dd..5c687989e0 100644
---- a/lib/curl_share.h
-+++ b/lib/curl_share.h
-@@ -80,6 +80,14 @@ CURLSHcode Curl_share_lock(struct Curl_easy *data, curl_lock_data type,
-                            curl_lock_access accesstype);
- CURLSHcode Curl_share_unlock(struct Curl_easy *data, curl_lock_data type);
- 
-+CURLSHcode Curl_share_lock_share(struct Curl_share *share,
-+                                 struct Curl_easy *data,
-+                                 curl_lock_data type,
-+                                 curl_lock_access accesstype);
-+CURLSHcode Curl_share_unlock_share(struct Curl_share *share,
-+                                   struct Curl_easy *data,
-+                                   curl_lock_data type);
-+
- /* convenience macro to check if this handle is using a shared SSL spool */
- #define CURL_SHARE_ssl_scache(data)                                \
-   ((data)->share &&                                                \
-diff --git a/lib/curl_trc.c b/lib/curl_trc.c
-index f8287e420f..f3f048d342 100644
---- a/lib/curl_trc.c
-+++ b/lib/curl_trc.c
-@@ -92,8 +92,7 @@ static struct curl_trc_feat Curl_trc_feat_ids = {
- 
- static size_t trc_print_ids(struct Curl_easy *data, char *buf, size_t maxlen)
- {
--  curl_off_t cid = data->conn ?
--                   data->conn->connection_id : data->state.recent_conn_id;
-+  curl_off_t cid = data->state.lastconnect_id;
-   if(data->id >= 0) {
-     if(cid >= 0)
-       return curl_msnprintf(buf, maxlen, CURL_TRC_FMT_IDSDC, data->id, cid);
-diff --git a/lib/easy.c b/lib/easy.c
-index d60bdaed7b..44516a79e7 100644
---- a/lib/easy.c
-+++ b/lib/easy.c
-@@ -761,7 +761,7 @@ static CURLcode easy_perform(struct Curl_easy *data, bool events)
-     Curl_detach_connection(data);
-     s = Curl_getconnectinfo(data, &c);
-     if((s != CURL_SOCKET_BAD) && c) {
--      Curl_conn_terminate(data, c, TRUE);
-+      Curl_conn_close(data, c, TRUE);
-     }
-     DEBUGASSERT(!data->conn);
-   }
-@@ -977,7 +977,6 @@ CURL *curl_easy_duphandle(CURL *curl)
- 
-   /* the connection pool is setup on demand */
-   outcurl->state.lastconnect_id = -1;
--  outcurl->state.recent_conn_id = -1;
-   outcurl->id = -1;
-   outcurl->mid = UINT32_MAX;
-   outcurl->master_mid = UINT32_MAX;
-@@ -1110,7 +1109,7 @@ void curl_easy_reset(CURL *curl)
- 
-   data->progress.hide = TRUE;
-   data->state.current_speed = -1; /* init to negative == impossible */
--  data->state.recent_conn_id = -1; /* clear remembered connection id */
-+  data->state.lastconnect_id = -1; /* clear remembered connection id */
- 
-   /* zero out authentication data: */
-   memset(&data->state.authhost, 0, sizeof(struct auth));
-@@ -1243,7 +1242,7 @@ CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen, size_t *n)
-   if(!data->conn)
-     /* on first invoke, the transfer has been detached from the connection and
-        needs to be reattached */
--    Curl_attach_connection(data, c);
-+    Curl_attach_connection(data, c, TRUE);
- 
-   *n = 0;
-   return Curl_conn_recv(data, FIRSTSOCKET, buffer, buflen, n);
-@@ -1262,7 +1261,7 @@ CURLcode Curl_connect_only_attach(struct Curl_easy *data)
-   if(!data->conn)
-     /* on first invoke, the transfer has been detached from the connection and
-        needs to be reattached */
--    Curl_attach_connection(data, c);
-+    Curl_attach_connection(data, c, TRUE);
- 
-   return CURLE_OK;
- }
-@@ -1288,7 +1287,7 @@ CURLcode Curl_senddata(struct Curl_easy *data, const void *buffer,
-   if(!data->conn)
-     /* on first invoke, the transfer has been detached from the connection and
-        needs to be reattached */
--    Curl_attach_connection(data, c);
-+    Curl_attach_connection(data, c, TRUE);
- 
-   sigpipe_ignore(data, &sigpipe_ctx);
-   result = Curl_conn_send(data, FIRSTSOCKET, buffer, buflen, FALSE, n);
-diff --git a/lib/getinfo.c b/lib/getinfo.c
-index fde4aa4ef2..20c907ab06 100644
---- a/lib/getinfo.c
-+++ b/lib/getinfo.c
-@@ -469,8 +469,7 @@ static CURLcode getinfo_offt(struct Curl_easy *data, CURLINFO info,
-     *param_offt = data->id;
-     break;
-   case CURLINFO_CONN_ID:
--    *param_offt = data->conn ?
--      data->conn->connection_id : data->state.recent_conn_id;
-+    *param_offt = data->state.lastconnect_id;
-     break;
-   case CURLINFO_EARLYDATA_SENT_T:
-     *param_offt = data->progress.earlydata_sent;
-diff --git a/lib/multi.c b/lib/multi.c
-index 1ae679565e..681ed2838d 100644
---- a/lib/multi.c
-+++ b/lib/multi.c
-@@ -299,7 +299,7 @@ struct Curl_multi *Curl_multi_handle(uint32_t xfer_table_size,
-   if(Curl_cshutdn_init(&multi->cshutdn, multi))
-     goto error;
- 
--  Curl_cpool_init(&multi->cpool, multi->admin, NULL, chashsize);
-+  Curl_cpool_init(&multi->cpool, NULL, chashsize);
- 
- #ifdef USE_SSL
-   if(Curl_ssl_scache_create(sesssize, 2, &multi->ssl_scache))
-@@ -348,7 +348,7 @@ error:
-   Curl_multi_ev_cleanup(multi);
-   Curl_hash_destroy(&multi->proto_hash);
-   Curl_dnscache_destroy(&multi->dnscache);
--  Curl_cpool_destroy(&multi->cpool);
-+  Curl_cpool_destroy(&multi->cpool, multi->admin);
-   Curl_cshutdn_destroy(&multi->cshutdn, multi->admin);
- #ifdef USE_SSL
-   Curl_ssl_scache_destroy(multi->ssl_scache);
-@@ -667,8 +667,6 @@ static void multi_done_locked(struct connectdata *conn,
-   }
- 
-   data->state.done = TRUE; /* called now! */
--  data->state.recent_conn_id = conn->connection_id;
--
-   Curl_dnscache_prune(data);
- 
-   if(multi_conn_should_close(conn, data, (bool)mdctx->premature)) {
-@@ -678,20 +676,19 @@ static void multi_done_locked(struct connectdata *conn,
-                data->set.reuse_forbid, conn->bits.close, mdctx->premature,
-                Curl_conn_is_multiplex(conn, FIRSTSOCKET));
-     connclose(conn, "disconnecting");
--    Curl_conn_terminate(data, conn, (bool)mdctx->premature);
-+    Curl_conn_close(data, conn, (bool)mdctx->premature);
-   }
-   else if(!Curl_conn_get_max_concurrent(data, conn, FIRSTSOCKET)) {
-     CURL_TRC_M(data, "multi_done, conn #%" FMT_OFF_T " to %s was shutdown"
-                " by server, not reusing", conn->connection_id,
-                conn->destination);
-     connclose(conn, "server shutdown");
--    Curl_conn_terminate(data, conn, (bool)mdctx->premature);
-+    Curl_conn_close(data, conn, (bool)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 */
--      data->state.lastconnect_id = conn->connection_id;
-       infof(data, "Connection #%" FMT_OFF_T " to host %s left intact",
-             conn->connection_id, conn->destination);
-     }
-@@ -888,7 +885,7 @@ CURLMcode curl_multi_remove_handle(CURLM *m, CURL *curl)
-     curl_socket_t s;
-     s = Curl_getconnectinfo(data, &c);
-     if((s != CURL_SOCKET_BAD) && c) {
--      Curl_conn_terminate(data, c, TRUE);
-+      Curl_conn_close(data, c, TRUE);
-     }
-   }
- 
-@@ -978,16 +975,23 @@ void Curl_detach_connection(struct Curl_easy *data)
- /*
-  * Curl_attach_connection() attaches this transfer to this connection.
-  *
-- * This is the only function that should assign data->conn
-+ * This is the only function that should assign data->conn.
-+ * `matched == TRUE` means the transfer's properties match this
-+ * connection and it is not a temporary attach for maintenance.
-  */
- void Curl_attach_connection(struct Curl_easy *data,
--                            struct connectdata *conn)
-+                            struct connectdata *conn,
-+                            bool matched)
- {
-   DEBUGASSERT(data);
-   DEBUGASSERT(!data->conn);
-   DEBUGASSERT(conn);
-   DEBUGASSERT(conn->attached_xfers < UINT32_MAX);
-   data->conn = conn;
-+  if(matched)
-+    data->state.lastconnect_id = conn->connection_id;
-+  else
-+    DEBUGASSERT(!data->mid); /* admin handle */
-   conn->attached_xfers++;
-   /* all attached transfers must be from the same multi */
-   if(!conn->attached_multi)
-@@ -1317,8 +1321,8 @@ CURLMcode curl_multi_fdset(CURLM *m,
-     } while(Curl_uint32_bset_next(&multi->process, mid, &mid));
-   }
- 
--  Curl_cshutdn_setfds(&multi->cshutdn, multi->admin,
--                      read_fd_set, write_fd_set, &this_max_fd);
-+  Curl_cshutdn_setfds(&multi->cshutdn, read_fd_set, write_fd_set,
-+                      &this_max_fd);
- 
-   *max_fd = this_max_fd;
-   Curl_pollset_cleanup(&ps);
-@@ -1363,7 +1367,7 @@ CURLMcode curl_multi_waitfds(CURLM *m,
-     } while(Curl_uint32_bset_next(&multi->process, mid, &mid));
-   }
- 
--  need += Curl_cshutdn_add_waitfds(&multi->cshutdn, multi->admin, &cwfds);
-+  need += Curl_cshutdn_add_waitfds(&multi->cshutdn, &cwfds);
- 
-   if(need != cwfds.n && ufds)
-     mresult = CURLM_OUT_OF_MEMORY;
-@@ -1604,7 +1608,7 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
-     } while(Curl_uint32_bset_next(&multi->process, mid, &mid));
-   }
- 
--  if(Curl_cshutdn_add_pollfds(&multi->cshutdn, multi->admin, &cpfds)) {
-+  if(Curl_cshutdn_add_pollfds(&multi->cshutdn, &cpfds)) {
-     mresult = CURLM_OUT_OF_MEMORY;
-     goto out;
-   }
-@@ -1792,7 +1796,7 @@ CURLMcode Curl_multi_add_perform(struct Curl_multi *multi,
- 
-     /* take this handle to the perform state right away */
-     multistate(data, MSTATE_PERFORMING);
--    Curl_attach_connection(data, conn);
-+    Curl_attach_connection(data, conn, TRUE);
-     CURL_REQ_SET_RECV(data);
-   }
-   return mresult;
-@@ -2417,7 +2421,7 @@ static CURLcode is_finished(struct Curl_multi *multi,
-              We do not have to do this in every case block above where a
-              failure is detected */
-           Curl_detach_connection(data);
--          Curl_conn_terminate(data, conn, dead_connection);
-+          Curl_conn_close(data, conn, dead_connection);
-         }
-       }
-       else if(data->mstate == MSTATE_CONNECT) {
-@@ -2741,7 +2745,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
-                                  struct Curl_easy *data,
-                                  struct Curl_sigpipe_ctx *sigpipe_ctx)
- {
--  CURLMcode mresult;
-+  CURLMcode mresult = CURLM_OK;
-   CURLcode result = CURLE_OK;
- 
-   if(!GOOD_EASY_HANDLE(data))
-@@ -2771,8 +2775,8 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
- #ifdef USE_RESOLV_THREADED
-     Curl_async_thrdd_multi_process(multi);
- #endif
--    Curl_cshutdn_perform(&multi->cshutdn, multi->admin, sigpipe_ctx);
--    return CURLM_OK;
-+    Curl_cshutdn_perform(&multi->cshutdn, sigpipe_ctx);
-+    goto out;
-   }
- 
-   sigpipe_apply(data, sigpipe_ctx);
-@@ -2791,8 +2795,10 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
-        data->mstate < MSTATE_COMPLETED) {
-       /* Make sure we set the connection's current owner */
-       DEBUGASSERT(data->conn);
--      if(!data->conn)
--        return CURLM_INTERNAL_ERROR;
-+      if(!data->conn) {
-+        mresult = CURLM_INTERNAL_ERROR;
-+        goto out;
-+      }
-     }
- 
-     /* Wait for the connect state as only then is the start time stored, but
-@@ -2874,7 +2880,8 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
-       break;
- 
-     default:
--      return CURLM_INTERNAL_ERROR;
-+      mresult = CURLM_INTERNAL_ERROR;
-+      goto out;
-     }
- 
-     if(data->mstate >= MSTATE_CONNECT &&
-@@ -2898,11 +2905,13 @@ statemachine_end:
- 
-     if(MSTATE_COMPLETED == data->mstate) {
-       handle_completed(multi, data, result);
--      return CURLM_OK;
-+      mresult = CURLM_OK;
-+      goto out;
-     }
-   } while((mresult == CURLM_CALL_MULTI_PERFORM) ||
-           multi_ischanged(multi, FALSE));
- 
-+out:
-   data->result = result;
-   return mresult;
- }
-@@ -3049,7 +3058,7 @@ CURLMcode curl_multi_cleanup(CURLM *m)
- #ifdef USE_RESOLV_THREADED
-     Curl_async_thrdd_multi_destroy(multi, !multi->quick_exit);
- #endif
--    Curl_cpool_destroy(&multi->cpool);
-+    Curl_cpool_destroy(&multi->cpool, multi->admin);
-     Curl_cshutdn_destroy(&multi->cshutdn, multi->admin);
-     if(multi->admin) {
-       CURL_TRC_M(multi->admin, "multi_cleanup, closing admin handle, done");
-@@ -3438,7 +3447,7 @@ CURLMcode curl_multi_setopt(CURLM *m, CURLMoption option, ...)
-       Curl_dnscache_clear(multi->admin);
-     }
-     if(val & CURLMNWC_CLEAR_CONNS) {
--      Curl_cpool_nw_changed(multi->admin);
-+      Curl_cpool_nw_changed(&multi->cpool, multi->admin);
-     }
-     break;
-   }
-diff --git a/lib/multiif.h b/lib/multiif.h
-index 920bf0e917..db9c8acf18 100644
---- a/lib/multiif.h
-+++ b/lib/multiif.h
-@@ -34,7 +34,8 @@ void Curl_expire_clear(struct Curl_easy *data);
- void Curl_expire_done(struct Curl_easy *data, expire_id id);
- CURLMcode Curl_update_timer(struct Curl_multi *multi) WARN_UNUSED_RESULT;
- void Curl_attach_connection(struct Curl_easy *data,
--                            struct connectdata *conn);
-+                            struct connectdata *conn,
-+                            bool matched);
- void Curl_detach_connection(struct Curl_easy *data);
- bool Curl_multiplex_wanted(const struct Curl_multi *multi);
- void Curl_set_in_callback(struct Curl_easy *data, bool value);
-diff --git a/lib/url.c b/lib/url.c
-index 505e08a7e1..4cfd3a1bb7 100644
---- a/lib/url.c
-+++ b/lib/url.c
-@@ -469,7 +469,6 @@ CURLcode Curl_open(struct Curl_easy **curl)
-   data->magic = CURLEASY_MAGIC_NUMBER;
-   /* most recent connection is not yet defined */
-   data->state.lastconnect_id = -1;
--  data->state.recent_conn_id = -1;
-   /* and not assigned an id yet */
-   data->id = -1;
-   data->mid = UINT32_MAX;
-@@ -622,14 +621,14 @@ bool Curl_conn_seems_dead(struct connectdata *conn,
-       /* The protocol has a special method for checking the state of the
-          connection. Use it to check if the connection is dead. */
-       /* briefly attach the connection for the check */
--      Curl_attach_connection(data, conn);
-+      Curl_attach_connection(data, conn, FALSE);
-       dead = conn->scheme->run->connection_is_dead(data, conn);
-       Curl_detach_connection(data);
-     }
-     else {
-       bool input_pending = FALSE;
- 
--      Curl_attach_connection(data, conn);
-+      Curl_attach_connection(data, conn, FALSE);
-       dead = !Curl_conn_is_alive(data, conn, &input_pending);
-       if(input_pending) {
-         /* For reuse, we want a "clean" connection state. This includes
-@@ -665,7 +664,7 @@ CURLcode Curl_conn_upkeep(struct Curl_easy *data,
-     return result;
- 
-   /* briefly attach for action */
--  Curl_attach_connection(data, conn);
-+  Curl_attach_connection(data, conn, FALSE);
-   result = Curl_conn_keep_alive(data, conn, FIRSTSOCKET);
-   Curl_detach_connection(data);
- 
-@@ -690,6 +689,7 @@ struct url_conn_match {
-   struct connectdata *found;
-   struct Curl_easy *data;
-   struct connectdata *needle;
-+  struct curltime now;
-   BIT(may_multiplex);
-   BIT(want_ntlm_http);
-   BIT(want_proxy_ntlm_http);
-@@ -1002,27 +1002,54 @@ static bool url_match_ssl_config(struct connectdata *conn,
-   return TRUE;
- }
- 
-+#if defined(USE_SPNEGO) || defined(USE_NTLM)
-+static bool url_allow_sspi_empty_creds(struct Curl_creds *conn_creds,
-+                                       struct Curl_easy *data,
-+                                       struct connectdata *conn)
-+{
-+#ifdef USE_WINDOWS_SSPI
-+  /* Empty user: SSPI on Windows can make use of an "ambient"
-+   * user from a "SecurityToken" associated with the current thread or
-+   * process. This token can be switched at any time. We are therefore
-+   * not able to find out reliably what token the connection really
-+   * used, nor what token in the next connect attempt will use.
-+   * To avoid TOCTOU attacks, do not reuse on empty credentials
-+   * UNLESS this connection is the one used by this transfer before. */
-+  if(!Curl_creds_has_user(conn_creds) &&
-+     (data->state.lastconnect_id != conn->connection_id))
-+    return FALSE;
-+#else
-+  (void)conn_creds;
-+  (void)data;
-+  (void)conn;
-+#endif
-+  return TRUE;
-+}
-+#endif /* USE_SPNEGO || USE_NTLM */
-+
- #ifdef USE_NTLM
- static bool url_match_auth_ntlm(struct connectdata *conn,
-                                 struct url_conn_match *m)
- {
--  /* 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(m->want_ntlm_http) {
-+  if(conn->http_ntlm_state != NTLMSTATE_NONE) {
-+    /* Connection is using NTLM. We cannot reuse if transfer
-+     * has different Auth input parameters.
-+     * To avoid TOCTOU attacks, do not reuse on empty credentials. */
-+    if(!m->want_ntlm_http ||
-+       !Curl_creds_has_user(conn->creds) ||
-+       !Curl_creds_same(conn->creds, m->data->state.creds) ||
-+       !Curl_peer_equal(conn->creds_origin, m->data->state.origin))
-+      return FALSE;
-+    if(!url_allow_sspi_empty_creds(conn->creds, m->data, conn))
-+      return FALSE;
-+  }
-+  else if(m->want_ntlm_http) {
-+    /* Transfer wants NTLM, connection is not using it.
-+     * Do not reuse when connection has credentials and they differ. */
-     if(conn->creds &&
-        (!Curl_creds_same(conn->creds, m->data->state.creds) ||
--        !Curl_peer_equal(conn->creds_origin, m->data->state.origin))) {
--      /* connection credentials in play and not the same or not for the
--       * same origin. */
-+        !Curl_peer_equal(conn->creds_origin, m->data->state.origin)))
-       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
-@@ -1069,23 +1096,36 @@ static bool url_match_auth_ntlm(struct connectdata *conn,
- static bool url_match_auth_nego(struct connectdata *conn,
-                                 struct url_conn_match *m)
- {
--  /* If we are looking for an HTTP+Negotiate connection, check if this is
--     already authenticating with the right credentials. If not, keep looking
--     so that we can reuse Negotiate connections if possible. */
--  if(m->want_nego_http) {
-+  if(conn->http_negotiate_state != GSS_AUTHNONE) {
-+    /* Connection is using Negotiate. We cannot reuse if transfer
-+     * has different Auth input parameters. */
-+    if(!m->want_nego_http ||
-+       !Curl_creds_same(conn->creds, m->data->state.creds) ||
-+       !Curl_peer_equal(conn->creds_origin, m->data->state.origin))
-+      return FALSE;
-+    if(!url_allow_sspi_empty_creds(conn->creds, m->data, conn))
-+      return FALSE;
-+  }
-+  else if(m->want_nego_http) {
-+    /* Transfer wants Negotiate, connection is not using it.
-+     * Do not reuse when connection has credentials and they differ. */
-     if(conn->creds &&
-        (!Curl_creds_same(conn->creds, m->data->state.creds) ||
-         !Curl_peer_equal(conn->creds_origin, m->data->state.origin)))
-       return FALSE;
-   }
--  else if(conn->http_negotiate_state != GSS_AUTHNONE) {
--    /* Connection is using Negotiate auth but we do not want Negotiate */
--    return FALSE;
--  }
- 
- #ifndef CURL_DISABLE_PROXY
-   /* Same for Proxy Negotiate authentication */
--  if(m->want_proxy_nego_http) {
-+  if(conn->proxy_negotiate_state != GSS_AUTHNONE) {
-+    if(!m->want_proxy_nego_http ||
-+       !Curl_creds_same(m->needle->http_proxy.creds, conn->http_proxy.creds))
-+      return FALSE;
-+    if(!url_allow_sspi_empty_creds(m->needle->http_proxy.creds,
-+                                   m->data, conn))
-+      return FALSE;
-+  }
-+  else if(m->want_proxy_nego_http) {
-     /* Both conn->http_proxy.user and conn->http_proxy.passwd can be
-      * NULL */
-     if(!conn->http_proxy.creds)
-@@ -1094,10 +1134,6 @@ static bool url_match_auth_nego(struct connectdata *conn,
-     if(!Curl_creds_same(m->needle->http_proxy.creds, conn->http_proxy.creds))
-       return FALSE;
-   }
--  else if(conn->proxy_negotiate_state != GSS_AUTHNONE) {
--    /* Proxy connection is using Negotiate auth but we do not want Negotiate */
--    return FALSE;
--  }
- #endif
-   if(m->want_nego_http || m->want_proxy_nego_http) {
-     /* Credentials are already checked, we may use this connection. We MUST
-@@ -1172,9 +1208,13 @@ static bool url_match_conn(struct connectdata *conn, void *userdata)
-   if(!url_match_multiplex_limits(conn, m))
-     return FALSE;
- 
--  if(!CONN_INUSE(conn) && Curl_conn_seems_dead(conn, m->data)) {
--    /* remove and disconnect. */
--    Curl_conn_terminate(m->data, conn, FALSE);
-+  /* If we are going to pick an idle connection, do an extra
-+   * health check before we reuse it. */
-+  if(!CONN_INUSE(conn) &&
-+     !Curl_cpool_conn_seems_healthy(conn, m->data, &m->now)) {
-+    infof(m->data, "Connection %" FMT_OFF_T " seems to be dead, terminating",
-+          conn->connection_id);
-+    Curl_conn_close(m->data, conn, FALSE);
-     return FALSE;
-   }
- 
-@@ -1189,7 +1229,7 @@ static bool url_match_result(void *userdata)
-   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);
-+    Curl_attach_connection(match->data, match->found, TRUE);
-     return TRUE;
-   }
-   else if(match->seen_single_use_conn && !match->seen_multiplex_conn) {
-@@ -1220,15 +1260,20 @@ static bool url_attach_existing(struct Curl_easy *data,
-                                 struct connectdata *needle,
-                                 bool *waitpipe)
- {
-+  struct cpool *cpool = Curl_cpool_get_instance(data);
-   struct url_conn_match match;
-   bool success;
- 
-   DEBUGASSERT(!data->conn);
-+
-   memset(&match, 0, sizeof(match));
-   match.data = data;
-   match.needle = needle;
-+  match.now = *Curl_pgrs_now(data);
-   match.may_multiplex = xfer_may_multiplex(data, needle);
- 
-+  Curl_cpool_prune_dead(cpool, data);
-+
- #ifdef USE_NTLM
-   match.want_ntlm_http =
-     (data->state.authhost.want & CURLAUTH_NTLM) &&
-@@ -2351,9 +2396,9 @@ static CURLcode url_find_or_create_conn(struct Curl_easy *data)
-       goto out;
- 
-     /* Setup a "faked" transfer that will do nothing */
--    Curl_attach_connection(data, needle);
-+    result = Curl_cpool_add(data, needle);
-+    Curl_attach_connection(data, needle, TRUE);
-     needle = NULL;
--    result = Curl_cpool_add(data, data->conn);
-     if(!result) {
-       /* Setup whatever necessary for a resumed transfer */
-       result = setup_range(data);
-@@ -2378,7 +2423,7 @@ static CURLcode url_find_or_create_conn(struct Curl_easy *data)
-     goto out;
- 
-   /* Get rid of any dead connections so limit are easier kept. */
--  Curl_cpool_prune_dead(data);
-+  Curl_cpool_prune_dead(Curl_cpool_get_instance(data), data);
- 
-   /*************************************************************
-    * Reuse of existing connection is not allowed when
-@@ -2458,11 +2503,12 @@ static CURLcode url_find_or_create_conn(struct Curl_easy *data)
-       DEBUGF(curl_mfprintf(stderr, "Error: init connection SSL config\n"));
-       goto out;
-     }
--    /* attach it and no longer own it */
--    Curl_attach_connection(data, needle);
--    needle = NULL;
- 
--    result = Curl_cpool_add(data, data->conn);
-+    /* Add needle to conn pool, which assigns the connection id.
-+     * Attach regardless of result, for correct handling. */
-+    result = Curl_cpool_add(data, needle);
-+    Curl_attach_connection(data, needle, TRUE);
-+    needle = NULL;
-     if(result)
-       goto out;
- 
-@@ -2573,7 +2619,7 @@ out:
-     /* We are not allowed to return failure with memory left allocated in the
-        connectdata struct, free those here */
-     Curl_detach_connection(data);
--    Curl_conn_terminate(data, conn, TRUE);
-+    Curl_conn_close(data, conn, TRUE);
-   }
- 
-   return result;
-@@ -2646,6 +2692,31 @@ void *Curl_conn_meta_get(struct connectdata *conn, const char *key)
-   return Curl_hash_pick(&conn->meta_hash, CURL_UNCONST(key), strlen(key) + 1);
- }
- 
-+struct Curl_easy *Curl_get_admin(struct Curl_easy *data)
-+{
-+  struct Curl_easy *admin;
-+
-+  if(!data->mid) /* already an admin handle */
-+    admin = data;
-+  else if(data->multi)
-+    admin = data->multi->admin;
-+  else if(data->multi_easy)
-+    admin = data->multi_easy->admin;
-+  else {
-+    DEBUGASSERT(0); /* we do not want this. does it happen? */
-+    admin = data;
-+  }
-+  if(admin != data) {
-+    admin->set.conn_max_idle_ms = data->set.conn_max_idle_ms;
-+    admin->set.conn_max_age_ms = data->set.conn_max_age_ms;
-+    admin->set.upkeep_interval_ms = data->set.upkeep_interval_ms;
-+    admin->set.timeout = data->set.timeout;
-+    admin->set.server_response_timeout = data->set.server_response_timeout;
-+    admin->set.no_signal = data->set.no_signal;
-+  }
-+  return admin;
-+}
-+
- CURLcode Curl_1st_fatal(CURLcode r1, CURLcode r2)
- {
-   if(r1 && (r1 != CURLE_AGAIN))
-diff --git a/lib/url.h b/lib/url.h
-index ebbe9d53c4..767bd7551a 100644
---- a/lib/url.h
-+++ b/lib/url.h
-@@ -67,6 +67,12 @@ CURLcode Curl_conn_meta_set(struct connectdata *conn, const char *key,
- void Curl_conn_meta_remove(struct connectdata *conn, const char *key);
- void *Curl_conn_meta_get(struct connectdata *conn, const char *key);
- 
-+/* Get an admin handle for internal operations from the given
-+ * easy handle, if possible. The admin handle inherits certain
-+ * properties from `data`. If no admin handle is available (not multi
-+ * or share attached), the easy handle itself is returned. */
-+struct Curl_easy *Curl_get_admin(struct Curl_easy *data);
-+
- #define CURL_DEFAULT_PROXY_PORT 1080 /* default proxy port unless specified */
- #define CURL_DEFAULT_HTTPS_PROXY_PORT 443 /* default https proxy port unless
-                                              specified */
-diff --git a/lib/urldata.h b/lib/urldata.h
-index d4d336d8db..1905994f0b 100644
---- a/lib/urldata.h
-+++ b/lib/urldata.h
-@@ -305,6 +305,7 @@ struct connectdata {
-   char *options; /* options string, allocated */
-   struct curltime created; /* creation time */
-   struct curltime lastused; /* when returned to the connection pool as idle */
-+  struct curltime lastchecked; /* when last checked alive status */
- 
-   /* A connection can have one or two sockets and connection filters.
-    * The protocol using the 2nd one is FTP for CONTROL+DATA sockets */
-@@ -573,9 +574,7 @@ struct UrlState {
-   /* buffers to store authentication data in, as parsed from input options */
-   struct curltime keeps_speed; /* for the progress meter really */
- 
--  curl_off_t lastconnect_id; /* The last connection, -1 if undefined */
--  curl_off_t recent_conn_id; /* The most recent connection used, might no
--                              * longer exist */
-+  curl_off_t lastconnect_id; /* The last assigned connection or -1 */
-   struct dynbuf headerb; /* buffer to store headers in */
- #ifndef CURL_DISABLE_HSTS
-   struct curl_slist *hstslist; /* list of HSTS files set by
-diff --git a/tests/data/test1554 b/tests/data/test1554
-index fa071b09b2..545acc5aaa 100644
---- a/tests/data/test1554
-+++ b/tests/data/test1554
-@@ -30,6 +30,8 @@
- [- Mutex unlock CONNECT
- -] Mutex lock CONNECT
- [- Mutex unlock CONNECT
-+-] Mutex lock CONNECT
-+[- Mutex unlock CONNECT
- run 1: foobar and so on fun!
- -] Mutex lock CONNECT
- [- Mutex unlock CONNECT
-@@ -45,6 +47,8 @@
- [- Mutex unlock CONNECT
- -] Mutex lock CONNECT
- [- Mutex unlock CONNECT
-+-] Mutex lock CONNECT
-+[- Mutex unlock CONNECT
- run 1: foobar and so on fun!
- -] Mutex lock CONNECT
- [- Mutex unlock CONNECT
-@@ -60,6 +64,8 @@
- [- Mutex unlock CONNECT
- -] Mutex lock CONNECT
- [- Mutex unlock CONNECT
-+-] Mutex lock CONNECT
-+[- Mutex unlock CONNECT
- run 1: foobar and so on fun!
- -] Mutex lock CONNECT
- [- Mutex unlock CONNECT
-@@ -69,6 +75,8 @@
- [- Mutex unlock SHARE
- -] Mutex lock SHARE
- [- Mutex unlock SHARE
-+-] Mutex lock CONNECT
-+[- Mutex unlock CONNECT
- </datacheck>
- </reply>
- 
--- 
-2.55.0

diff --git a/0003-http2-make-server-push-transfers-inherit-share-from-.patch b/0003-http2-make-server-push-transfers-inherit-share-from-.patch
new file mode 100644
index 0000000..1252500
--- /dev/null
+++ b/0003-http2-make-server-push-transfers-inherit-share-from-.patch
@@ -0,0 +1,34 @@
+From 8a5812e074c527dbfc9fe0821d0cf0b9bb5d3001 Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Wed, 5 Aug 2026 10:02:53 +0200
+Subject: [PATCH] http2: make server push transfers inherit share from parent
+
+Reported-by: Stephan Zeisberg
+Closes #22488
+
+(cherry picked from commit 90325ff0444cbdff368bda5d26d6405a0bb6ee43)
+---
+ lib/http2.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/lib/http2.c b/lib/http2.c
+index a820439ef4..a0c147cdc1 100644
+--- a/lib/http2.c
++++ b/lib/http2.c
+@@ -46,6 +46,7 @@
+ #include "bufref.h"
+ #include "curlx/dynbuf.h"
+ #include "headers.h"
++#include "curl_share.h"
+ 
+ #if NGHTTP2_VERSION_NUM < 0x010f00
+ #error "nghttp2 1.15.0 or greater required"
+@@ -704,6 +705,8 @@ static struct Curl_easy *h2_duphandle(struct Curl_cfilter *cf,
+     struct h2_stream_ctx *second_stream;
+     http2_data_setup(cf, second, &second_stream);
+     second->state.priority.weight = data->state.priority.weight;
++    if(data->share)
++      (void)Curl_share_easy_link(second, data->share);
+   }
+   return second;
+ }

diff --git a/0004-connections-use-admin-handles-only-for-maintenance.patch b/0004-connections-use-admin-handles-only-for-maintenance.patch
new file mode 100644
index 0000000..ad8b00a
--- /dev/null
+++ b/0004-connections-use-admin-handles-only-for-maintenance.patch
@@ -0,0 +1,2157 @@
+From 1ebca9f8658ebbf5fe352d10acb61e602f4acc77 Mon Sep 17 00:00:00 2001
+From: Stefan Eissing <stefan@eissing.org>
+Date: Thu, 13 Aug 2026 13:23:53 +0200
+Subject: [PATCH] connections: use admin handles only for maintenance
+
+Maintenance tasks like connection upkeep, liveliness checks and cache
+eviction must only run on an admin handle, not the application transfer
+from the calling context.
+
+Then application transfers will get only attached to the connections
+they actually work on. This makes `data->state.recent_conn_id`
+meaningful for checks if a subsequent address is finding the previous
+connection again.
+
+One thing led to another:
+- add Curl_get_admin(data), to obtain an admin handle for
+  an application handle, inheriting some properties for
+  connection operation.
+- rename `Curl_easy *data` parameter to `Curl_easy *admin`
+  where only admin handles should be passed. Add DEBUGASSERTs
+  in the called function.
+- rename `Curl_conn_terminate()` to `Curl_conn_close()`
+  because this makes connections enter the shutdown close
+  where possible.
+- rename `Curl_cshutdn_terminate()` to `Curl_conn_terminate()`
+  since this definitely kills the connection and does not
+  involve a `cshutdn` instance.
+- add Curl_share_lock_share(), Curl_share_unlock_share()
+  so it possible to operate on a share without the passed
+  easy handle having the share set.
+  This catches a case where a shared needed to be locked
+  but was not before. Adjust test1554 results.
+
+Fixes #22567
+Reported-by: cybertron10 on github
+Closes #22572
+
+(cherry picked from commit 7103a93b05bc69ea98ed9d05d02fa9eeba533f2f)
+---
+ lib/conncache.c     | 411 +++++++++++++++++++++++++++++---------------
+ lib/conncache.h     |  31 ++--
+ lib/cshutdn.c       | 176 +++++++++----------
+ lib/cshutdn.h       |  29 ++--
+ lib/curl_share.c    |  27 ++-
+ lib/curl_share.h    |   8 +
+ lib/curl_trc.c      |   3 +-
+ lib/easy.c          |  11 +-
+ lib/getinfo.c       |   3 +-
+ lib/multi.c         |  59 ++++---
+ lib/multiif.h       |   3 +-
+ lib/url.c           | 157 ++++++++++++-----
+ lib/url.h           |   6 +
+ lib/urldata.h       |   5 +-
+ tests/data/test1554 |   8 +
+ 15 files changed, 591 insertions(+), 346 deletions(-)
+
+diff --git a/lib/conncache.c b/lib/conncache.c
+index 5ba2368622..82bea4db45 100644
+--- a/lib/conncache.c
++++ b/lib/conncache.c
+@@ -42,7 +42,7 @@
+   do {                                                                  \
+     if(c) {                                                             \
+       if(CURL_SHARE_KEEP_CONNECT((c)->share))                           \
+-        Curl_share_lock((d), CURL_LOCK_DATA_CONNECT,                    \
++        Curl_share_lock_share((c)->share, (d), CURL_LOCK_DATA_CONNECT,  \
+                         CURL_LOCK_ACCESS_SINGLE);                       \
+       DEBUGASSERT(!(c)->locked);                                        \
+       (c)->locked = TRUE;                                               \
+@@ -55,7 +55,7 @@
+       DEBUGASSERT((c)->locked);                                         \
+       (c)->locked = FALSE;                                              \
+       if(CURL_SHARE_KEEP_CONNECT((c)->share))                           \
+-        Curl_share_unlock((d), CURL_LOCK_DATA_CONNECT);                 \
++        Curl_share_unlock_share((c)->share, (d), CURL_LOCK_DATA_CONNECT); \
+     }                                                                   \
+   } while(0)
+ 
+@@ -111,16 +111,12 @@ static void cpool_bundle_free_entry(void *freethis)
+ }
+ 
+ void Curl_cpool_init(struct cpool *cpool,
+-                     struct Curl_easy *idata,
+                      struct Curl_share *share,
+                      size_t size)
+ {
+   Curl_hash_init(&cpool->dest2bundle, size, Curl_hash_str,
+                  curlx_str_key_compare, cpool_bundle_free_entry);
+ 
+-  DEBUGASSERT(idata);
+-
+-  cpool->idata = idata;
+   cpool->share = share;
+   cpool->initialized = TRUE;
+ }
+@@ -186,6 +182,8 @@ static void cpool_discard_conn(struct cpool *cpool,
+                                struct connectdata *conn,
+                                bool aborted)
+ {
++  struct cshutdn *cshutdn;
++  struct Curl_easy *admin;
+   bool done = FALSE;
+ 
+   DEBUGASSERT(data);
+@@ -193,12 +191,13 @@ static void cpool_discard_conn(struct cpool *cpool,
+   DEBUGASSERT(cpool);
+   DEBUGASSERT(!conn->bits.in_cpool);
+ 
++  admin = Curl_get_admin(data);
+   /*
+    * If this connection is not marked to force-close, leave it open if there
+    * are other users of it
+    */
+   if(CONN_INUSE(conn) && !aborted) {
+-    CURL_TRC_M(data, "[CPOOL] not discarding #%" FMT_OFF_T
++    CURL_TRC_M(admin, "[CPOOL] not discarding #%" FMT_OFF_T
+                " still in use by %u transfers", conn->connection_id,
+                conn->attached_xfers);
+     return;
+@@ -219,35 +218,36 @@ static void cpool_discard_conn(struct cpool *cpool,
+     done = TRUE;
+   if(!done) {
+     /* Attempt to shutdown the connection right away. */
+-    Curl_cshutdn_run_once(cpool->idata, conn, &done);
++    Curl_conn_shutdown_once(admin, conn, &done);
+   }
+ 
+-  if(done || !data->multi)
+-    Curl_cshutdn_terminate(cpool->idata, conn, FALSE);
++  cshutdn = Curl_cshutdn_get(data);
++  if(done || !cshutdn)
++    Curl_conn_terminate(admin, conn, FALSE);
+   else
+-    Curl_cshutdn_add(&data->multi->cshutdn, conn, cpool->num_conn);
++    Curl_cshutdn_add(cshutdn, conn, cpool->num_conn);
+ }
+ 
+-void Curl_cpool_destroy(struct cpool *cpool)
++void Curl_cpool_destroy(struct cpool *cpool, struct Curl_easy *admin)
+ {
+-  if(cpool && cpool->initialized && cpool->idata) {
++  if(cpool && cpool->initialized && admin) {
+     struct connectdata *conn;
+     struct Curl_sigpipe_ctx pipe_ctx;
+ 
+-    CURL_TRC_M(cpool->idata, "%s[CPOOL] destroy, %zu connections",
++    CURL_TRC_M(admin, "%s[CPOOL] destroy, %zu connections",
+                cpool->share ? "[SHARE] " : "", cpool->num_conn);
+     /* Move all connections to the shutdown list */
+     sigpipe_init(&pipe_ctx);
+-    CPOOL_LOCK(cpool, cpool->idata);
++    CPOOL_LOCK(cpool, admin);
+     conn = cpool_get_first(cpool);
+     if(conn)
+-      sigpipe_apply(cpool->idata, &pipe_ctx);
++      sigpipe_apply(admin, &pipe_ctx);
+     while(conn) {
+       cpool_remove_conn(cpool, conn);
+-      cpool_discard_conn(cpool, cpool->idata, conn, FALSE);
++      cpool_discard_conn(cpool, admin, conn, FALSE);
+       conn = cpool_get_first(cpool);
+     }
+-    CPOOL_UNLOCK(cpool, cpool->idata);
++    CPOOL_UNLOCK(cpool, admin);
+     sigpipe_restore(&pipe_ctx);
+     Curl_hash_destroy(&cpool->dest2bundle);
+   }
+@@ -255,17 +255,22 @@ void Curl_cpool_destroy(struct cpool *cpool)
+ 
+ static struct cpool *cpool_get_instance(struct Curl_easy *data)
+ {
+-  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;
+-  }
++  /* admin handles do not necessarily find the correct pool */
++  DEBUGASSERT(data->mid);
++  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;
+   return NULL;
+ }
+ 
++struct cpool *Curl_cpool_get_instance(struct Curl_easy *data)
++{
++  return cpool_get_instance(data);
++}
++
+ void Curl_cpool_xfer_init(struct Curl_easy *data)
+ {
+   struct cpool *cpool = cpool_get_instance(data);
+@@ -367,10 +372,89 @@ static struct connectdata *cpool_get_oldest_idle(struct cpool *cpool,
+   return oldest_idle;
+ }
+ 
++static void cpool_conn_close(struct cpool *cpool,
++                             struct Curl_easy *data,
++                             struct connectdata *conn,
++                             bool aborted)
++{
++  struct Curl_easy *admin;
++  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, "conn terminate when inuse: %u", conn->attached_xfers));
++    return;
++  }
++
++  /* This method may be called while we are under lock, e.g. from a
++   * user callback in find. */
++  admin = Curl_get_admin(data);
++  do_lock = !CPOOL_IS_LOCKED(cpool);
++  if(do_lock)
++    CPOOL_LOCK(cpool, admin);
++
++  if(conn->bits.in_cpool) {
++    cpool_remove_conn(cpool, conn);
++    DEBUGASSERT(!conn->bits.in_cpool);
++  }
++
++  /* treat the connection as aborted in CONNECT_ONLY situations,
++   * so no graceful shutdown is attempted. */
++  if(conn->bits.connect_only)
++    aborted = TRUE;
++
++  if(data->multi) {
++    /* Add it to the multi's cpool for shutdown handling */
++    infof(data, "%s connection #%" FMT_OFF_T,
++          aborted ? "closing" : "shutting down", conn->connection_id);
++    cpool_discard_conn(&data->multi->cpool, data, conn, aborted);
++  }
++  else {
++    /* No multi available, terminate */
++    infof(data, "closing connection #%" FMT_OFF_T, conn->connection_id);
++    Curl_conn_terminate(admin, conn, !aborted);
++  }
++
++  if(do_lock)
++    CPOOL_UNLOCK(cpool, admin);
++}
++
++void Curl_conn_close(struct Curl_easy *data,
++                     struct connectdata *conn,
++                     bool aborted)
++{
++  struct cpool *cpool = cpool_get_instance(data);
++  cpool_conn_close(cpool, data, conn, aborted);
++}
++
++/* Evict an idle connection to make room in the pool. A pool owned by
++ * a share has no multi that could perform a controlled shutdown of the
++ * connection; terminate it right away. Otherwise, hand it to the
++ * transfer's multi for shutdown. Expects the pool to be locked. */
++static void cpool_evict_conn(struct cpool *cpool,
++                             struct Curl_easy *admin,
++                             struct connectdata *conn)
++{
++  if(cpool->share) {
++    cpool_remove_conn(cpool, conn);
++    Curl_conn_terminate(admin, conn, TRUE);
++  }
++  else
++    cpool_conn_close(cpool, admin, conn, FALSE);
++}
+ int Curl_cpool_check_limits(struct Curl_easy *data,
+                             struct connectdata *conn)
+ {
+   struct cpool *cpool = cpool_get_instance(data);
++  struct cshutdn *cshutdn = Curl_cshutdn_get(data);
++  struct Curl_easy *admin;
+   struct cpool_bundle *bundle;
+   size_t dest_limit = 0;
+   size_t total_limit = 0;
+@@ -380,25 +464,26 @@ int Curl_cpool_check_limits(struct Curl_easy *data,
+   if(!cpool)
+     return CPOOL_LIMIT_OK;
+ 
+-  if(cpool->idata->multi) {
+-    dest_limit = cpool->idata->multi->max_host_connections;
+-    total_limit = cpool->idata->multi->max_total_connections;
++  if(data->multi) {
++    dest_limit = data->multi->max_host_connections;
++    total_limit = data->multi->max_total_connections;
+   }
+ 
+   if(!dest_limit && !total_limit)
+     return CPOOL_LIMIT_OK;
+ 
+-  CPOOL_LOCK(cpool, cpool->idata);
++  admin = Curl_get_admin(data);
++  CPOOL_LOCK(cpool, admin);
+   if(dest_limit) {
+     size_t live;
+ 
+     bundle = cpool_find_bundle(cpool, conn);
+     live = bundle ? Curl_llist_count(&bundle->conns) : 0;
+-    shutdowns = Curl_cshutdn_dest_count(data, conn->destination);
++    shutdowns = Curl_cshutdn_dest_count(cshutdn, conn->destination);
+     while((live + shutdowns) >= dest_limit) {
+       if(shutdowns) {
+         /* close one connection in shutdown right away, if we can */
+-        if(!Curl_cshutdn_close_oldest(data, conn->destination))
++        if(!Curl_cshutdn_close_oldest(cshutdn, conn->destination))
+           break;
+       }
+       else if(!bundle)
+@@ -412,17 +497,17 @@ int Curl_cpool_check_limits(struct Curl_easy *data,
+         if(!oldest_idle)
+           break;
+         /* disconnect the old conn and continue */
+-        CURL_TRC_M(data, "Discarding connection #%" FMT_OFF_T
++        CURL_TRC_M(admin, "Discarding connection #%" FMT_OFF_T
+                    " from %zu to reach destination limit of %zu",
+                    oldest_idle->connection_id,
+                    Curl_llist_count(&bundle->conns), dest_limit);
+-        Curl_conn_terminate(cpool->idata, oldest_idle, FALSE);
++        cpool_evict_conn(cpool, admin, oldest_idle);
+ 
+         /* in case the bundle was destroyed in disconnect, look it up again */
+         bundle = cpool_find_bundle(cpool, conn);
+         live = bundle ? Curl_llist_count(&bundle->conns) : 0;
+       }
+-      shutdowns = Curl_cshutdn_dest_count(cpool->idata, conn->destination);
++      shutdowns = Curl_cshutdn_dest_count(cshutdn, conn->destination);
+     }
+     if((live + shutdowns) >= dest_limit) {
+       res = CPOOL_LIMIT_DEST;
+@@ -431,11 +516,11 @@ int Curl_cpool_check_limits(struct Curl_easy *data,
+   }
+ 
+   if(total_limit) {
+-    shutdowns = Curl_cshutdn_count(cpool->idata);
++    shutdowns = Curl_cshutdn_count(cshutdn);
+     while((cpool->num_conn + shutdowns) >= total_limit) {
+       if(shutdowns) {
+         /* close one connection in shutdown right away, if we can */
+-        if(!Curl_cshutdn_close_oldest(data, NULL))
++        if(!Curl_cshutdn_close_oldest(cshutdn, NULL))
+           break;
+       }
+       else {
+@@ -444,13 +529,13 @@ int Curl_cpool_check_limits(struct Curl_easy *data,
+         if(!oldest_idle)
+           break;
+         /* disconnect the old conn and continue */
+-        CURL_TRC_M(data, "Discarding connection #%"
++        CURL_TRC_M(admin, "Discarding connection #%"
+                    FMT_OFF_T " from %zu to reach total "
+                    "limit of %zu",
+                    oldest_idle->connection_id, cpool->num_conn, total_limit);
+-        Curl_conn_terminate(cpool->idata, oldest_idle, FALSE);
++        cpool_evict_conn(cpool, admin, oldest_idle);
+       }
+-      shutdowns = Curl_cshutdn_count(cpool->idata);
++      shutdowns = Curl_cshutdn_count(cshutdn);
+     }
+     if((cpool->num_conn + shutdowns) >= total_limit) {
+       res = CPOOL_LIMIT_TOTAL;
+@@ -459,7 +544,7 @@ int Curl_cpool_check_limits(struct Curl_easy *data,
+   }
+ 
+ out:
+-  CPOOL_UNLOCK(cpool, cpool->idata);
++  CPOOL_UNLOCK(cpool, admin);
+   return res;
+ }
+ 
+@@ -512,7 +597,8 @@ out:
+ static bool cpool_foreach(struct Curl_easy *data,
+                           struct cpool *cpool,
+                           void *param,
+-                          int (*func)(struct Curl_easy *data,
++                          int (*func)(struct cpool *cpool,
++                                      struct Curl_easy *data,
+                                       struct connectdata *conn, void *param))
+ {
+   struct Curl_hash_iterator iter;
+@@ -536,7 +622,7 @@ static bool cpool_foreach(struct Curl_easy *data,
+       struct connectdata *conn = Curl_node_elem(curr);
+       curr = Curl_node_next(curr);
+ 
+-      if(func(data, conn, param) == 1) {
++      if(func(cpool, data, conn, param) == 1) {
+         return TRUE;
+       }
+     }
+@@ -556,6 +642,7 @@ bool Curl_cpool_conn_now_idle(struct Curl_easy *data,
+   unsigned int maxconnects;
+   struct connectdata *oldest_idle = NULL;
+   struct cpool *cpool = cpool_get_instance(data);
++  struct Curl_easy *admin;
+   bool kept = TRUE;
+ 
+   if(!data || !data->multi)
+@@ -573,8 +660,10 @@ bool Curl_cpool_conn_now_idle(struct Curl_easy *data,
+   if(cpool && maxconnects) {
+     /* may be called form a callback already under lock */
+     bool do_lock = !CPOOL_IS_LOCKED(cpool);
++
++    admin = Curl_get_admin(data);
+     if(do_lock)
+-      CPOOL_LOCK(cpool, data);
++      CPOOL_LOCK(cpool, admin);
+     if(cpool->num_conn > maxconnects) {
+       infof(data, "Connection pool is full, closing the oldest of %zu/%u",
+             cpool->num_conn, maxconnects);
+@@ -582,11 +671,11 @@ bool Curl_cpool_conn_now_idle(struct Curl_easy *data,
+       oldest_idle = cpool_get_oldest_idle(cpool, Curl_pgrs_now(data));
+       kept = (oldest_idle != conn);
+       if(oldest_idle) {
+-        Curl_conn_terminate(data, oldest_idle, FALSE);
++        cpool_evict_conn(cpool, admin, oldest_idle);
+       }
+     }
+     if(do_lock)
+-      CPOOL_UNLOCK(cpool, data);
++      CPOOL_UNLOCK(cpool, admin);
+   }
+ 
+   return kept;
+@@ -632,78 +721,25 @@ bool Curl_cpool_find(struct Curl_easy *data,
+   return found;
+ }
+ 
+-void Curl_conn_terminate(struct Curl_easy *data,
+-                         struct connectdata *conn,
+-                         bool aborted)
+-{
+-  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, "conn terminate when inuse: %u", conn->attached_xfers));
+-    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, data);
+-
+-  if(conn->bits.in_cpool) {
+-    cpool_remove_conn(cpool, conn);
+-    DEBUGASSERT(!conn->bits.in_cpool);
+-  }
+-
+-  /* treat the connection as aborted in CONNECT_ONLY situations,
+-   * so no graceful shutdown is attempted. */
+-  if(conn->bits.connect_only)
+-    aborted = TRUE;
+-
+-  if(data->multi) {
+-    /* Add it to the multi's cpool for shutdown handling */
+-    infof(data, "%s connection #%" FMT_OFF_T,
+-          aborted ? "closing" : "shutting down", conn->connection_id);
+-    cpool_discard_conn(&data->multi->cpool, data, conn, aborted);
+-  }
+-  else {
+-    /* No multi available, terminate */
+-    infof(data, "closing connection #%" FMT_OFF_T, conn->connection_id);
+-    Curl_cshutdn_terminate(cpool->idata, conn, !aborted);
+-  }
+-
+-  if(do_lock)
+-    CPOOL_UNLOCK(cpool, data);
+-}
+-
+ struct cpool_reaper_ctx {
+-  size_t checked;
+   size_t reaped;
++  struct curltime now;
+ };
+ 
+-static int cpool_reap_dead_cb(struct Curl_easy *data,
++static int cpool_reap_dead_cb(struct cpool *cpool,
++                              struct Curl_easy *admin,
+                               struct connectdata *conn, void *param)
+ {
+   struct cpool_reaper_ctx *reaper = param;
+-  bool terminate = !CONN_INUSE(conn) && conn->bits.no_reuse;
+ 
+-  if(!terminate) {
+-    reaper->checked++;
+-    terminate = Curl_conn_seems_dead(conn, data);
+-  }
+-  if(terminate) {
+-    /* stop the iteration here, pass back the connection that was pruned */
+-    reaper->reaped++;
+-    Curl_conn_terminate(data, conn, FALSE);
+-    return 1;
++  if(!CONN_INUSE(conn)) {
++    if(conn->bits.no_reuse || conn->bits.close ||
++       !Curl_cpool_conn_seems_healthy(conn, admin, &reaper->now)) {
++      /* terminate conn and stop the iteration */
++      reaper->reaped++;
++      cpool_conn_close(cpool, admin, conn, FALSE);
++      return 1;
++    }
+   }
+   return 0; /* continue iteration */
+ }
+@@ -715,46 +751,67 @@ static int cpool_reap_dead_cb(struct Curl_easy *data,
+  *
+  * When called, this transfer has no connection attached.
+  */
+-void Curl_cpool_prune_dead(struct Curl_easy *data)
++void Curl_cpool_prune_dead(struct cpool *cpool,
++                           struct Curl_easy *data)
+ {
+-  struct cpool *cpool = cpool_get_instance(data);
+-  struct cpool_reaper_ctx reaper;
++  struct Curl_easy *admin;
+   timediff_t elapsed;
+ 
+   if(!cpool)
+     return;
+ 
+-  memset(&reaper, 0, sizeof(reaper));
+-  CPOOL_LOCK(cpool, data);
+-  elapsed = curlx_ptimediff_ms(Curl_pgrs_now(data), &cpool->last_cleanup);
++  admin = Curl_get_admin(data);
++  CPOOL_LOCK(cpool, admin);
++  elapsed = curlx_ptimediff_ms(Curl_pgrs_now(admin), &cpool->last_cleanup);
+ 
+   if(elapsed >= 1000L) {
+-    while(cpool_foreach(data, cpool, &reaper, cpool_reap_dead_cb))
++    struct cpool_reaper_ctx reaper;
++
++    memset(&reaper, 0, sizeof(reaper));
++    reaper.now = *Curl_pgrs_now(admin);
++    while(cpool_foreach(admin, cpool, &reaper, cpool_reap_dead_cb))
+       ;
+-    cpool->last_cleanup = *Curl_pgrs_now(data);
++    cpool->last_cleanup = *Curl_pgrs_now(admin);
+   }
+-  CPOOL_UNLOCK(cpool, data);
++  CPOOL_UNLOCK(cpool, admin);
+ }
+ 
+-static int conn_upkeep(struct Curl_easy *data,
++static int conn_upkeep(struct cpool *cpool,
++                       struct Curl_easy *admin,
+                        struct connectdata *conn,
+                        void *param)
+ {
+   (void)param;
+-  Curl_conn_upkeep(data, conn);
++  if(curlx_ptimediff_ms(Curl_pgrs_now(admin), &conn->keepalive) >=
++     admin->set.upkeep_interval_ms) {
++    CURLcode result;
++
++    /* briefly attach for action */
++    Curl_attach_connection(admin, conn, FALSE);
++    result = Curl_conn_keep_alive(admin, conn, FIRSTSOCKET);
++    conn->keepalive = *Curl_pgrs_now(admin);
++    Curl_detach_connection(admin);
++
++    if(result && !CONN_INUSE(conn)) {
++      cpool_conn_close(cpool, admin, conn, FALSE);
++      return 1;
++    }
++  }
+   return 0; /* continue iteration */
+ }
+ 
+ CURLcode Curl_cpool_upkeep(struct Curl_easy *data)
+ {
+   struct cpool *cpool = cpool_get_instance(data);
++  struct Curl_easy *admin = Curl_get_admin(data);
+ 
+   if(!cpool)
+     return CURLE_OK;
+ 
+-  CPOOL_LOCK(cpool, data);
+-  cpool_foreach(data, cpool, NULL, conn_upkeep);
+-  CPOOL_UNLOCK(cpool, data);
++  CPOOL_LOCK(cpool, admin);
++  while(cpool_foreach(admin, cpool, NULL, conn_upkeep))
++    ;
++  CPOOL_UNLOCK(cpool, admin);
+   return CURLE_OK;
+ }
+ 
+@@ -763,10 +820,12 @@ struct cpool_find_ctx {
+   struct connectdata *conn;
+ };
+ 
+-static int cpool_find_conn(struct Curl_easy *data,
++static int cpool_find_conn(struct cpool *cpool,
++                           struct Curl_easy *data,
+                            struct connectdata *conn, void *param)
+ {
+   struct cpool_find_ctx *fctx = param;
++  (void)cpool;
+   (void)data;
+   if(conn->connection_id == fctx->id) {
+     fctx->conn = conn;
+@@ -797,10 +856,12 @@ struct cpool_do_conn_ctx {
+   void *cbdata;
+ };
+ 
+-static int cpool_do_conn(struct Curl_easy *data,
++static int cpool_do_conn(struct cpool *cpool,
++                         struct Curl_easy *data,
+                          struct connectdata *conn, void *param)
+ {
+   struct cpool_do_conn_ctx *dctx = param;
++  (void)cpool;
+ 
+   if(conn->connection_id == dctx->id) {
+     dctx->cb(conn, data, dctx->cbdata);
+@@ -839,39 +900,113 @@ void Curl_cpool_do_locked(struct Curl_easy *data,
+     cb(conn, data, cbdata);
+ }
+ 
+-static int cpool_mark_stale(struct Curl_easy *data,
++static int cpool_mark_stale(struct cpool *cpool,
++                            struct Curl_easy *admin,
+                             struct connectdata *conn, void *param)
+ {
+-  (void)data;
++  (void)cpool;
++  (void)admin;
+   (void)param;
+   conn->bits.no_reuse = TRUE;
+   return 0;
+ }
+ 
+-static int cpool_reap_no_reuse(struct Curl_easy *data,
++static int cpool_reap_no_reuse(struct cpool *cpool,
++                               struct Curl_easy *admin,
+                                struct connectdata *conn, void *param)
+ {
+   (void)param;
+   if(!CONN_INUSE(conn) && conn->bits.no_reuse) {
+-    Curl_conn_terminate(data, conn, FALSE);
++    cpool_conn_close(cpool, admin, conn, FALSE);
+     return 1;
+   }
+   return 0; /* continue iteration */
+ }
+ 
+-void Curl_cpool_nw_changed(struct Curl_easy *data)
++void Curl_cpool_nw_changed(struct cpool *cpool, struct Curl_easy *admin)
+ {
+-  struct cpool *cpool = cpool_get_instance(data);
+-
+-  if(cpool) {
+-    CPOOL_LOCK(cpool, data);
+-    cpool_foreach(data, cpool, NULL, cpool_mark_stale);
+-    while(cpool_foreach(data, cpool, NULL, cpool_reap_no_reuse))
++  if(cpool && admin) {
++    CPOOL_LOCK(cpool, admin);
++    cpool_foreach(admin, cpool, NULL, cpool_mark_stale);
++    while(cpool_foreach(admin, cpool, NULL, cpool_reap_no_reuse))
+       ;
+-    CPOOL_UNLOCK(cpool, data);
++    CPOOL_UNLOCK(cpool, admin);
+   }
+ }
+ 
++/* A connection has to have been idle for less than 'conn_max_idle_ms'
++   (the success rate is too low after this), or created less than
++   'conn_max_age_ms' ago, to be subject for reuse. */
++static bool cpool_conn_maxage(struct Curl_easy *data,
++                              struct connectdata *conn,
++                              const struct curltime *pnow)
++{
++  timediff_t age_ms;
++
++  if(data->set.conn_max_idle_ms) {
++    age_ms = curlx_ptimediff_ms(pnow, &conn->lastused);
++    if(age_ms > data->set.conn_max_idle_ms) {
++      infof(data, "Too old connection (%" FMT_TIMEDIFF_T
++            " ms idle, max idle is %" FMT_TIMEDIFF_T " ms), disconnect it",
++            age_ms, data->set.conn_max_idle_ms);
++      return TRUE;
++    }
++  }
++
++  if(data->set.conn_max_age_ms) {
++    age_ms = curlx_ptimediff_ms(pnow, &conn->created);
++    if(age_ms > data->set.conn_max_age_ms) {
++      infof(data,
++            "Too old connection (created %" FMT_TIMEDIFF_T
++            " ms ago, max lifetime is %" FMT_TIMEDIFF_T " ms), disconnect it",
++            age_ms, data->set.conn_max_age_ms);
++      return TRUE;
++    }
++  }
++
++  return FALSE;
++}
++
++bool Curl_cpool_conn_seems_healthy(struct connectdata *conn,
++                                   struct Curl_easy *data,
++                                   const struct curltime *pnow)
++{
++  struct Curl_easy *admin;
++  bool healthy = TRUE;
++
++  DEBUGASSERT(!data->conn);
++  if(!CONN_INUSE(conn) && cpool_conn_maxage(data, conn, pnow)) /* too old? */
++    return FALSE;
++  if(curlx_ptimediff_ms(pnow, &conn->lastchecked) < 1000)
++    return TRUE;
++
++  admin = Curl_get_admin(data);
++  if(conn->scheme->run->connection_is_dead) {
++    Curl_attach_connection(admin, conn, FALSE);
++    healthy = !conn->scheme->run->connection_is_dead(admin, conn);
++    Curl_detach_connection(admin);
++  }
++  else {
++    bool input_pending = FALSE;
++
++    Curl_attach_connection(admin, conn, FALSE);
++    healthy = Curl_conn_is_alive(admin, conn, &input_pending);
++    Curl_detach_connection(admin);
++    if(healthy && input_pending &&
++       !CONN_INUSE(conn) && !Curl_conn_is_multiplex(conn, FIRSTSOCKET)) {
++      /* Non-multiplexed connections without attached transfers should
++       * not have input pending. The input might be a TLS Notify Close,
++       * for all we know. */
++      DEBUGF(infof(data, "connection has no transfer but input, not healthy"));
++      healthy = FALSE;
++    }
++  }
++
++  if(healthy)
++    conn->lastchecked = *pnow;
++  return healthy;
++}
++
+ #if 0
+ /* Useful for debugging the connection pool */
+ void Curl_cpool_print(struct cpool *cpool)
+diff --git a/lib/conncache.h b/lib/conncache.h
+index 71940d724c..97832ac250 100644
+--- a/lib/conncache.h
++++ b/lib/conncache.h
+@@ -34,7 +34,7 @@ struct Curl_multi;
+ struct Curl_share;
+ 
+ /**
+- * Terminate the connection, e.g. close and destroy.
++ * Close and destroy the connection.
+  * If the connection is in a cpool, remove it.
+  * If a `cshutdn` is available (e.g. data has a multi handle),
+  * pass the connection to that for controlled shutdown.
+@@ -42,9 +42,9 @@ struct Curl_share;
+  * Takes ownership of `conn`.
+  * `data` should not be attached to a connection.
+  */
+-void Curl_conn_terminate(struct Curl_easy *data,
+-                         struct connectdata *conn,
+-                         bool aborted);
++void Curl_conn_close(struct Curl_easy *data,
++                     struct connectdata *conn,
++                     bool aborted);
+ 
+ struct cpool {
+   /* the pooled connections, bundled per destination */
+@@ -53,22 +53,24 @@ struct cpool {
+   curl_off_t next_connection_id;
+   curl_off_t next_easy_id;
+   struct curltime last_cleanup;
+-  struct Curl_easy *idata; /* internal handle for maintenance */
+   struct Curl_share *share; /* != NULL if pool belongs to share */
+   BIT(locked);
+   BIT(initialized);
+ };
+ 
++/* Get connection pool instance for data or NULL if none exists */
++struct cpool *Curl_cpool_get_instance(struct Curl_easy *data);
++
+ /* Init the pool, pass multi only if pool is owned by it.
+  * Cannot fail.
+  */
+ void Curl_cpool_init(struct cpool *cpool,
+-                     struct Curl_easy *idata,
+                      struct Curl_share *share,
+                      size_t size);
+ 
+ /* Destroy all connections and free all members */
+-void Curl_cpool_destroy(struct cpool *cpool);
++void Curl_cpool_destroy(struct cpool *cpool,
++                        struct Curl_easy *admin);
+ 
+ /* Init the transfer to be used within its connection pool.
+  * Assigns `data->id`. */
+@@ -126,13 +128,12 @@ bool Curl_cpool_conn_now_idle(struct Curl_easy *data,
+                               struct connectdata *conn);
+ 
+ /**
+- * This function scans the data's connection pool for half-open/dead
++ * Scans the 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);
++void Curl_cpool_prune_dead(struct cpool *cpool,
++                           struct Curl_easy *data);
+ 
+ /**
+  * Perform upkeep actions on connections in the transfer's pool.
+@@ -162,6 +163,12 @@ void Curl_cpool_do_locked(struct Curl_easy *data,
+                           Curl_cpool_conn_do_cb *cb, void *cbdata);
+ 
+ /* Close all unused connections, prevent reuse of existing ones. */
+-void Curl_cpool_nw_changed(struct Curl_easy *data);
++void Curl_cpool_nw_changed(struct cpool *cpool, struct Curl_easy *admin);
++
++/* Return TRUE iff the given connection is considered healthy, e.g.
++ * usable for more transfers. */
++bool Curl_cpool_conn_seems_healthy(struct connectdata *conn,
++                                   struct Curl_easy *data,
++                                   const struct curltime *pnow);
+ 
+ #endif /* HEADER_CURL_CONNCACHE_H */
+diff --git a/lib/cshutdn.c b/lib/cshutdn.c
+index cc77e401fd..dfd3c904ce 100644
+--- a/lib/cshutdn.c
++++ b/lib/cshutdn.c
+@@ -38,6 +38,13 @@
+ #include "curlx/strparse.h"
+ 
+ 
++struct cshutdn *Curl_cshutdn_get(struct Curl_easy *data)
++{
++  if(data && data->multi)
++    return &data->multi->cshutdn;
++  return NULL;
++}
++
+ static void cshutdn_run_conn_handler(struct Curl_easy *data,
+                                      struct connectdata *conn)
+ {
+@@ -107,22 +114,22 @@ static void cshutdn_run_once(struct Curl_easy *data,
+     conn->bits.shutdown_filters = TRUE;
+ }
+ 
+-void Curl_cshutdn_run_once(struct Curl_easy *data,
++void Curl_conn_shutdown_once(struct Curl_easy *admin,
+                            struct connectdata *conn,
+                            bool *done)
+ {
+-  DEBUGASSERT(!data->conn);
+-  Curl_attach_connection(data, conn);
+-  cshutdn_run_once(data, conn, done);
+-  CURL_TRC_M(data, "[SHUTDOWN] shutdown, done=%d", *done);
+-  Curl_detach_connection(data);
++  DEBUGASSERT(!admin->conn);
++  DEBUGASSERT(!admin->mid);
++  Curl_attach_connection(admin, conn, FALSE);
++  cshutdn_run_once(admin, conn, done);
++  CURL_TRC_M(admin, "[SHUTDOWN] shutdown, done=%d", *done);
++  Curl_detach_connection(admin);
+ }
+ 
+-void Curl_cshutdn_terminate(struct Curl_easy *data,
+-                            struct connectdata *conn,
+-                            bool do_shutdown)
++void Curl_conn_terminate(struct Curl_easy *admin,
++                         struct connectdata *conn,
++                         bool do_shutdown)
+ {
+-  struct Curl_easy *admin = data;
+   bool done;
+ 
+   /* there must be a connection to close */
+@@ -130,16 +137,10 @@ void Curl_cshutdn_terminate(struct Curl_easy *data,
+   /* it must be removed from the connection pool */
+   DEBUGASSERT(!conn->bits.in_cpool);
+   /* the transfer must be detached from the connection */
+-  DEBUGASSERT(data && !data->conn);
++  DEBUGASSERT(admin && !admin->conn);
++  DEBUGASSERT(!admin->mid);
+ 
+-  /* If we can obtain an internal admin handle, use that to attach
+-   * and terminate the connection. Some protocol will try to mess with
+-   * `data` during shutdown and we do not want that with a `data` from
+-   * the application. */
+-  if(data->multi && data->multi->admin)
+-    admin = data->multi->admin;
+-
+-  Curl_attach_connection(admin, conn);
++  Curl_attach_connection(admin, conn, FALSE);
+ 
+   cshutdn_run_conn_handler(admin, conn);
+   if(do_shutdown) {
+@@ -154,18 +155,17 @@ void Curl_cshutdn_terminate(struct Curl_easy *data,
+   Curl_conn_cf_discard_all(admin, conn, FIRSTSOCKET);
+   Curl_detach_connection(admin);
+ 
+-  if(data->multi)
+-    Curl_multi_ev_conn_done(data->multi, data, conn);
++  if(admin->multi)
++    Curl_multi_ev_conn_done(admin->multi, admin, conn);
+   Curl_conn_free(admin, conn);
+ 
+-  if(data->multi) {
+-    CURL_TRC_M(data, "[SHUTDOWN] trigger multi connchanged");
+-    Curl_multi_connchanged(data->multi);
++  if(admin->multi) {
++    CURL_TRC_M(admin, "[SHUTDOWN] trigger multi connchanged");
++    Curl_multi_connchanged(admin->multi);
+   }
+ }
+ 
+ static bool cshutdn_destroy_oldest(struct cshutdn *cshutdn,
+-                                   struct Curl_easy *data,
+                                    const char *destination)
+ {
+   struct Curl_llist_node *e;
+@@ -184,20 +184,19 @@ static bool cshutdn_destroy_oldest(struct cshutdn *cshutdn,
+     conn = Curl_node_elem(e);
+     Curl_node_remove(e);
+     sigpipe_init(&sigpipe_ctx);
+-    sigpipe_apply(data, &sigpipe_ctx);
+-    Curl_cshutdn_terminate(data, conn, FALSE);
++    sigpipe_apply(cshutdn->multi->admin, &sigpipe_ctx);
++    Curl_conn_terminate(cshutdn->multi->admin, conn, FALSE);
+     sigpipe_restore(&sigpipe_ctx);
+     return TRUE;
+   }
+   return FALSE;
+ }
+ 
+-bool Curl_cshutdn_close_oldest(struct Curl_easy *data,
++bool Curl_cshutdn_close_oldest(struct cshutdn *cshutdn,
+                                const char *destination)
+ {
+-  if(data && data->multi) {
+-    struct cshutdn *csd = &data->multi->cshutdn;
+-    return cshutdn_destroy_oldest(csd, data, destination);
++  if(cshutdn) {
++    return cshutdn_destroy_oldest(cshutdn, destination);
+   }
+   return FALSE;
+ }
+@@ -205,7 +204,6 @@ bool Curl_cshutdn_close_oldest(struct Curl_easy *data,
+ #define NUM_POLLS_ON_STACK 10
+ 
+ static CURLcode cshutdn_wait(struct cshutdn *cshutdn,
+-                             struct Curl_easy *data,
+                              int timeout_ms)
+ {
+   struct pollfd a_few_on_stack[NUM_POLLS_ON_STACK];
+@@ -214,7 +212,7 @@ static CURLcode cshutdn_wait(struct cshutdn *cshutdn,
+ 
+   Curl_pollfds_init(&cpfds, a_few_on_stack, NUM_POLLS_ON_STACK);
+ 
+-  result = Curl_cshutdn_add_pollfds(cshutdn, data, &cpfds);
++  result = Curl_cshutdn_add_pollfds(cshutdn, &cpfds);
+   if(result)
+     goto out;
+ 
+@@ -226,11 +224,11 @@ out:
+ }
+ 
+ static void cshutdn_perform(struct cshutdn *cshutdn,
+-                            struct Curl_easy *data,
+                             struct Curl_sigpipe_ctx *sigpipe_ctx)
+ {
+   struct Curl_llist_node *e = Curl_llist_head(&cshutdn->list);
+   struct Curl_llist_node *enext;
++  struct Curl_easy *admin = cshutdn->multi->admin;
+   struct connectdata *conn;
+   timediff_t next_expire_ms = 0, ms;
+   bool done;
+@@ -238,67 +236,64 @@ static void cshutdn_perform(struct cshutdn *cshutdn,
+   if(!e)
+     return;
+ 
+-  CURL_TRC_M(data, "[SHUTDOWN] perform on %zu connections",
++  CURL_TRC_M(admin, "[SHUTDOWN] perform on %zu connections",
+              Curl_llist_count(&cshutdn->list));
+-  sigpipe_apply(data, sigpipe_ctx);
++  sigpipe_apply(admin, sigpipe_ctx);
+   while(e) {
+     enext = Curl_node_next(e);
+     conn = Curl_node_elem(e);
+-    Curl_cshutdn_run_once(data, conn, &done);
++    Curl_conn_shutdown_once(admin, conn, &done);
+     if(done) {
+       Curl_node_remove(e);
+-      Curl_cshutdn_terminate(data, conn, FALSE);
++      Curl_conn_terminate(admin, conn, FALSE);
+     }
+     else {
+       /* idata has one timer list, but maybe more than one connection.
+        * Set EXPIRE_SHUTDOWN to the smallest time left for all. */
+-      ms = Curl_conn_shutdown_timeleft(data, conn);
+-      if(ms && ms < next_expire_ms)
++      ms = Curl_conn_shutdown_timeleft(admin, conn);
++      if(ms && (!next_expire_ms || (ms < next_expire_ms)))
+         next_expire_ms = ms;
+     }
+     e = enext;
+   }
+ 
+   if(next_expire_ms)
+-    Curl_expire_ex(data, next_expire_ms, EXPIRE_SHUTDOWN);
++    Curl_expire_ex(admin, next_expire_ms, EXPIRE_SHUTDOWN);
+ }
+ 
+ static void cshutdn_terminate_all(struct cshutdn *cshutdn,
+-                                  struct Curl_easy *data,
+                                   int timeout_ms)
+ {
+-  struct curltime started = *Curl_pgrs_now(data);
++  struct Curl_easy *admin = cshutdn->multi->admin;
++  struct curltime started = *Curl_pgrs_now(admin);
+   struct Curl_llist_node *e;
+   struct Curl_sigpipe_ctx sigpipe_ctx;
+ 
+-  DEBUGASSERT(cshutdn);
+-  DEBUGASSERT(data);
+-
+-  CURL_TRC_M(data, "[SHUTDOWN] shutdown all");
++  CURL_TRC_M(admin, "[SHUTDOWN] shutdown all");
+   sigpipe_init(&sigpipe_ctx);
+ 
+   while(Curl_llist_head(&cshutdn->list)) {
+     timediff_t spent_ms;
+     int remain_ms;
+ 
+-    cshutdn_perform(cshutdn, data, &sigpipe_ctx);
++    cshutdn_perform(cshutdn, &sigpipe_ctx);
+ 
+     if(!Curl_llist_head(&cshutdn->list)) {
+-      CURL_TRC_M(data, "[SHUTDOWN] shutdown finished cleanly");
++      CURL_TRC_M(admin, "[SHUTDOWN] shutdown finished cleanly");
+       break;
+     }
+ 
+     /* wait for activity, timeout or "nothing" */
+-    spent_ms = curlx_ptimediff_ms(Curl_pgrs_now(data), &started);
++    spent_ms = curlx_ptimediff_ms(Curl_pgrs_now(admin), &started);
+     if(spent_ms >= (timediff_t)timeout_ms) {
+-      CURL_TRC_M(data, "[SHUTDOWN] shutdown finished, %s",
++      CURL_TRC_M(admin, "[SHUTDOWN] shutdown finished, %s",
+                  (timeout_ms > 0) ? "timeout" : "best effort done");
+       break;
+     }
+ 
+     remain_ms = timeout_ms - (int)spent_ms;
+-    if(cshutdn_wait(cshutdn, data, remain_ms)) {
+-      CURL_TRC_M(data, "[SHUTDOWN] shutdown finished, aborted");
++    if(cshutdn_wait(cshutdn, remain_ms)) {
++      CURL_TRC_M(admin, "[SHUTDOWN] shutdown finished, aborted");
+       break;
+     }
+   }
+@@ -308,7 +303,7 @@ static void cshutdn_terminate_all(struct cshutdn *cshutdn,
+   while(e) {
+     struct connectdata *conn = Curl_node_elem(e);
+     Curl_node_remove(e);
+-    Curl_cshutdn_terminate(data, conn, FALSE);
++    Curl_conn_terminate(admin, conn, FALSE);
+     e = Curl_llist_head(&cshutdn->list);
+   }
+   DEBUGASSERT(!Curl_llist_count(&cshutdn->list));
+@@ -327,12 +322,13 @@ int Curl_cshutdn_init(struct cshutdn *cshutdn,
+ }
+ 
+ void Curl_cshutdn_destroy(struct cshutdn *cshutdn,
+-                          struct Curl_easy *data)
++                          struct Curl_easy *admin)
+ {
+-  if(cshutdn->initialized && data) {
++  if(cshutdn->initialized && admin) {
+     int timeout_ms = 0;
+     /* for testing, run graceful shutdown */
+ #ifdef DEBUGBUILD
++    DEBUGASSERT(!admin->mid);
+     {
+       const char *p = getenv("CURL_GRACEFUL_SHUTDOWN");
+       if(p) {
+@@ -343,29 +339,28 @@ void Curl_cshutdn_destroy(struct cshutdn *cshutdn,
+     }
+ #endif
+ 
+-    CURL_TRC_M(data, "[SHUTDOWN] destroy, %zu connections, timeout=%dms",
++    CURL_TRC_M(admin, "[SHUTDOWN] destroy, %zu connections, timeout=%dms",
+                Curl_llist_count(&cshutdn->list), timeout_ms);
+-    cshutdn_terminate_all(cshutdn, data, timeout_ms);
++    cshutdn_terminate_all(cshutdn, timeout_ms);
+   }
+   cshutdn->multi = NULL;
++  cshutdn->initialized = FALSE;
+ }
+ 
+-size_t Curl_cshutdn_count(struct Curl_easy *data)
++size_t Curl_cshutdn_count(struct cshutdn *cshutdn)
+ {
+-  if(data && data->multi) {
+-    struct cshutdn *csd = &data->multi->cshutdn;
+-    return Curl_llist_count(&csd->list);
++  if(cshutdn) {
++    return Curl_llist_count(&cshutdn->list);
+   }
+   return 0;
+ }
+ 
+-size_t Curl_cshutdn_dest_count(struct Curl_easy *data,
++size_t Curl_cshutdn_dest_count(struct cshutdn *cshutdn,
+                                const char *destination)
+ {
+-  if(data && data->multi) {
+-    struct cshutdn *csd = &data->multi->cshutdn;
++  if(cshutdn) {
+     size_t n = 0;
+-    struct Curl_llist_node *e = Curl_llist_head(&csd->list);
++    struct Curl_llist_node *e = Curl_llist_head(&cshutdn->list);
+     while(e) {
+       struct connectdata *conn = Curl_node_elem(e);
+       if(!strcmp(destination, conn->destination))
+@@ -378,17 +373,17 @@ size_t Curl_cshutdn_dest_count(struct Curl_easy *data,
+ }
+ 
+ static CURLMcode cshutdn_update_ev(struct cshutdn *cshutdn,
+-                                   struct Curl_easy *data,
+                                    struct connectdata *conn)
+ {
++  struct Curl_easy *admin = cshutdn->multi->admin;
+   CURLMcode mresult;
+ 
+   DEBUGASSERT(cshutdn);
+   DEBUGASSERT(cshutdn->multi->socket_cb);
+ 
+-  Curl_attach_connection(data, conn);
+-  mresult = Curl_multi_ev_assess_conn(cshutdn->multi, data, conn);
+-  Curl_detach_connection(data);
++  Curl_attach_connection(admin, conn, FALSE);
++  mresult = Curl_multi_ev_assess_conn(cshutdn->multi, admin, conn);
++  Curl_detach_connection(admin);
+   return mresult;
+ }
+ 
+@@ -396,47 +391,46 @@ void Curl_cshutdn_add(struct cshutdn *cshutdn,
+                       struct connectdata *conn,
+                       size_t conns_in_pool)
+ {
+-  struct Curl_easy *data = cshutdn->multi->admin;
++  struct Curl_easy *admin = cshutdn->multi->admin;
+   size_t max_total = cshutdn->multi->max_total_connections;
+ 
+   /* Add the connection to our shutdown list for non-blocking shutdown
+    * during multi processing. */
+   if(max_total > 0 &&
+      (max_total <= (conns_in_pool + Curl_llist_count(&cshutdn->list)))) {
+-    CURL_TRC_M(data, "[SHUTDOWN] discarding oldest shutdown connection "
++    CURL_TRC_M(admin, "[SHUTDOWN] discarding oldest shutdown connection "
+                "due to connection limit of %zu", max_total);
+-    cshutdn_destroy_oldest(cshutdn, data, NULL);
++    cshutdn_destroy_oldest(cshutdn, NULL);
+   }
+ 
+   if(cshutdn->multi->socket_cb) {
+-    if(cshutdn_update_ev(cshutdn, data, conn)) {
+-      CURL_TRC_M(data, "[SHUTDOWN] update events failed, discarding #%"
++    if(cshutdn_update_ev(cshutdn, conn)) {
++      CURL_TRC_M(admin, "[SHUTDOWN] update events failed, discarding #%"
+                  FMT_OFF_T, conn->connection_id);
+-      Curl_cshutdn_terminate(data, conn, FALSE);
++      Curl_conn_terminate(admin, conn, FALSE);
+       return;
+     }
+   }
+ 
+   Curl_llist_append(&cshutdn->list, conn, &conn->cshutdn_node);
+-  CURL_TRC_M(data, "[SHUTDOWN] added #%" FMT_OFF_T
++  CURL_TRC_M(admin, "[SHUTDOWN] added #%" FMT_OFF_T
+              " to shutdowns, now %zu conns in shutdown",
+              conn->connection_id, Curl_llist_count(&cshutdn->list));
+ }
+ 
+ void Curl_cshutdn_perform(struct cshutdn *cshutdn,
+-                          struct Curl_easy *data,
+                           struct Curl_sigpipe_ctx *sigpipe_ctx)
+ {
+-  cshutdn_perform(cshutdn, data, sigpipe_ctx);
++  cshutdn_perform(cshutdn, sigpipe_ctx);
+ }
+ 
+ /* return fd_set info about the shutdown connections */
+ void Curl_cshutdn_setfds(struct cshutdn *cshutdn,
+-                         struct Curl_easy *data,
+                          fd_set *read_fd_set, fd_set *write_fd_set,
+                          int *maxfd)
+ {
+   if(Curl_llist_head(&cshutdn->list)) {
++    struct Curl_easy *admin = cshutdn->multi->admin;
+     struct Curl_llist_node *e;
+     struct easy_pollset ps;
+ 
+@@ -447,9 +441,9 @@ void Curl_cshutdn_setfds(struct cshutdn *cshutdn,
+       CURLcode result;
+ 
+       Curl_pollset_reset(&ps);
+-      Curl_attach_connection(data, conn);
+-      result = Curl_conn_adjust_pollset(data, conn, &ps);
+-      Curl_detach_connection(data);
++      Curl_attach_connection(admin, conn, FALSE);
++      result = Curl_conn_adjust_pollset(admin, conn, &ps);
++      Curl_detach_connection(admin);
+ 
+       if(result)
+         continue;
+@@ -473,13 +467,13 @@ void Curl_cshutdn_setfds(struct cshutdn *cshutdn,
+ 
+ /* return information about the shutdown connections */
+ unsigned int Curl_cshutdn_add_waitfds(struct cshutdn *cshutdn,
+-                                      struct Curl_easy *data,
+                                       struct Curl_waitfds *cwfds)
+ {
+   unsigned int need = 0;
+ 
+   if(Curl_llist_head(&cshutdn->list)) {
+     struct Curl_llist_node *e;
++    struct Curl_easy *admin = cshutdn->multi->admin;
+     struct easy_pollset ps;
+     struct connectdata *conn;
+     CURLcode result;
+@@ -488,9 +482,9 @@ unsigned int Curl_cshutdn_add_waitfds(struct cshutdn *cshutdn,
+     for(e = Curl_llist_head(&cshutdn->list); e; e = Curl_node_next(e)) {
+       conn = Curl_node_elem(e);
+       Curl_pollset_reset(&ps);
+-      Curl_attach_connection(data, conn);
+-      result = Curl_conn_adjust_pollset(data, conn, &ps);
+-      Curl_detach_connection(data);
++      Curl_attach_connection(admin, conn, FALSE);
++      result = Curl_conn_adjust_pollset(admin, conn, &ps);
++      Curl_detach_connection(admin);
+ 
+       if(!result)
+         need += Curl_waitfds_add_ps(cwfds, &ps);
+@@ -501,7 +495,6 @@ unsigned int Curl_cshutdn_add_waitfds(struct cshutdn *cshutdn,
+ }
+ 
+ CURLcode Curl_cshutdn_add_pollfds(struct cshutdn *cshutdn,
+-                                  struct Curl_easy *data,
+                                   struct curl_pollfds *cpfds)
+ {
+   CURLcode result = CURLE_OK;
+@@ -509,15 +502,16 @@ CURLcode Curl_cshutdn_add_pollfds(struct cshutdn *cshutdn,
+   if(Curl_llist_head(&cshutdn->list)) {
+     struct Curl_llist_node *e;
+     struct easy_pollset ps;
++    struct Curl_easy *admin = cshutdn->multi->admin;
+     struct connectdata *conn;
+ 
+     Curl_pollset_init(&ps);
+     for(e = Curl_llist_head(&cshutdn->list); e; e = Curl_node_next(e)) {
+       conn = Curl_node_elem(e);
+       Curl_pollset_reset(&ps);
+-      Curl_attach_connection(data, conn);
+-      result = Curl_conn_adjust_pollset(data, conn, &ps);
+-      Curl_detach_connection(data);
++      Curl_attach_connection(admin, conn, FALSE);
++      result = Curl_conn_adjust_pollset(admin, conn, &ps);
++      Curl_detach_connection(admin);
+ 
+       if(!result)
+         result = Curl_pollfds_add_ps(cpfds, &ps);
+diff --git a/lib/cshutdn.h b/lib/cshutdn.h
+index 8479524993..a0338f6488 100644
+--- a/lib/cshutdn.h
++++ b/lib/cshutdn.h
+@@ -33,20 +33,20 @@ struct Curl_share;
+ struct Curl_sigpipe_ctx;
+ 
+ /* Run the shutdown of the connection once.
+- * Shortly attach/detach `data` to `conn` while doing so.
++ * Shortly attach/detach the admin handle to `conn` while doing so.
+  * `done` will be set TRUE if any error was encountered or if
+  * the connection was shut down completely. */
+-void Curl_cshutdn_run_once(struct Curl_easy *data,
+-                           struct connectdata *conn,
+-                           bool *done);
++void Curl_conn_shutdown_once(struct Curl_easy *admin,
++                             struct connectdata *conn,
++                             bool *done);
+ 
+ /* Terminates the connection, e.g. closes and destroys it.
+  * If `do_shutdown` is TRUE, the shutdown will be run once before
+  * terminating it.
+  * Takes ownership of `conn`. */
+-void Curl_cshutdn_terminate(struct Curl_easy *data,
+-                            struct connectdata *conn,
+-                            bool do_shutdown);
++void Curl_conn_terminate(struct Curl_easy *admin,
++                         struct connectdata *conn,
++                         bool do_shutdown);
+ 
+ /* A `cshutdown` is always owned by a multi handle to maintain
+  * the connections to be shut down. It registers timers and
+@@ -57,25 +57,28 @@ struct cshutdn {
+   BIT(initialized);
+ };
+ 
++/* Get the cshutdn instance relevant for `data` or NULL if there is none */
++struct cshutdn *Curl_cshutdn_get(struct Curl_easy *data);
++
+ /* Init as part of the given multi handle. */
+ int Curl_cshutdn_init(struct cshutdn *cshutdn,
+                       struct Curl_multi *multi);
+ 
+ /* Terminate all remaining connections and free resources. */
+ void Curl_cshutdn_destroy(struct cshutdn *cshutdn,
+-                          struct Curl_easy *data);
++                          struct Curl_easy *admin);
+ 
+ /* Number of connections being shut down. */
+-size_t Curl_cshutdn_count(struct Curl_easy *data);
++size_t Curl_cshutdn_count(struct cshutdn *cshutdn);
+ 
+ /* Number of connections to the destination being shut down. */
+-size_t Curl_cshutdn_dest_count(struct Curl_easy *data,
++size_t Curl_cshutdn_dest_count(struct cshutdn *cshutdn,
+                                const char *destination);
+ 
+ /* Close the oldest connection in shutdown to destination or,
+  * when destination is NULL for any destination.
+  * Return TRUE if a connection has been closed. */
+-bool Curl_cshutdn_close_oldest(struct Curl_easy *data,
++bool Curl_cshutdn_close_oldest(struct cshutdn *cshutdn,
+                                const char *destination);
+ 
+ /* Add a connection to have it shut down. Terminate the oldest
+@@ -86,21 +89,17 @@ void Curl_cshutdn_add(struct cshutdn *cshutdn,
+ 
+ /* Add sockets and POLLIN/OUT flags for connections being shut down. */
+ CURLcode Curl_cshutdn_add_pollfds(struct cshutdn *cshutdn,
+-                                  struct Curl_easy *data,
+                                   struct curl_pollfds *cpfds);
+ 
+ unsigned int Curl_cshutdn_add_waitfds(struct cshutdn *cshutdn,
+-                                      struct Curl_easy *data,
+                                       struct Curl_waitfds *cwfds);
+ 
+ void Curl_cshutdn_setfds(struct cshutdn *cshutdn,
+-                         struct Curl_easy *data,
+                          fd_set *read_fd_set, fd_set *write_fd_set,
+                          int *maxfd);
+ 
+ /* Run maintenance on all connections. */
+ void Curl_cshutdn_perform(struct cshutdn *cshutdn,
+-                          struct Curl_easy *data,
+                           struct Curl_sigpipe_ctx *sigpipe_ctx);
+ 
+ #endif /* HEADER_CURL_CSHUTDN_H */
+diff --git a/lib/curl_share.c b/lib/curl_share.c
+index 94469bc3ef..ce0b0f5083 100644
+--- a/lib/curl_share.c
++++ b/lib/curl_share.c
+@@ -35,7 +35,7 @@
+ static void share_destroy(struct Curl_share *share)
+ {
+   if(share->specifier & (1 << CURL_LOCK_DATA_CONNECT)) {
+-    Curl_cpool_destroy(&share->cpool);
++    Curl_cpool_destroy(&share->cpool, share->admin);
+   }
+ 
+   Curl_dnscache_destroy(&share->dnscache);
+@@ -261,7 +261,7 @@ CURLSHcode curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
+     case CURL_LOCK_DATA_CONNECT:
+       /* It is safe to set this option several times on a share. */
+       if(!share->cpool.initialized) {
+-        Curl_cpool_init(&share->cpool, share->admin, share, 103);
++        Curl_cpool_init(&share->cpool, share, 103);
+       }
+       break;
+ 
+@@ -368,11 +368,11 @@ CURLSHcode curl_share_cleanup(CURLSH *sh)
+   return CURLSHE_OK;
+ }
+ 
+-CURLSHcode Curl_share_lock(struct Curl_easy *data, curl_lock_data type,
+-                           curl_lock_access accesstype)
++CURLSHcode Curl_share_lock_share(struct Curl_share *share,
++                                 struct Curl_easy *data,
++                                 curl_lock_data type,
++                                 curl_lock_access accesstype)
+ {
+-  struct Curl_share *share = data->share;
+-
+   if(!share)
+     return CURLSHE_INVALID;
+ 
+@@ -385,10 +385,16 @@ CURLSHcode Curl_share_lock(struct Curl_easy *data, curl_lock_data type,
+   return CURLSHE_OK;
+ }
+ 
+-CURLSHcode Curl_share_unlock(struct Curl_easy *data, curl_lock_data type)
++CURLSHcode Curl_share_lock(struct Curl_easy *data, curl_lock_data type,
++                           curl_lock_access accesstype)
+ {
+-  struct Curl_share *share = data->share;
++  return Curl_share_lock_share(data->share, data, type, accesstype);
++}
+ 
++CURLSHcode Curl_share_unlock_share(struct Curl_share *share,
++                                   struct Curl_easy *data,
++                                   curl_lock_data type)
++{
+   if(!share)
+     return CURLSHE_INVALID;
+ 
+@@ -400,6 +406,11 @@ CURLSHcode Curl_share_unlock(struct Curl_easy *data, curl_lock_data type)
+   return CURLSHE_OK;
+ }
+ 
++CURLSHcode Curl_share_unlock(struct Curl_easy *data, curl_lock_data type)
++{
++  return Curl_share_unlock_share(data->share, data, type);
++}
++
+ CURLcode Curl_share_easy_unlink(struct Curl_easy *data)
+ {
+   struct Curl_share *share = data->share;
+diff --git a/lib/curl_share.h b/lib/curl_share.h
+index 1d49a8d1dd..5c687989e0 100644
+--- a/lib/curl_share.h
++++ b/lib/curl_share.h
+@@ -80,6 +80,14 @@ CURLSHcode Curl_share_lock(struct Curl_easy *data, curl_lock_data type,
+                            curl_lock_access accesstype);
+ CURLSHcode Curl_share_unlock(struct Curl_easy *data, curl_lock_data type);
+ 
++CURLSHcode Curl_share_lock_share(struct Curl_share *share,
++                                 struct Curl_easy *data,
++                                 curl_lock_data type,
++                                 curl_lock_access accesstype);
++CURLSHcode Curl_share_unlock_share(struct Curl_share *share,
++                                   struct Curl_easy *data,
++                                   curl_lock_data type);
++
+ /* convenience macro to check if this handle is using a shared SSL spool */
+ #define CURL_SHARE_ssl_scache(data)                                \
+   ((data)->share &&                                                \
+diff --git a/lib/curl_trc.c b/lib/curl_trc.c
+index f8287e420f..f3f048d342 100644
+--- a/lib/curl_trc.c
++++ b/lib/curl_trc.c
+@@ -92,8 +92,7 @@ static struct curl_trc_feat Curl_trc_feat_ids = {
+ 
+ static size_t trc_print_ids(struct Curl_easy *data, char *buf, size_t maxlen)
+ {
+-  curl_off_t cid = data->conn ?
+-                   data->conn->connection_id : data->state.recent_conn_id;
++  curl_off_t cid = data->state.lastconnect_id;
+   if(data->id >= 0) {
+     if(cid >= 0)
+       return curl_msnprintf(buf, maxlen, CURL_TRC_FMT_IDSDC, data->id, cid);
+diff --git a/lib/easy.c b/lib/easy.c
+index d60bdaed7b..44516a79e7 100644
+--- a/lib/easy.c
++++ b/lib/easy.c
+@@ -761,7 +761,7 @@ static CURLcode easy_perform(struct Curl_easy *data, bool events)
+     Curl_detach_connection(data);
+     s = Curl_getconnectinfo(data, &c);
+     if((s != CURL_SOCKET_BAD) && c) {
+-      Curl_conn_terminate(data, c, TRUE);
++      Curl_conn_close(data, c, TRUE);
+     }
+     DEBUGASSERT(!data->conn);
+   }
+@@ -977,7 +977,6 @@ CURL *curl_easy_duphandle(CURL *curl)
+ 
+   /* the connection pool is setup on demand */
+   outcurl->state.lastconnect_id = -1;
+-  outcurl->state.recent_conn_id = -1;
+   outcurl->id = -1;
+   outcurl->mid = UINT32_MAX;
+   outcurl->master_mid = UINT32_MAX;
+@@ -1110,7 +1109,7 @@ void curl_easy_reset(CURL *curl)
+ 
+   data->progress.hide = TRUE;
+   data->state.current_speed = -1; /* init to negative == impossible */
+-  data->state.recent_conn_id = -1; /* clear remembered connection id */
++  data->state.lastconnect_id = -1; /* clear remembered connection id */
+ 
+   /* zero out authentication data: */
+   memset(&data->state.authhost, 0, sizeof(struct auth));
+@@ -1243,7 +1242,7 @@ CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen, size_t *n)
+   if(!data->conn)
+     /* on first invoke, the transfer has been detached from the connection and
+        needs to be reattached */
+-    Curl_attach_connection(data, c);
++    Curl_attach_connection(data, c, TRUE);
+ 
+   *n = 0;
+   return Curl_conn_recv(data, FIRSTSOCKET, buffer, buflen, n);
+@@ -1262,7 +1261,7 @@ CURLcode Curl_connect_only_attach(struct Curl_easy *data)
+   if(!data->conn)
+     /* on first invoke, the transfer has been detached from the connection and
+        needs to be reattached */
+-    Curl_attach_connection(data, c);
++    Curl_attach_connection(data, c, TRUE);
+ 
+   return CURLE_OK;
+ }
+@@ -1288,7 +1287,7 @@ CURLcode Curl_senddata(struct Curl_easy *data, const void *buffer,
+   if(!data->conn)
+     /* on first invoke, the transfer has been detached from the connection and
+        needs to be reattached */
+-    Curl_attach_connection(data, c);
++    Curl_attach_connection(data, c, TRUE);
+ 
+   sigpipe_ignore(data, &sigpipe_ctx);
+   result = Curl_conn_send(data, FIRSTSOCKET, buffer, buflen, FALSE, n);
+diff --git a/lib/getinfo.c b/lib/getinfo.c
+index fde4aa4ef2..20c907ab06 100644
+--- a/lib/getinfo.c
++++ b/lib/getinfo.c
+@@ -469,8 +469,7 @@ static CURLcode getinfo_offt(struct Curl_easy *data, CURLINFO info,
+     *param_offt = data->id;
+     break;
+   case CURLINFO_CONN_ID:
+-    *param_offt = data->conn ?
+-      data->conn->connection_id : data->state.recent_conn_id;
++    *param_offt = data->state.lastconnect_id;
+     break;
+   case CURLINFO_EARLYDATA_SENT_T:
+     *param_offt = data->progress.earlydata_sent;
+diff --git a/lib/multi.c b/lib/multi.c
+index 1ae679565e..681ed2838d 100644
+--- a/lib/multi.c
++++ b/lib/multi.c
+@@ -299,7 +299,7 @@ struct Curl_multi *Curl_multi_handle(uint32_t xfer_table_size,
+   if(Curl_cshutdn_init(&multi->cshutdn, multi))
+     goto error;
+ 
+-  Curl_cpool_init(&multi->cpool, multi->admin, NULL, chashsize);
++  Curl_cpool_init(&multi->cpool, NULL, chashsize);
+ 
+ #ifdef USE_SSL
+   if(Curl_ssl_scache_create(sesssize, 2, &multi->ssl_scache))
+@@ -348,7 +348,7 @@ error:
+   Curl_multi_ev_cleanup(multi);
+   Curl_hash_destroy(&multi->proto_hash);
+   Curl_dnscache_destroy(&multi->dnscache);
+-  Curl_cpool_destroy(&multi->cpool);
++  Curl_cpool_destroy(&multi->cpool, multi->admin);
+   Curl_cshutdn_destroy(&multi->cshutdn, multi->admin);
+ #ifdef USE_SSL
+   Curl_ssl_scache_destroy(multi->ssl_scache);
+@@ -667,8 +667,6 @@ static void multi_done_locked(struct connectdata *conn,
+   }
+ 
+   data->state.done = TRUE; /* called now! */
+-  data->state.recent_conn_id = conn->connection_id;
+-
+   Curl_dnscache_prune(data);
+ 
+   if(multi_conn_should_close(conn, data, (bool)mdctx->premature)) {
+@@ -678,20 +676,19 @@ static void multi_done_locked(struct connectdata *conn,
+                data->set.reuse_forbid, conn->bits.close, mdctx->premature,
+                Curl_conn_is_multiplex(conn, FIRSTSOCKET));
+     connclose(conn, "disconnecting");
+-    Curl_conn_terminate(data, conn, (bool)mdctx->premature);
++    Curl_conn_close(data, conn, (bool)mdctx->premature);
+   }
+   else if(!Curl_conn_get_max_concurrent(data, conn, FIRSTSOCKET)) {
+     CURL_TRC_M(data, "multi_done, conn #%" FMT_OFF_T " to %s was shutdown"
+                " by server, not reusing", conn->connection_id,
+                conn->destination);
+     connclose(conn, "server shutdown");
+-    Curl_conn_terminate(data, conn, (bool)mdctx->premature);
++    Curl_conn_close(data, conn, (bool)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 */
+-      data->state.lastconnect_id = conn->connection_id;
+       infof(data, "Connection #%" FMT_OFF_T " to host %s left intact",
+             conn->connection_id, conn->destination);
+     }
+@@ -888,7 +885,7 @@ CURLMcode curl_multi_remove_handle(CURLM *m, CURL *curl)
+     curl_socket_t s;
+     s = Curl_getconnectinfo(data, &c);
+     if((s != CURL_SOCKET_BAD) && c) {
+-      Curl_conn_terminate(data, c, TRUE);
++      Curl_conn_close(data, c, TRUE);
+     }
+   }
+ 
+@@ -978,16 +975,23 @@ void Curl_detach_connection(struct Curl_easy *data)
+ /*
+  * Curl_attach_connection() attaches this transfer to this connection.
+  *
+- * This is the only function that should assign data->conn
++ * This is the only function that should assign data->conn.
++ * `matched == TRUE` means the transfer's properties match this
++ * connection and it is not a temporary attach for maintenance.
+  */
+ void Curl_attach_connection(struct Curl_easy *data,
+-                            struct connectdata *conn)
++                            struct connectdata *conn,
++                            bool matched)
+ {
+   DEBUGASSERT(data);
+   DEBUGASSERT(!data->conn);
+   DEBUGASSERT(conn);
+   DEBUGASSERT(conn->attached_xfers < UINT32_MAX);
+   data->conn = conn;
++  if(matched)
++    data->state.lastconnect_id = conn->connection_id;
++  else
++    DEBUGASSERT(!data->mid); /* admin handle */
+   conn->attached_xfers++;
+   /* all attached transfers must be from the same multi */
+   if(!conn->attached_multi)
+@@ -1317,8 +1321,8 @@ CURLMcode curl_multi_fdset(CURLM *m,
+     } while(Curl_uint32_bset_next(&multi->process, mid, &mid));
+   }
+ 
+-  Curl_cshutdn_setfds(&multi->cshutdn, multi->admin,
+-                      read_fd_set, write_fd_set, &this_max_fd);
++  Curl_cshutdn_setfds(&multi->cshutdn, read_fd_set, write_fd_set,
++                      &this_max_fd);
+ 
+   *max_fd = this_max_fd;
+   Curl_pollset_cleanup(&ps);
+@@ -1363,7 +1367,7 @@ CURLMcode curl_multi_waitfds(CURLM *m,
+     } while(Curl_uint32_bset_next(&multi->process, mid, &mid));
+   }
+ 
+-  need += Curl_cshutdn_add_waitfds(&multi->cshutdn, multi->admin, &cwfds);
++  need += Curl_cshutdn_add_waitfds(&multi->cshutdn, &cwfds);
+ 
+   if(need != cwfds.n && ufds)
+     mresult = CURLM_OUT_OF_MEMORY;
+@@ -1604,7 +1608,7 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
+     } while(Curl_uint32_bset_next(&multi->process, mid, &mid));
+   }
+ 
+-  if(Curl_cshutdn_add_pollfds(&multi->cshutdn, multi->admin, &cpfds)) {
++  if(Curl_cshutdn_add_pollfds(&multi->cshutdn, &cpfds)) {
+     mresult = CURLM_OUT_OF_MEMORY;
+     goto out;
+   }
+@@ -1792,7 +1796,7 @@ CURLMcode Curl_multi_add_perform(struct Curl_multi *multi,
+ 
+     /* take this handle to the perform state right away */
+     multistate(data, MSTATE_PERFORMING);
+-    Curl_attach_connection(data, conn);
++    Curl_attach_connection(data, conn, TRUE);
+     CURL_REQ_SET_RECV(data);
+   }
+   return mresult;
+@@ -2417,7 +2421,7 @@ static CURLcode is_finished(struct Curl_multi *multi,
+              We do not have to do this in every case block above where a
+              failure is detected */
+           Curl_detach_connection(data);
+-          Curl_conn_terminate(data, conn, dead_connection);
++          Curl_conn_close(data, conn, dead_connection);
+         }
+       }
+       else if(data->mstate == MSTATE_CONNECT) {
+@@ -2741,7 +2745,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
+                                  struct Curl_easy *data,
+                                  struct Curl_sigpipe_ctx *sigpipe_ctx)
+ {
+-  CURLMcode mresult;
++  CURLMcode mresult = CURLM_OK;
+   CURLcode result = CURLE_OK;
+ 
+   if(!GOOD_EASY_HANDLE(data))
+@@ -2771,8 +2775,8 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
+ #ifdef USE_RESOLV_THREADED
+     Curl_async_thrdd_multi_process(multi);
+ #endif
+-    Curl_cshutdn_perform(&multi->cshutdn, multi->admin, sigpipe_ctx);
+-    return CURLM_OK;
++    Curl_cshutdn_perform(&multi->cshutdn, sigpipe_ctx);
++    goto out;
+   }
+ 
+   sigpipe_apply(data, sigpipe_ctx);
+@@ -2791,8 +2795,10 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
+        data->mstate < MSTATE_COMPLETED) {
+       /* Make sure we set the connection's current owner */
+       DEBUGASSERT(data->conn);
+-      if(!data->conn)
+-        return CURLM_INTERNAL_ERROR;
++      if(!data->conn) {
++        mresult = CURLM_INTERNAL_ERROR;
++        goto out;
++      }
+     }
+ 
+     /* Wait for the connect state as only then is the start time stored, but
+@@ -2874,7 +2880,8 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
+       break;
+ 
+     default:
+-      return CURLM_INTERNAL_ERROR;
++      mresult = CURLM_INTERNAL_ERROR;
++      goto out;
+     }
+ 
+     if(data->mstate >= MSTATE_CONNECT &&
+@@ -2898,11 +2905,13 @@ statemachine_end:
+ 
+     if(MSTATE_COMPLETED == data->mstate) {
+       handle_completed(multi, data, result);
+-      return CURLM_OK;
++      mresult = CURLM_OK;
++      goto out;
+     }
+   } while((mresult == CURLM_CALL_MULTI_PERFORM) ||
+           multi_ischanged(multi, FALSE));
+ 
++out:
+   data->result = result;
+   return mresult;
+ }
+@@ -3049,7 +3058,7 @@ CURLMcode curl_multi_cleanup(CURLM *m)
+ #ifdef USE_RESOLV_THREADED
+     Curl_async_thrdd_multi_destroy(multi, !multi->quick_exit);
+ #endif
+-    Curl_cpool_destroy(&multi->cpool);
++    Curl_cpool_destroy(&multi->cpool, multi->admin);
+     Curl_cshutdn_destroy(&multi->cshutdn, multi->admin);
+     if(multi->admin) {
+       CURL_TRC_M(multi->admin, "multi_cleanup, closing admin handle, done");
+@@ -3438,7 +3447,7 @@ CURLMcode curl_multi_setopt(CURLM *m, CURLMoption option, ...)
+       Curl_dnscache_clear(multi->admin);
+     }
+     if(val & CURLMNWC_CLEAR_CONNS) {
+-      Curl_cpool_nw_changed(multi->admin);
++      Curl_cpool_nw_changed(&multi->cpool, multi->admin);
+     }
+     break;
+   }
+diff --git a/lib/multiif.h b/lib/multiif.h
+index 920bf0e917..db9c8acf18 100644
+--- a/lib/multiif.h
++++ b/lib/multiif.h
+@@ -34,7 +34,8 @@ void Curl_expire_clear(struct Curl_easy *data);
+ void Curl_expire_done(struct Curl_easy *data, expire_id id);
+ CURLMcode Curl_update_timer(struct Curl_multi *multi) WARN_UNUSED_RESULT;
+ void Curl_attach_connection(struct Curl_easy *data,
+-                            struct connectdata *conn);
++                            struct connectdata *conn,
++                            bool matched);
+ void Curl_detach_connection(struct Curl_easy *data);
+ bool Curl_multiplex_wanted(const struct Curl_multi *multi);
+ void Curl_set_in_callback(struct Curl_easy *data, bool value);
+diff --git a/lib/url.c b/lib/url.c
+index 505e08a7e1..4cfd3a1bb7 100644
+--- a/lib/url.c
++++ b/lib/url.c
+@@ -469,7 +469,6 @@ CURLcode Curl_open(struct Curl_easy **curl)
+   data->magic = CURLEASY_MAGIC_NUMBER;
+   /* most recent connection is not yet defined */
+   data->state.lastconnect_id = -1;
+-  data->state.recent_conn_id = -1;
+   /* and not assigned an id yet */
+   data->id = -1;
+   data->mid = UINT32_MAX;
+@@ -622,14 +621,14 @@ bool Curl_conn_seems_dead(struct connectdata *conn,
+       /* The protocol has a special method for checking the state of the
+          connection. Use it to check if the connection is dead. */
+       /* briefly attach the connection for the check */
+-      Curl_attach_connection(data, conn);
++      Curl_attach_connection(data, conn, FALSE);
+       dead = conn->scheme->run->connection_is_dead(data, conn);
+       Curl_detach_connection(data);
+     }
+     else {
+       bool input_pending = FALSE;
+ 
+-      Curl_attach_connection(data, conn);
++      Curl_attach_connection(data, conn, FALSE);
+       dead = !Curl_conn_is_alive(data, conn, &input_pending);
+       if(input_pending) {
+         /* For reuse, we want a "clean" connection state. This includes
+@@ -665,7 +664,7 @@ CURLcode Curl_conn_upkeep(struct Curl_easy *data,
+     return result;
+ 
+   /* briefly attach for action */
+-  Curl_attach_connection(data, conn);
++  Curl_attach_connection(data, conn, FALSE);
+   result = Curl_conn_keep_alive(data, conn, FIRSTSOCKET);
+   Curl_detach_connection(data);
+ 
+@@ -690,6 +689,7 @@ struct url_conn_match {
+   struct connectdata *found;
+   struct Curl_easy *data;
+   struct connectdata *needle;
++  struct curltime now;
+   BIT(may_multiplex);
+   BIT(want_ntlm_http);
+   BIT(want_proxy_ntlm_http);
+@@ -1002,27 +1002,54 @@ static bool url_match_ssl_config(struct connectdata *conn,
+   return TRUE;
+ }
+ 
++#if defined(USE_SPNEGO) || defined(USE_NTLM)
++static bool url_allow_sspi_empty_creds(struct Curl_creds *conn_creds,
++                                       struct Curl_easy *data,
++                                       struct connectdata *conn)
++{
++#ifdef USE_WINDOWS_SSPI
++  /* Empty user: SSPI on Windows can make use of an "ambient"
++   * user from a "SecurityToken" associated with the current thread or
++   * process. This token can be switched at any time. We are therefore
++   * not able to find out reliably what token the connection really
++   * used, nor what token in the next connect attempt will use.
++   * To avoid TOCTOU attacks, do not reuse on empty credentials
++   * UNLESS this connection is the one used by this transfer before. */
++  if(!Curl_creds_has_user(conn_creds) &&
++     (data->state.lastconnect_id != conn->connection_id))
++    return FALSE;
++#else
++  (void)conn_creds;
++  (void)data;
++  (void)conn;
++#endif
++  return TRUE;
++}
++#endif /* USE_SPNEGO || USE_NTLM */
++
+ #ifdef USE_NTLM
+ static bool url_match_auth_ntlm(struct connectdata *conn,
+                                 struct url_conn_match *m)
+ {
+-  /* 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(m->want_ntlm_http) {
++  if(conn->http_ntlm_state != NTLMSTATE_NONE) {
++    /* Connection is using NTLM. We cannot reuse if transfer
++     * has different Auth input parameters.
++     * To avoid TOCTOU attacks, do not reuse on empty credentials. */
++    if(!m->want_ntlm_http ||
++       !Curl_creds_has_user(conn->creds) ||
++       !Curl_creds_same(conn->creds, m->data->state.creds) ||
++       !Curl_peer_equal(conn->creds_origin, m->data->state.origin))
++      return FALSE;
++    if(!url_allow_sspi_empty_creds(conn->creds, m->data, conn))
++      return FALSE;
++  }
++  else if(m->want_ntlm_http) {
++    /* Transfer wants NTLM, connection is not using it.
++     * Do not reuse when connection has credentials and they differ. */
+     if(conn->creds &&
+        (!Curl_creds_same(conn->creds, m->data->state.creds) ||
+-        !Curl_peer_equal(conn->creds_origin, m->data->state.origin))) {
+-      /* connection credentials in play and not the same or not for the
+-       * same origin. */
++        !Curl_peer_equal(conn->creds_origin, m->data->state.origin)))
+       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
+@@ -1069,23 +1096,36 @@ static bool url_match_auth_ntlm(struct connectdata *conn,
+ static bool url_match_auth_nego(struct connectdata *conn,
+                                 struct url_conn_match *m)
+ {
+-  /* If we are looking for an HTTP+Negotiate connection, check if this is
+-     already authenticating with the right credentials. If not, keep looking
+-     so that we can reuse Negotiate connections if possible. */
+-  if(m->want_nego_http) {
++  if(conn->http_negotiate_state != GSS_AUTHNONE) {
++    /* Connection is using Negotiate. We cannot reuse if transfer
++     * has different Auth input parameters. */
++    if(!m->want_nego_http ||
++       !Curl_creds_same(conn->creds, m->data->state.creds) ||
++       !Curl_peer_equal(conn->creds_origin, m->data->state.origin))
++      return FALSE;
++    if(!url_allow_sspi_empty_creds(conn->creds, m->data, conn))
++      return FALSE;
++  }
++  else if(m->want_nego_http) {
++    /* Transfer wants Negotiate, connection is not using it.
++     * Do not reuse when connection has credentials and they differ. */
+     if(conn->creds &&
+        (!Curl_creds_same(conn->creds, m->data->state.creds) ||
+         !Curl_peer_equal(conn->creds_origin, m->data->state.origin)))
+       return FALSE;
+   }
+-  else if(conn->http_negotiate_state != GSS_AUTHNONE) {
+-    /* Connection is using Negotiate auth but we do not want Negotiate */
+-    return FALSE;
+-  }
+ 
+ #ifndef CURL_DISABLE_PROXY
+   /* Same for Proxy Negotiate authentication */
+-  if(m->want_proxy_nego_http) {
++  if(conn->proxy_negotiate_state != GSS_AUTHNONE) {
++    if(!m->want_proxy_nego_http ||
++       !Curl_creds_same(m->needle->http_proxy.creds, conn->http_proxy.creds))
++      return FALSE;
++    if(!url_allow_sspi_empty_creds(m->needle->http_proxy.creds,
++                                   m->data, conn))
++      return FALSE;
++  }
++  else if(m->want_proxy_nego_http) {
+     /* Both conn->http_proxy.user and conn->http_proxy.passwd can be
+      * NULL */
+     if(!conn->http_proxy.creds)
+@@ -1094,10 +1134,6 @@ static bool url_match_auth_nego(struct connectdata *conn,
+     if(!Curl_creds_same(m->needle->http_proxy.creds, conn->http_proxy.creds))
+       return FALSE;
+   }
+-  else if(conn->proxy_negotiate_state != GSS_AUTHNONE) {
+-    /* Proxy connection is using Negotiate auth but we do not want Negotiate */
+-    return FALSE;
+-  }
+ #endif
+   if(m->want_nego_http || m->want_proxy_nego_http) {
+     /* Credentials are already checked, we may use this connection. We MUST
+@@ -1172,9 +1208,13 @@ static bool url_match_conn(struct connectdata *conn, void *userdata)
+   if(!url_match_multiplex_limits(conn, m))
+     return FALSE;
+ 
+-  if(!CONN_INUSE(conn) && Curl_conn_seems_dead(conn, m->data)) {
+-    /* remove and disconnect. */
+-    Curl_conn_terminate(m->data, conn, FALSE);
++  /* If we are going to pick an idle connection, do an extra
++   * health check before we reuse it. */
++  if(!CONN_INUSE(conn) &&
++     !Curl_cpool_conn_seems_healthy(conn, m->data, &m->now)) {
++    infof(m->data, "Connection %" FMT_OFF_T " seems to be dead, terminating",
++          conn->connection_id);
++    Curl_conn_close(m->data, conn, FALSE);
+     return FALSE;
+   }
+ 
+@@ -1189,7 +1229,7 @@ static bool url_match_result(void *userdata)
+   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);
++    Curl_attach_connection(match->data, match->found, TRUE);
+     return TRUE;
+   }
+   else if(match->seen_single_use_conn && !match->seen_multiplex_conn) {
+@@ -1220,15 +1260,20 @@ static bool url_attach_existing(struct Curl_easy *data,
+                                 struct connectdata *needle,
+                                 bool *waitpipe)
+ {
++  struct cpool *cpool = Curl_cpool_get_instance(data);
+   struct url_conn_match match;
+   bool success;
+ 
+   DEBUGASSERT(!data->conn);
++
+   memset(&match, 0, sizeof(match));
+   match.data = data;
+   match.needle = needle;
++  match.now = *Curl_pgrs_now(data);
+   match.may_multiplex = xfer_may_multiplex(data, needle);
+ 
++  Curl_cpool_prune_dead(cpool, data);
++
+ #ifdef USE_NTLM
+   match.want_ntlm_http =
+     (data->state.authhost.want & CURLAUTH_NTLM) &&
+@@ -2351,9 +2396,9 @@ static CURLcode url_find_or_create_conn(struct Curl_easy *data)
+       goto out;
+ 
+     /* Setup a "faked" transfer that will do nothing */
+-    Curl_attach_connection(data, needle);
++    result = Curl_cpool_add(data, needle);
++    Curl_attach_connection(data, needle, TRUE);
+     needle = NULL;
+-    result = Curl_cpool_add(data, data->conn);
+     if(!result) {
+       /* Setup whatever necessary for a resumed transfer */
+       result = setup_range(data);
+@@ -2378,7 +2423,7 @@ static CURLcode url_find_or_create_conn(struct Curl_easy *data)
+     goto out;
+ 
+   /* Get rid of any dead connections so limit are easier kept. */
+-  Curl_cpool_prune_dead(data);
++  Curl_cpool_prune_dead(Curl_cpool_get_instance(data), data);
+ 
+   /*************************************************************
+    * Reuse of existing connection is not allowed when
+@@ -2458,11 +2503,12 @@ static CURLcode url_find_or_create_conn(struct Curl_easy *data)
+       DEBUGF(curl_mfprintf(stderr, "Error: init connection SSL config\n"));
+       goto out;
+     }
+-    /* attach it and no longer own it */
+-    Curl_attach_connection(data, needle);
+-    needle = NULL;
+ 
+-    result = Curl_cpool_add(data, data->conn);
++    /* Add needle to conn pool, which assigns the connection id.
++     * Attach regardless of result, for correct handling. */
++    result = Curl_cpool_add(data, needle);
++    Curl_attach_connection(data, needle, TRUE);
++    needle = NULL;
+     if(result)
+       goto out;
+ 
+@@ -2573,7 +2619,7 @@ out:
+     /* We are not allowed to return failure with memory left allocated in the
+        connectdata struct, free those here */
+     Curl_detach_connection(data);
+-    Curl_conn_terminate(data, conn, TRUE);
++    Curl_conn_close(data, conn, TRUE);
+   }
+ 
+   return result;
+@@ -2646,6 +2692,31 @@ void *Curl_conn_meta_get(struct connectdata *conn, const char *key)
+   return Curl_hash_pick(&conn->meta_hash, CURL_UNCONST(key), strlen(key) + 1);
+ }
+ 
++struct Curl_easy *Curl_get_admin(struct Curl_easy *data)
++{
++  struct Curl_easy *admin;
++
++  if(!data->mid) /* already an admin handle */
++    admin = data;
++  else if(data->multi)
++    admin = data->multi->admin;
++  else if(data->multi_easy)
++    admin = data->multi_easy->admin;
++  else {
++    DEBUGASSERT(0); /* we do not want this. does it happen? */
++    admin = data;
++  }
++  if(admin != data) {
++    admin->set.conn_max_idle_ms = data->set.conn_max_idle_ms;
++    admin->set.conn_max_age_ms = data->set.conn_max_age_ms;
++    admin->set.upkeep_interval_ms = data->set.upkeep_interval_ms;
++    admin->set.timeout = data->set.timeout;
++    admin->set.server_response_timeout = data->set.server_response_timeout;
++    admin->set.no_signal = data->set.no_signal;
++  }
++  return admin;
++}
++
+ CURLcode Curl_1st_fatal(CURLcode r1, CURLcode r2)
+ {
+   if(r1 && (r1 != CURLE_AGAIN))
+diff --git a/lib/url.h b/lib/url.h
+index ebbe9d53c4..767bd7551a 100644
+--- a/lib/url.h
++++ b/lib/url.h
+@@ -67,6 +67,12 @@ CURLcode Curl_conn_meta_set(struct connectdata *conn, const char *key,
+ void Curl_conn_meta_remove(struct connectdata *conn, const char *key);
+ void *Curl_conn_meta_get(struct connectdata *conn, const char *key);
+ 
++/* Get an admin handle for internal operations from the given
++ * easy handle, if possible. The admin handle inherits certain
++ * properties from `data`. If no admin handle is available (not multi
++ * or share attached), the easy handle itself is returned. */
++struct Curl_easy *Curl_get_admin(struct Curl_easy *data);
++
+ #define CURL_DEFAULT_PROXY_PORT 1080 /* default proxy port unless specified */
+ #define CURL_DEFAULT_HTTPS_PROXY_PORT 443 /* default https proxy port unless
+                                              specified */
+diff --git a/lib/urldata.h b/lib/urldata.h
+index d4d336d8db..1905994f0b 100644
+--- a/lib/urldata.h
++++ b/lib/urldata.h
+@@ -305,6 +305,7 @@ struct connectdata {
+   char *options; /* options string, allocated */
+   struct curltime created; /* creation time */
+   struct curltime lastused; /* when returned to the connection pool as idle */
++  struct curltime lastchecked; /* when last checked alive status */
+ 
+   /* A connection can have one or two sockets and connection filters.
+    * The protocol using the 2nd one is FTP for CONTROL+DATA sockets */
+@@ -573,9 +574,7 @@ struct UrlState {
+   /* buffers to store authentication data in, as parsed from input options */
+   struct curltime keeps_speed; /* for the progress meter really */
+ 
+-  curl_off_t lastconnect_id; /* The last connection, -1 if undefined */
+-  curl_off_t recent_conn_id; /* The most recent connection used, might no
+-                              * longer exist */
++  curl_off_t lastconnect_id; /* The last assigned connection or -1 */
+   struct dynbuf headerb; /* buffer to store headers in */
+ #ifndef CURL_DISABLE_HSTS
+   struct curl_slist *hstslist; /* list of HSTS files set by
+diff --git a/tests/data/test1554 b/tests/data/test1554
+index fa071b09b2..545acc5528 100644
+--- a/tests/data/test1554
++++ b/tests/data/test1554
+@@ -30,6 +30,8 @@ run 1: foobar and so on fun!
+ [- Mutex unlock CONNECT
+ -] Mutex lock CONNECT
+ [- Mutex unlock CONNECT
++-] Mutex lock CONNECT
++[- Mutex unlock CONNECT
+ run 1: foobar and so on fun!
+ -] Mutex lock CONNECT
+ [- Mutex unlock CONNECT
+@@ -45,6 +47,8 @@ run 1: foobar and so on fun!
+ [- Mutex unlock CONNECT
+ -] Mutex lock CONNECT
+ [- Mutex unlock CONNECT
++-] Mutex lock CONNECT
++[- Mutex unlock CONNECT
+ run 1: foobar and so on fun!
+ -] Mutex lock CONNECT
+ [- Mutex unlock CONNECT
+@@ -60,6 +64,8 @@ run 1: foobar and so on fun!
+ [- Mutex unlock CONNECT
+ -] Mutex lock CONNECT
+ [- Mutex unlock CONNECT
++-] Mutex lock CONNECT
++[- Mutex unlock CONNECT
+ run 1: foobar and so on fun!
+ -] Mutex lock CONNECT
+ [- Mutex unlock CONNECT
+@@ -69,6 +75,8 @@ run 1: foobar and so on fun!
+ [- Mutex unlock SHARE
+ -] Mutex lock SHARE
+ [- Mutex unlock SHARE
++-] Mutex lock CONNECT
++[- Mutex unlock CONNECT
+ </datacheck>
+ </reply>
+ 

diff --git a/0004-curl-8.21.0-remove-test1701.patch b/0004-curl-8.21.0-remove-test1701.patch
deleted file mode 100644
index 6b167bf..0000000
--- a/0004-curl-8.21.0-remove-test1701.patch
+++ /dev/null
@@ -1,127 +0,0 @@
-From 2d37e9969df87ee5b5c7e43d5b261b048a25001b Mon Sep 17 00:00:00 2001
-From: Stefan Eissing <stefan@eissing.org>
-Date: Fri, 10 Jul 2026 09:58:08 +0200
-Subject: [PATCH] tests: remove test1701
-
-Test 1701 did a HTTP/2 Upgrade in a HTTP/1.1 POST request. This will no
-longer be supported in the upcoming nghttp2 release for security reasons
-(Upgrade requests with body a re messy, error prone and can easily lead
-to connection confusion).
-
-As no other server we have supports this, remove the test.
-
-Reported-by: firexinghe on github
-Fixes #22280
-Closes #22291
-
-(cherry picked from commit e89d5a1202f3e00918eb0ea465041dbaa78e75c7)
----
- tests/data/Makefile.am |  2 +-
- tests/data/test1701    | 82 ------------------------------------------
- 2 files changed, 1 insertion(+), 83 deletions(-)
- delete mode 100644 tests/data/test1701
-
-diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
-index 69bfdc9134..5a190f1fea 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -223,7 +223,7 @@ test1669 test1670 test1671 test1672 test1673 test1674 test1675 test1676 \
- test1677                   test1680 test1681 test1682 test1683 test1684 \
- test1685 test1686 \
- \
--test1700 test1701 test1702 test1703 test1704 test1705 test1706 test1707 \
-+test1700          test1702 test1703 test1704 test1705 test1706 test1707 \
- test1708 test1709 test1710 test1711 test1712 test1713 test1714 test1715 \
- test1720 test1721 test1722 test1723 test1724 test1725 \
- \
-diff --git a/tests/data/test1701 b/tests/data/test1701
-deleted file mode 100644
-index 50e782bed0..0000000000
---- a/tests/data/test1701
-+++ /dev/null
-@@ -1,82 +0,0 @@
--<?xml version="1.0" encoding="US-ASCII"?>
--<testcase>
--<info>
--<keywords>
--HTTP
--HTTP POST
--HTTP/2
--</keywords>
--</info>
--
--# Server-side
--<reply>
--<data crlf="headers" nocheck="yes">
--HTTP/1.1 200 OK
--Date: Tue, 09 Nov 2010 14:49:00 GMT
--Server: test-server/fake
--Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
--ETag: "21025-dc7-39462498"
--Accept-Ranges: bytes
--Content-Length: 6
--Connection: close
--Content-Type: text/html
--Funny-head: yesyes
--
---foo-
--</data>
--</reply>
--
--# Client-side
--<client>
--<features>
--h2c
--</features>
--<server>
--http/2
--</server>
--<name>
--HTTP/2 POST with Upgrade:
--</name>
--<command>
--http://%HOSTIP:%HTTP2PORT/%TESTNUMBER --http2 -d "datatosend"
--</command>
--</client>
--
--# Verify data after the test has been "shot"
--<verify>
--<strip>
--^X-Forwarded-Proto:.*
--^Via:.*
--</strip>
--<protocol crlf="yes" nonewline="yes">
--POST /%TESTNUMBER HTTP/1.1
--Host: %HOSTIP:%HTTP2PORT
--User-Agent: curl/%VERSION
--Accept: */*
--Content-Length: 10
--Content-Type: application/x-www-form-urlencoded
--
--datatosend
--</protocol>
--<stdout crlf="headers">
--HTTP/1.1 101 Switching Protocols
--Connection: Upgrade
--Upgrade: h2c
--
--HTTP/2 200%SP
--date: Tue, 09 Nov 2010 14:49:00 GMT
--last-modified: Tue, 13 Jun 2000 12:10:00 GMT
--etag: "21025-dc7-39462498"
--accept-ranges: bytes
--content-length: 6
--content-type: text/html
--funny-head: yesyes
--via: 1.1 nghttpx
--
---foo-
--</stdout>
--<stripfile>
--s/^server: nghttpx.*\r?\n//
--</stripfile>
--</verify>
--</testcase>
--- 
-2.55.0
-

diff --git a/0005-curl-8.21.0-CVE-2026-80255.patch b/0005-curl-8.21.0-CVE-2026-80255.patch
deleted file mode 100644
index 0e083a3..0000000
--- a/0005-curl-8.21.0-CVE-2026-80255.patch
+++ /dev/null
@@ -1,105 +0,0 @@
-From 3765167e6e46c8a549d822983f4eec7048c28099 Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Thu, 27 Aug 2026 08:33:30 +0200
-Subject: [PATCH 1/2] cookie: improve TAB handling
-
-For entries with a leading tab. Verified in test 2885.
-
-Reported-by: Stanislav Fort
-Closes #22699
-
-(cherry picked from commit 4f6aa41a0145e930e766775dbe860883d350aa0a)
----
- lib/cookie.c           |  2 +-
- tests/data/Makefile.am |  2 +-
- tests/data/test2885    | 52 ++++++++++++++++++++++++++++++++++++++++++
- 3 files changed, 54 insertions(+), 2 deletions(-)
- create mode 100644 tests/data/test2885
-
-diff --git a/lib/cookie.c b/lib/cookie.c
-index 91dc8d5fd0..c608b90321 100644
---- a/lib/cookie.c
-+++ b/lib/cookie.c
-@@ -614,7 +614,7 @@ parse_cookie_header(struct Curl_easy *data,
-     struct Curl_str name;
- 
-     /* we have a <name>=<value> pair or a stand-alone word here */
--    if(!curlx_str_cspn(&ptr, &name, ";\t\r\n=")) {
-+    if(!curlx_str_cspn(&ptr, &name, ";\r\n=")) {
-       struct Curl_str val;
-       bool sep = FALSE;
-       curlx_str_trimblanks(&name);
-diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
-index 5a190f1fea..17227ba369 100644
---- a/tests/data/Makefile.am
-+++ b/tests/data/Makefile.am
-@@ -272,7 +272,7 @@ test2600 test2601 test2602 test2603 test2604 test2605 \
- test2700 test2701 test2702 test2703 test2704 test2705 test2706 test2707 \
- test2708 test2709 test2710 test2711 test2712 test2713 test2714 test2715 \
- test2716 test2717 test2718 test2719 test2720 test2721 test2722 test2723 \
--\
-+test2885 \
- test3000 test3001 test3002 test3003 test3004 test3005 test3006 test3007 \
- test3008 test3009 test3010 test3011 test3012 test3013 test3014 test3015 \
- test3016 test3017 test3018 test3019 test3020 test3021 test3022 test3023 \
-diff --git a/tests/data/test2885 b/tests/data/test2885
-new file mode 100644
-index 0000000000..456224fdc5
---- /dev/null
-+++ b/tests/data/test2885
-@@ -0,0 +1,52 @@
-+<?xml version="1.0" encoding="US-ASCII"?>
-+<testcase>
-+<info>
-+<keywords>
-+HTTP
-+cookies
-+</keywords>
-+</info>
-+
-+<reply>
-+<data crlf="headers">
-+HTTP/1.1 200 OK
-+Content-Length: 0
-+Set-Cookie: thisis=SECRET;%TABSecure
-+Set-Cookie: also=notab; Secure
-+
-+</data>
-+</reply>
-+
-+<client>
-+<features>
-+cookies
-+</features>
-+<server>
-+https
-+</server>
-+<name>
-+Cookies with TAB before 'secure'
-+</name>
-+<command>
-+https://cookie.example:%HTTPSPORT/%TESTNUMBER -c %LOGDIR/cookies.txt --resolve cookie.example:%HTTPSPORT:%HOSTIP --insecure
-+</command>
-+</client>
-+
-+<verify>
-+<protocol crlf="headers">
-+GET /%TESTNUMBER HTTP/1.1
-+Host: cookie.example:%HTTPSPORT
-+User-Agent: curl/%VERSION
-+Accept: */*
-+
-+</protocol>
-+<file name="%LOGDIR/cookies.txt" mode="text">
-+# Netscape HTTP Cookie File
-+# https://curl.se/docs/http-cookies.html
-+# This file was generated by libcurl! Edit at your own risk.
-+
-+cookie.example%TABFALSE%TAB/%TABTRUE%TAB0%TABalso%TABnotab
-+cookie.example%TABFALSE%TAB/%TABTRUE%TAB0%TABthisis%TABSECRET
-+</file>
-+</verify>
-+</testcase>
--- 
-2.55.0
-

diff --git a/0005-tests-remove-test1701.patch b/0005-tests-remove-test1701.patch
new file mode 100644
index 0000000..da40a85
--- /dev/null
+++ b/0005-tests-remove-test1701.patch
@@ -0,0 +1,124 @@
+From 578cfd7d12eee94712972ec52f9f27a427b743a4 Mon Sep 17 00:00:00 2001
+From: Stefan Eissing <stefan@eissing.org>
+Date: Fri, 10 Jul 2026 09:58:08 +0200
+Subject: [PATCH] tests: remove test1701
+
+Test 1701 did a HTTP/2 Upgrade in a HTTP/1.1 POST request. This will no
+longer be supported in the upcoming nghttp2 release for security reasons
+(Upgrade requests with body a re messy, error prone and can easily lead
+to connection confusion).
+
+As no other server we have supports this, remove the test.
+
+Reported-by: firexinghe on github
+Fixes #22280
+Closes #22291
+
+(cherry picked from commit e89d5a1202f3e00918eb0ea465041dbaa78e75c7)
+---
+ tests/data/Makefile.am |  2 +-
+ tests/data/test1701    | 82 ------------------------------------------
+ 2 files changed, 1 insertion(+), 83 deletions(-)
+ delete mode 100644 tests/data/test1701
+
+diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
+index 69bfdc9134..5a190f1fea 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -223,7 +223,7 @@ test1669 test1670 test1671 test1672 test1673 test1674 test1675 test1676 \
+ test1677                   test1680 test1681 test1682 test1683 test1684 \
+ test1685 test1686 \
+ \
+-test1700 test1701 test1702 test1703 test1704 test1705 test1706 test1707 \
++test1700          test1702 test1703 test1704 test1705 test1706 test1707 \
+ test1708 test1709 test1710 test1711 test1712 test1713 test1714 test1715 \
+ test1720 test1721 test1722 test1723 test1724 test1725 \
+ \
+diff --git a/tests/data/test1701 b/tests/data/test1701
+deleted file mode 100644
+index 50e782bed0..0000000000
+--- a/tests/data/test1701
++++ /dev/null
+@@ -1,82 +0,0 @@
+-<?xml version="1.0" encoding="US-ASCII"?>
+-<testcase>
+-<info>
+-<keywords>
+-HTTP
+-HTTP POST
+-HTTP/2
+-</keywords>
+-</info>
+-
+-# Server-side
+-<reply>
+-<data crlf="headers" nocheck="yes">
+-HTTP/1.1 200 OK
+-Date: Tue, 09 Nov 2010 14:49:00 GMT
+-Server: test-server/fake
+-Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
+-ETag: "21025-dc7-39462498"
+-Accept-Ranges: bytes
+-Content-Length: 6
+-Connection: close
+-Content-Type: text/html
+-Funny-head: yesyes
+-
+--foo-
+-</data>
+-</reply>
+-
+-# Client-side
+-<client>
+-<features>
+-h2c
+-</features>
+-<server>
+-http/2
+-</server>
+-<name>
+-HTTP/2 POST with Upgrade:
+-</name>
+-<command>
+-http://%HOSTIP:%HTTP2PORT/%TESTNUMBER --http2 -d "datatosend"
+-</command>
+-</client>
+-
+-# Verify data after the test has been "shot"
+-<verify>
+-<strip>
+-^X-Forwarded-Proto:.*
+-^Via:.*
+-</strip>
+-<protocol crlf="yes" nonewline="yes">
+-POST /%TESTNUMBER HTTP/1.1
+-Host: %HOSTIP:%HTTP2PORT
+-User-Agent: curl/%VERSION
+-Accept: */*
+-Content-Length: 10
+-Content-Type: application/x-www-form-urlencoded
+-
+-datatosend
+-</protocol>
+-<stdout crlf="headers">
+-HTTP/1.1 101 Switching Protocols
+-Connection: Upgrade
+-Upgrade: h2c
+-
+-HTTP/2 200%SP
+-date: Tue, 09 Nov 2010 14:49:00 GMT
+-last-modified: Tue, 13 Jun 2000 12:10:00 GMT
+-etag: "21025-dc7-39462498"
+-accept-ranges: bytes
+-content-length: 6
+-content-type: text/html
+-funny-head: yesyes
+-via: 1.1 nghttpx
+-
+--foo-
+-</stdout>
+-<stripfile>
+-s/^server: nghttpx.*\r?\n//
+-</stripfile>
+-</verify>
+-</testcase>

diff --git a/0006-cookie-improve-TAB-handling.patch b/0006-cookie-improve-TAB-handling.patch
new file mode 100644
index 0000000..8ada3ab
--- /dev/null
+++ b/0006-cookie-improve-TAB-handling.patch
@@ -0,0 +1,102 @@
+From 6cd74bbb75b61348f23bb2ad263e498b09dc5b90 Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Thu, 27 Aug 2026 08:33:30 +0200
+Subject: [PATCH] cookie: improve TAB handling
+
+For entries with a leading tab. Verified in test 2885.
+
+Reported-by: Stanislav Fort
+Closes #22699
+
+(cherry picked from commit 4f6aa41a0145e930e766775dbe860883d350aa0a)
+---
+ lib/cookie.c           |  2 +-
+ tests/data/Makefile.am |  2 +-
+ tests/data/test2885    | 52 ++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 54 insertions(+), 2 deletions(-)
+ create mode 100644 tests/data/test2885
+
+diff --git a/lib/cookie.c b/lib/cookie.c
+index 91dc8d5fd0..c608b90321 100644
+--- a/lib/cookie.c
++++ b/lib/cookie.c
+@@ -614,7 +614,7 @@ parse_cookie_header(struct Curl_easy *data,
+     struct Curl_str name;
+ 
+     /* we have a <name>=<value> pair or a stand-alone word here */
+-    if(!curlx_str_cspn(&ptr, &name, ";\t\r\n=")) {
++    if(!curlx_str_cspn(&ptr, &name, ";\r\n=")) {
+       struct Curl_str val;
+       bool sep = FALSE;
+       curlx_str_trimblanks(&name);
+diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
+index 5a190f1fea..17227ba369 100644
+--- a/tests/data/Makefile.am
++++ b/tests/data/Makefile.am
+@@ -272,7 +272,7 @@ test2600 test2601 test2602 test2603 test2604 test2605 \
+ test2700 test2701 test2702 test2703 test2704 test2705 test2706 test2707 \
+ test2708 test2709 test2710 test2711 test2712 test2713 test2714 test2715 \
+ test2716 test2717 test2718 test2719 test2720 test2721 test2722 test2723 \
+-\
++test2885 \
+ test3000 test3001 test3002 test3003 test3004 test3005 test3006 test3007 \
+ test3008 test3009 test3010 test3011 test3012 test3013 test3014 test3015 \
+ test3016 test3017 test3018 test3019 test3020 test3021 test3022 test3023 \
+diff --git a/tests/data/test2885 b/tests/data/test2885
+new file mode 100644
+index 0000000000..456224fdc5
+--- /dev/null
++++ b/tests/data/test2885
+@@ -0,0 +1,52 @@
++<?xml version="1.0" encoding="US-ASCII"?>
++<testcase>
++<info>
++<keywords>
++HTTP
++cookies
++</keywords>
++</info>
++
++<reply>
++<data crlf="headers">
++HTTP/1.1 200 OK
++Content-Length: 0
++Set-Cookie: thisis=SECRET;%TABSecure
++Set-Cookie: also=notab; Secure
++
++</data>
++</reply>
++
++<client>
++<features>
++cookies
++</features>
++<server>
++https
++</server>
++<name>
++Cookies with TAB before 'secure'
++</name>
++<command>
++https://cookie.example:%HTTPSPORT/%TESTNUMBER -c %LOGDIR/cookies.txt --resolve cookie.example:%HTTPSPORT:%HOSTIP --insecure
++</command>
++</client>
++
++<verify>
++<protocol crlf="headers">
++GET /%TESTNUMBER HTTP/1.1
++Host: cookie.example:%HTTPSPORT
++User-Agent: curl/%VERSION
++Accept: */*
++
++</protocol>
++<file name="%LOGDIR/cookies.txt" mode="text">
++# Netscape HTTP Cookie File
++# https://curl.se/docs/http-cookies.html
++# This file was generated by libcurl! Edit at your own risk.
++
++cookie.example%TABFALSE%TAB/%TABTRUE%TAB0%TABalso%TABnotab
++cookie.example%TABFALSE%TAB/%TABTRUE%TAB0%TABthisis%TABSECRET
++</file>
++</verify>
++</testcase>

diff --git a/0006-curl-8.21.0-CVE-2026-80229.patch b/0006-curl-8.21.0-CVE-2026-80229.patch
deleted file mode 100644
index 689f110..0000000
--- a/0006-curl-8.21.0-CVE-2026-80229.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From 2a1ab2f7c2b48e859b69e3837fe1bd9900d02ef4 Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Tue, 25 Aug 2026 11:14:30 +0200
-Subject: [PATCH 2/2] openssl: avoid conn reuse if provider is used
-
-Reported-by: Stanislav Fort
-
-Closes #22665
-
-(cherry picked from commit 7ea37abc6ac0120ba5f6d94be8d196f7cf1506bb)
----
- lib/vtls/openssl.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
-index 010bbb9825..04c554579c 100644
---- a/lib/vtls/openssl.c
-+++ b/lib/vtls/openssl.c
-@@ -3707,6 +3707,11 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx,
-           ossl_strerror(ERR_peek_error(), error_buffer, sizeof(error_buffer)));
-     return CURLE_OUT_OF_MEMORY;
-   }
-+#ifdef OPENSSL_HAS_PROVIDERS
-+  if(data->state.libctx)
-+    /* forbid connection reuse with provider/engine use */
-+    connclose(data->conn, "provider in use");
-+#endif
- 
-   if(cb_setup) {
-     result = cb_setup(cf, data, cb_user_data);
--- 
-2.55.0
-

diff --git a/0007-curl-8.21.0-CVE-2026-13608.patch b/0007-curl-8.21.0-CVE-2026-13608.patch
deleted file mode 100644
index af98be6..0000000
--- a/0007-curl-8.21.0-CVE-2026-13608.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-From 63ca1d9b811755b1362c111f5bf0d8ff68cf21b3 Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Mon, 29 Jun 2026 10:44:47 +0200
-Subject: [PATCH 1/2] openldap: handle Curl_sasl_continue() returns better
-
-Similar to how it gets treated already in other protocol handlers.
-
-Follow-up to eeca818b1e8d1e61c2d4
-
-Reported-by: Eunsoo Kim
-Closes #22213
-
-(cherry picked from commit ea71c3b6b60e563651ea8596a975aef0c8199519)
----
- lib/openldap.c | 15 +++++++++++++--
- 1 file changed, 13 insertions(+), 2 deletions(-)
-
-diff --git a/lib/openldap.c b/lib/openldap.c
-index 8ec6bb27cd..d743e55185 100644
---- a/lib/openldap.c
-+++ b/lib/openldap.c
-@@ -783,8 +783,19 @@ static CURLcode oldap_state_sasl_resp(struct Curl_easy *data,
-   }
-   else {
-     result = Curl_sasl_continue(&li->sasl, data, code, &progress);
--    if(!result && progress != SASL_INPROGRESS)
--      oldap_state(data, li, OLDAP_STOP);
-+    if(!result) {
-+      switch(progress) {
-+      case SASL_DONE:
-+        oldap_state(data, li, OLDAP_STOP);   /* Authenticated */
-+        break;
-+      case SASL_IDLE:            /* No mechanism left after cancellation */
-+        failf(data, "Authentication cancelled");
-+        result = CURLE_LOGIN_DENIED;
-+        break;
-+      default:
-+        break;
-+      }
-+    }
-   }
- 
-   if(li->servercred)
--- 
-2.56.0
-

diff --git a/0007-openssl-avoid-conn-reuse-if-provider-is-used.patch b/0007-openssl-avoid-conn-reuse-if-provider-is-used.patch
new file mode 100644
index 0000000..28af1fe
--- /dev/null
+++ b/0007-openssl-avoid-conn-reuse-if-provider-is-used.patch
@@ -0,0 +1,30 @@
+From df12b5ca0718060f7cf6a173e263d9c6319eafb0 Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Tue, 25 Aug 2026 11:14:30 +0200
+Subject: [PATCH] openssl: avoid conn reuse if provider is used
+
+Reported-by: Stanislav Fort
+
+Closes #22665
+
+(cherry picked from commit 7ea37abc6ac0120ba5f6d94be8d196f7cf1506bb)
+---
+ lib/vtls/openssl.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
+index 010bbb9825..4659cbf881 100644
+--- a/lib/vtls/openssl.c
++++ b/lib/vtls/openssl.c
+@@ -3707,6 +3707,11 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx,
+           ossl_strerror(ERR_peek_error(), error_buffer, sizeof(error_buffer)));
+     return CURLE_OUT_OF_MEMORY;
+   }
++#ifdef OPENSSL_HAS_PROVIDERS
++  if(data->state.libctx)
++    /* forbid connection reuse with provider/engine use */
++    connclose(data->conn, "provider in use");
++#endif
+ 
+   if(cb_setup) {
+     result = cb_setup(cf, data, cb_user_data);

diff --git a/0008-curl-8.21.0-CVE-2026-80230.patch b/0008-curl-8.21.0-CVE-2026-80230.patch
deleted file mode 100644
index 772bfac..0000000
--- a/0008-curl-8.21.0-CVE-2026-80230.patch
+++ /dev/null
@@ -1,65 +0,0 @@
-From 750c52af28449ba6fb094ec74697293e3c09d7b9 Mon Sep 17 00:00:00 2001
-From: Daniel Stenberg <daniel@haxx.se>
-Date: Mon, 24 Aug 2026 23:37:49 +0200
-Subject: [PATCH 2/2] openssl: no server cert is only okay if also not pinned
-
-Reported-by: Stanislav Fort
-Closes #22660
-
-(cherry picked from commit 5267ed859d545534d0c21675a2b70af5a3b6e3ef)
----
- lib/vtls/openssl.c | 26 +++++++++++++++-----------
- 1 file changed, 15 insertions(+), 11 deletions(-)
-
-diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
-index 4659cbf881..0f4123e83d 100644
---- a/lib/vtls/openssl.c
-+++ b/lib/vtls/openssl.c
-@@ -4573,21 +4573,24 @@ out:
-   return result;
- }
- 
--static CURLcode ossl_check_pinned_key(struct Curl_cfilter *cf,
--                                      struct Curl_easy *data,
--                                      X509 *server_cert)
-+static const char *pinned(struct Curl_cfilter *cf,
-+                          struct Curl_easy *data)
- {
--  const char *ptr;
--  CURLcode result = CURLE_OK;
--
-   (void)cf;
-+  return
- #ifndef CURL_DISABLE_PROXY
--  ptr = Curl_ssl_cf_is_proxy(cf) ?
-+    Curl_ssl_cf_is_proxy(cf) ?
-     data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
--    data->set.str[STRING_SSL_PINNEDPUBLICKEY];
--#else
--  ptr = data->set.str[STRING_SSL_PINNEDPUBLICKEY];
- #endif
-+    data->set.str[STRING_SSL_PINNEDPUBLICKEY];
-+}
-+
-+static CURLcode ossl_check_pinned_key(struct Curl_cfilter *cf,
-+                                      struct Curl_easy *data,
-+                                      X509 *server_cert)
-+{
-+  CURLcode result = CURLE_OK;
-+  const char *ptr = pinned(cf, data);
-   if(ptr) {
-     result = ossl_pkp_pin_peer_pubkey(data, server_cert, ptr);
-     if(result)
-@@ -4769,7 +4772,8 @@ CURLcode Curl_ossl_check_peer_cert(struct Curl_cfilter *cf,
-   server_cert = SSL_get1_peer_certificate(octx->ssl);
-   if(!server_cert) {
-     /* no verification at all, this maybe acceptable */
--    if(!(conn_config->verifypeer || conn_config->verifyhost))
-+    if(!(conn_config->verifypeer || conn_config->verifyhost) &&
-+       !pinned(cf, data))
-       goto out;
- 
-     failf(data, "SSL: could not get peer certificate");
--- 
-2.56.0
-

diff --git a/0008-openldap-handle-Curl_sasl_continue-returns-better.patch b/0008-openldap-handle-Curl_sasl_continue-returns-better.patch
new file mode 100644
index 0000000..d1acd39
--- /dev/null
+++ b/0008-openldap-handle-Curl_sasl_continue-returns-better.patch
@@ -0,0 +1,43 @@
+From c12159bf4979abe9653e39b7ae0aad9f40fd2571 Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Mon, 29 Jun 2026 10:44:47 +0200
+Subject: [PATCH] openldap: handle Curl_sasl_continue() returns better
+
+Similar to how it gets treated already in other protocol handlers.
+
+Follow-up to eeca818b1e8d1e61c2d4
+
+Reported-by: Eunsoo Kim
+Closes #22213
+
+(cherry picked from commit ea71c3b6b60e563651ea8596a975aef0c8199519)
+---
+ lib/openldap.c | 15 +++++++++++++--
+ 1 file changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/lib/openldap.c b/lib/openldap.c
+index 8ec6bb27cd..d743e55185 100644
+--- a/lib/openldap.c
++++ b/lib/openldap.c
+@@ -783,8 +783,19 @@ static CURLcode oldap_state_sasl_resp(struct Curl_easy *data,
+   }
+   else {
+     result = Curl_sasl_continue(&li->sasl, data, code, &progress);
+-    if(!result && progress != SASL_INPROGRESS)
+-      oldap_state(data, li, OLDAP_STOP);
++    if(!result) {
++      switch(progress) {
++      case SASL_DONE:
++        oldap_state(data, li, OLDAP_STOP);   /* Authenticated */
++        break;
++      case SASL_IDLE:            /* No mechanism left after cancellation */
++        failf(data, "Authentication cancelled");
++        result = CURLE_LOGIN_DENIED;
++        break;
++      default:
++        break;
++      }
++    }
+   }
+ 
+   if(li->servercred)

diff --git a/0009-openssl-no-server-cert-is-only-okay-if-also-not-pinn.patch b/0009-openssl-no-server-cert-is-only-okay-if-also-not-pinn.patch
new file mode 100644
index 0000000..d1af410
--- /dev/null
+++ b/0009-openssl-no-server-cert-is-only-okay-if-also-not-pinn.patch
@@ -0,0 +1,62 @@
+From a84b69f1c6e5ec52cf23fe2fe3390e3002257b8a Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Mon, 24 Aug 2026 23:37:49 +0200
+Subject: [PATCH] openssl: no server cert is only okay if also not pinned
+
+Reported-by: Stanislav Fort
+Closes #22660
+
+(cherry picked from commit 5267ed859d545534d0c21675a2b70af5a3b6e3ef)
+---
+ lib/vtls/openssl.c | 26 +++++++++++++++-----------
+ 1 file changed, 15 insertions(+), 11 deletions(-)
+
+diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
+index 4659cbf881..0f4123e83d 100644
+--- a/lib/vtls/openssl.c
++++ b/lib/vtls/openssl.c
+@@ -4573,21 +4573,24 @@ out:
+   return result;
+ }
+ 
+-static CURLcode ossl_check_pinned_key(struct Curl_cfilter *cf,
+-                                      struct Curl_easy *data,
+-                                      X509 *server_cert)
++static const char *pinned(struct Curl_cfilter *cf,
++                          struct Curl_easy *data)
+ {
+-  const char *ptr;
+-  CURLcode result = CURLE_OK;
+-
+   (void)cf;
++  return
+ #ifndef CURL_DISABLE_PROXY
+-  ptr = Curl_ssl_cf_is_proxy(cf) ?
++    Curl_ssl_cf_is_proxy(cf) ?
+     data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
+-    data->set.str[STRING_SSL_PINNEDPUBLICKEY];
+-#else
+-  ptr = data->set.str[STRING_SSL_PINNEDPUBLICKEY];
+ #endif
++    data->set.str[STRING_SSL_PINNEDPUBLICKEY];
++}
++
++static CURLcode ossl_check_pinned_key(struct Curl_cfilter *cf,
++                                      struct Curl_easy *data,
++                                      X509 *server_cert)
++{
++  CURLcode result = CURLE_OK;
++  const char *ptr = pinned(cf, data);
+   if(ptr) {
+     result = ossl_pkp_pin_peer_pubkey(data, server_cert, ptr);
+     if(result)
+@@ -4769,7 +4772,8 @@ CURLcode Curl_ossl_check_peer_cert(struct Curl_cfilter *cf,
+   server_cert = SSL_get1_peer_certificate(octx->ssl);
+   if(!server_cert) {
+     /* no verification at all, this maybe acceptable */
+-    if(!(conn_config->verifypeer || conn_config->verifyhost))
++    if(!(conn_config->verifypeer || conn_config->verifyhost) &&
++       !pinned(cf, data))
+       goto out;
+ 
+     failf(data, "SSL: could not get peer certificate");

diff --git a/0010-ci-setup-packit.patch b/0010-ci-setup-packit.patch
new file mode 100644
index 0000000..d79dcf9
--- /dev/null
+++ b/0010-ci-setup-packit.patch
@@ -0,0 +1,59 @@
+From f8e586dc95df632991777a7d640c29cc3ba86d08 Mon Sep 17 00:00:00 2001
+From: Jan Macku <jamacku@redhat.com>
+Date: Wed, 21 Oct 2026 09:53:07 +0200
+Subject: [PATCH] ci: setup packit
+
+inspired by systemd's .packit.yml
+
+fedora-only
+---
+ .packit.yml | 40 ++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 40 insertions(+)
+ create mode 100644 .packit.yml
+
+diff --git a/.packit.yml b/.packit.yml
+new file mode 100644
+index 0000000000..3a8b029f2b
+--- /dev/null
++++ b/.packit.yml
+@@ -0,0 +1,40 @@
++specfile_path: .packit_rpm/curl.spec
++files_to_sync:
++  - .packit.yml
++  - src: .packit_rpm/curl.spec
++    dest: curl.spec
++upstream_package_name: curl
++downstream_package_name: curl
++upstream_tag_template: curl-{version}
++srpm_build_deps: []
++
++actions:
++  get-current-version:
++    # Show the closest matching tag for the checked out revision, otherwise
++    # Packit tries to get the latest tag by creation date, which doesn't work well.
++    - "bash -ec 'git describe --tags --abbrev=0 | cut -d- -f1'"
++
++  post-upstream-clone:
++    # Use the Fedora specfile
++    - "git clone -b f45 https://src.fedoraproject.org/rpms/curl.git .packit_rpm --depth=1"
++    # Drop the "sources" file so rebase-helper doesn't think we're a dist-git
++    - "rm -fv .packit_rpm/sources"
++    # Drop all patches, since they're already included in the tarball
++    - "sed -ri '/^Patch[0-9]+:/d' .packit_rpm/curl.spec"
++    # Replace dynamic %(pkg-config ...) version macros with 0 — the
++    # specfile library's rpm.spec() call cannot evaluate %(...) shell
++    # expansions, causing Requires lines to end with bare '>='
++    - "sed -ri 's/^(%global \\S+_version )\\%\\(.*/\\1 0/' .packit_rpm/curl.spec"
++    # Drop GPG signature verification — packit generates its own tarball
++    # from git, so it will never match the upstream-signed archive
++    - "sed -ri '/gpgverify/d' .packit_rpm/curl.spec"
++
++# Available targets can be listed via `copr-cli list-chroots`
++jobs:
++- job: copr_build
++  trigger: pull_request
++  targets:
++  - fedora-45-aarch64
++  - fedora-45-ppc64le
++  - fedora-45-s390x
++  - fedora-45-x86_64

diff --git a/0011-multi-adjust-the-cleanup-order-in-multi_done.patch b/0011-multi-adjust-the-cleanup-order-in-multi_done.patch
new file mode 100644
index 0000000..b53c808
--- /dev/null
+++ b/0011-multi-adjust-the-cleanup-order-in-multi_done.patch
@@ -0,0 +1,48 @@
+From fefb1873363a79a4bdb290779cfae50bbbf17028 Mon Sep 17 00:00:00 2001
+From: Stefan Eissing <stefan@eissing.org>
+Date: Mon, 12 Oct 2026 07:40:45 +0200
+Subject: [PATCH] multi: adjust the cleanup order in multi_done
+
+Closes #23370
+
+(cherry picked from commit 8b0744af5b1b631da5b938ca31c3f9895ad5a321)
+
+Resolves: CVE-2026-92392
+---
+ lib/multi.c | 13 +++++++------
+ 1 file changed, 7 insertions(+), 6 deletions(-)
+
+diff --git a/lib/multi.c b/lib/multi.c
+index 681ed2838d..046d3ccd52 100644
+--- a/lib/multi.c
++++ b/lib/multi.c
+@@ -755,12 +755,6 @@ static CURLcode multi_done(struct Curl_easy *data,
+   /* Make sure that transfer client writes are really done now. */
+   result = Curl_1st_fatal(result, Curl_xfer_write_done(data, premature));
+ 
+-  /* Inform connection filters that this transfer is done */
+-  if(conn)
+-    Curl_conn_ev_data_done(data, premature);
+-
+-  process_pending_handles(data->multi); /* connection / multiplex */
+-
+   if(!result)
+     result = Curl_req_done(&data->req, data, premature);
+ 
+@@ -769,9 +763,16 @@ static CURLcode multi_done(struct Curl_easy *data,
+      * do with the transfer's connection. */
+     struct multi_done_ctx mdctx;
+ 
++    /* Inform connection filters that this transfer is done and they
++     * need to give up any references to `data`. */
++    Curl_conn_ev_data_done(data, premature);
++
+     memset(&mdctx, 0, sizeof(mdctx));
+     mdctx.premature = premature;
+     Curl_cpool_do_locked(data, data->conn, multi_done_locked, &mdctx);
++
++    if(data->multi)
++      process_pending_handles(data->multi); /* connection / multiplex */
+   }
+ 
+   /* flush the netrc cache */

diff --git a/0101-curl-7.32.0-multilib.patch b/0101-curl-7.32.0-multilib.patch
deleted file mode 100644
index f7f66e6..0000000
--- a/0101-curl-7.32.0-multilib.patch
+++ /dev/null
@@ -1,92 +0,0 @@
-From 6bb4e674cdc953f5c0048aa84172539900725166 Mon Sep 17 00:00:00 2001
-From: Jan Macku <jamacku@redhat.com>
-Date: Tue, 16 Dec 2025 10:04:40 +0100
-Subject: [PATCH] prevent multilib conflicts on the curl-config script
-
----
- curl-config.in      | 23 +++++------------------
- docs/curl-config.md |  4 +++-
- libcurl.pc.in       |  1 +
- 3 files changed, 9 insertions(+), 19 deletions(-)
-
-diff --git a/curl-config.in b/curl-config.in
-index a1c8185875..bb43ca8335 100644
---- a/curl-config.in
-+++ b/curl-config.in
-@@ -74,7 +74,7 @@ while test "$#" -gt 0; do
-     ;;
- 
-   --cc)
--    echo '@CC@'
-+    echo 'gcc'
-     ;;
- 
-   --prefix)
-@@ -149,16 +149,7 @@ while test "$#" -gt 0; do
-     ;;
- 
-   --libs)
--    if test "@libdir@" != '/usr/lib' && test "@libdir@" != '/usr/lib64'; then
--      curllibdir="-L@libdir@ "
--    else
--      curllibdir=''
--    fi
--    if test '@ENABLE_SHARED@' = 'no'; then
--      echo "${curllibdir}-lcurl @LIBCURL_PC_LIBS_PRIVATE@"
--    else
--      echo "${curllibdir}-lcurl"
--    fi
-+    echo '-lcurl'
-     ;;
- 
-   --ssl-backends)
-@@ -166,16 +157,12 @@ while test "$#" -gt 0; do
-     ;;
- 
-   --static-libs)
--    if test '@ENABLE_STATIC@' != 'no'; then
--      echo "@libdir@/libcurl.@libext@ @LIBCURL_PC_LDFLAGS_PRIVATE@ @LIBCURL_PC_LIBS_PRIVATE@"
--    else
--      echo 'curl was built with static libraries disabled' >&2
--      exit 1
--    fi
-+    echo 'curl was built with static libraries disabled' >&2
-+    exit 1
-     ;;
- 
-   --configure)
--    echo @CONFIGURE_OPTIONS@
-+    pkg-config libcurl --variable=configure_options | sed 's/^"//;s/"$//'
-     ;;
- 
-   *)
-diff --git a/docs/curl-config.md b/docs/curl-config.md
-index 12ad245b79..fa0e03d273 100644
---- a/docs/curl-config.md
-+++ b/docs/curl-config.md
-@@ -87,7 +87,9 @@ no, one or several names. If more than one name, they appear comma-separated.
- ## `--static-libs`
- 
- Shows the complete set of libs and other linker options you need in order to
--link your application with libcurl statically. (Added in 7.17.1)
-+link your application with libcurl statically. Note that Fedora/RHEL libcurl
-+packages do not provide any static libraries, thus cannot be linked statically.
-+(Added in 7.17.1)
- 
- ## `--version`
- 
-diff --git a/libcurl.pc.in b/libcurl.pc.in
-index c0ba5244a8..f3645e1748 100644
---- a/libcurl.pc.in
-+++ b/libcurl.pc.in
-@@ -28,6 +28,7 @@ libdir=@libdir@
- includedir=@includedir@
- supported_protocols="@SUPPORT_PROTOCOLS@"
- supported_features="@SUPPORT_FEATURES@"
-+configure_options=@CONFIGURE_OPTIONS@
- 
- Name: libcurl
- URL: https://curl.se/
--- 
-2.52.0
-

diff --git a/curl.spec b/curl.spec
index 1dd012b..f7e0baa 100644
--- a/curl.spec
+++ b/curl.spec
@@ -13,7 +13,7 @@
 Summary: A utility for getting files from remote servers (FTP, HTTP, and others)
 Name: curl
 Version: 8.21.0
-Release: 8%{?dist}
+Release: 9%{?dist}
 License: curl
 Source0: https://curl.se/download/%{name}-%{version_no_tilde}.tar.xz
 Source1: https://curl.se/download/%{name}-%{version_no_tilde}.tar.xz.asc
@@ -23,15 +23,17 @@ Source1: https://curl.se/download/%{name}-%{version_no_tilde}.tar.xz.asc
 Source2: mykey.asc
 
 # Fedora-specific
-Patch001: 0001-curl-8.21.0-lib-add-multi_wakeup_internal.patch
-Patch002: 0002-curl-8.21.0-CVE-2026-18924.patch
-Patch003: 0003-curl-8.21.0-CVE-2026-19931.patch
-Patch004: 0004-curl-8.21.0-remove-test1701.patch
-Patch005: 0005-curl-8.21.0-CVE-2026-80255.patch
-Patch006: 0006-curl-8.21.0-CVE-2026-80229.patch
-Patch007: 0007-curl-8.21.0-CVE-2026-13608.patch
-Patch008: 0008-curl-8.21.0-CVE-2026-80230.patch
-Patch101: 0101-curl-7.32.0-multilib.patch
+Patch0001: 0001-prevent-multilib-conflicts-on-the-curl-config-script.patch
+Patch0002: 0002-lib-add-multi_wakeup_internal.patch
+Patch0003: 0003-http2-make-server-push-transfers-inherit-share-from-.patch
+Patch0004: 0004-connections-use-admin-handles-only-for-maintenance.patch
+Patch0005: 0005-tests-remove-test1701.patch
+Patch0006: 0006-cookie-improve-TAB-handling.patch
+Patch0007: 0007-openssl-avoid-conn-reuse-if-provider-is-used.patch
+Patch0008: 0008-openldap-handle-Curl_sasl_continue-returns-better.patch
+Patch0009: 0009-openssl-no-server-cert-is-only-okay-if-also-not-pinn.patch
+Patch0010: 0010-ci-setup-packit.patch
+Patch0011: 0011-multi-adjust-the-cleanup-order-in-multi_done.patch
 
 Provides: curl-full = %{version}-%{release}
 # do not fail when trying to install curl-minimal after drop
@@ -482,6 +484,10 @@ rm -f ${RPM_BUILD_ROOT}%{_mandir}/man1/wcurl.1*
 %{_libdir}/libcurl.so.4.[0-9].[0-9].minimal
 
 %changelog
+* Mon Nov 02 2026 Jan Macku <jamacku@redhat.com> - 8.21.0-9
+- ci: setup packit
+- multi: adjust the cleanup order in multi_done (CVE-2026-92392)
+
 * Thu Oct 08 2026 Jan Macku <jamacku@redhat.com> - 8.21.0-8
 - fix OpenLDAP SASL authentication bypass (CVE-2026-13608)
 - fix OpenSSL pinning bypass (CVE-2026-80230)

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-03  9:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03  9:10 [rpms/curl] f45: curl-8.21.0-9 Jan Macku

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox