diff options
| author | Dan Engelbrecht <[email protected]> | 2026-05-04 22:37:09 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2026-05-04 22:37:09 +0200 |
| commit | ae745c4e90500f827ec83ce238a22d10ec1ea74d (patch) | |
| tree | d6e7e11f61ca5c3f54d3afb3fa23b44bb62e6c16 /src/zenhttp/clients/httpclientcurl.cpp | |
| parent | zenhttp improvements (robustness / correctness) (#968) (diff) | |
| download | archived-zen-ae745c4e90500f827ec83ce238a22d10ec1ea74d.tar.xz archived-zen-ae745c4e90500f827ec83ce238a22d10ec1ea74d.zip | |
watchdog ephemeral port exhaust (#1022)
- Improvement: Hub pools HTTP connections to managed instances so provision/deprovision churn no longer exhausts Windows ephemeral ports
Diffstat (limited to 'src/zenhttp/clients/httpclientcurl.cpp')
| -rw-r--r-- | src/zenhttp/clients/httpclientcurl.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/zenhttp/clients/httpclientcurl.cpp b/src/zenhttp/clients/httpclientcurl.cpp index eee80c269..02dd361b2 100644 --- a/src/zenhttp/clients/httpclientcurl.cpp +++ b/src/zenhttp/clients/httpclientcurl.cpp @@ -15,6 +15,7 @@ #include <zencore/session.h> #include <zencore/stream.h> #include <zencore/string.h> +#include <zenhttp/httpclientshare.h> #include <zenhttp/packageformat.h> #include <algorithm> @@ -558,6 +559,27 @@ CurlHttpClient::AllocSession(std::string_view ResourcePath, const KeyValueMap& P curl_easy_reset(Handle); } + // Share must be applied after both fresh init and reset (reset clears all + // options including the share binding). MAXAGE_CONN bounds how long a + // stale entry to a deprovisioned instance can survive in the share. + // Note: when CURL_LOCK_DATA_CONNECT is shared, libcurl ignores the + // per-easy-handle CURLOPT_MAXCONNECTS - the share owns the cache size. + if (m_ConnectionSettings.OptionalShare) + { + const CURLcode ShareCode = curl_easy_setopt(Handle, CURLOPT_SHARE, m_ConnectionSettings.OptionalShare->Native()); + if (ShareCode != CURLE_OK) + { + ZEN_WARN("CURLOPT_SHARE failed: {} ({}); falling back to per-handle connection cache", + curl_easy_strerror(ShareCode), + static_cast<int>(ShareCode)); + } + const CURLcode AgeCode = curl_easy_setopt(Handle, CURLOPT_MAXAGE_CONN, 60L); + if (AgeCode != CURLE_OK) + { + ZEN_WARN("CURLOPT_MAXAGE_CONN failed: {} ({})", curl_easy_strerror(AgeCode), static_cast<int>(AgeCode)); + } + } + // Unix domain socket if (!m_ConnectionSettings.UnixSocketPath.empty()) { |