Skip to content

feat: add CurlShare to share DNS/TLS caches across session threads - #775

Open
dokson wants to merge 1 commit into
lexiforest:mainfrom
dokson:feature/curl-share
Open

feat: add CurlShare to share DNS/TLS caches across session threads#775
dokson wants to merge 1 commit into
lexiforest:mainfrom
dokson:feature/curl-share

Conversation

@dokson

@dokson dokson commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Adds CurlShare (wrapper over libcurl's curl_share_setopt) and a curl_share= arg on Session/AsyncSession, to share the DNS and TLS session caches across a session's thread-local handles.

Per the share docs, libcurl doesn't support sharing the connection cache between concurrent threads, so it's not shared by default: CurlShare(connect=True) opts in, for serialized use only. duphandle() doesn't inherit CURLOPT_SHARE, so it's re-attached (covers streaming/ws). Docs explain why connection pooling stays per-thread.

Checklist

  • I have manually reviewed the changes and fully understand the code.

@dokson
dokson force-pushed the feature/curl-share branch from 2553ca8 to cc83245 Compare June 7, 2026 09:17
@dokson dokson closed this Jun 7, 2026
@dokson dokson reopened this Jun 7, 2026
@dokson
dokson force-pushed the feature/curl-share branch from cc83245 to a09627e Compare June 14, 2026 11:15
Adds a CurlShare wrapper over libcurl's share interface (curl_share_*) and a
curl_share= parameter on Session and AsyncSession. Attaching a share lets the
session handles reuse the DNS and TLS session caches across threads, cutting
DNS lookups and TLS handshakes when reconnecting to the same host.

Connection-cache sharing is opt-in (CurlShare(connect=True)) and only safe for
serialized use, since libcurl does not support sharing connections between
concurrent threads. The docs explain why connection pooling stays per-thread.
@dokson
dokson force-pushed the feature/curl-share branch from a09627e to 100d4f7 Compare June 14, 2026 11:16
@lexiforest lexiforest added this to the v0.17 milestone Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants