Skip to content

Conversation

@cjen1-msft
Copy link
Contributor

Per the mailing list: https://curl.se/mail/lib-2020-01/0015.html
Curl easy handles will try to reuse the SSL sessions etc that already exist.

This PR makes the snapshot fetching use a single curl_easy handle, and thus where possible (no disconnects etc) it should reuse the same session for subsequent connections to the same host.

We shouldn't need to use the CURL_LOCK_DATA_SSL_SESSION as, afaict that applies to multiple easy handles.

@cjen1-msft cjen1-msft requested a review from a team as a code owner September 30, 2025 10:38
@cjen1-msft cjen1-msft marked this pull request as draft September 30, 2025 10:48
@cjen1-msft
Copy link
Contributor Author

I think from this log we can conclude that it is reusing connections:

*   Trying 127.189.138.158:34139...
* ALPN: curl offers h2,http/1.1
*  CAfile: service_cert.pem
*  CApath: /etc/ssl/certs
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 / secp521r1 / id-ecPublicKey
* ALPN: server accepted http/1.1
* Server certificate:
*  subject: CN=CCF Node
*  start date: Sep 30 16:24:21 2025 GMT
*  expire date: Oct  1 16:24:20 2025 GMT
*  subjectAltName: host "127.189.138.158" matched cert's IP address!
*  issuer: CN=CCF Test Service
*  SSL certificate verify ok.
*   Certificate level 0: Public key type EC/secp384r1 (384/192 Bits/secBits), signed using ecdsa-with-SHA384
*   Certificate level 1: Public key type EC/secp384r1 (384/192 Bits/secBits), signed using ecdsa-with-SHA384
* Connected to 127.189.138.158 (127.189.138.158) port 34139
* using HTTP/1.x
> HEAD /node/snapshot HTTP/1.1
Host: 127.189.138.158:34139
Accept: */*

* Request completely sent off
< HTTP/1.1 308 PERMANENT_REDIRECT
< content-length: 0
< location: /node/snapshot/snapshot_46_50.committed
< 
* Connection #0 to host 127.189.138.158 left intact
* Re-using existing connection with host 127.189.138.158
> HEAD /node/snapshot/snapshot_46_50.committed HTTP/1.1
Host: 127.189.138.158:34139
Accept: */*

* Request completely sent off
< HTTP/1.1 200 OK
< accept-ranges: bytes
< content-length: 82516
< 
* Connection #0 to host 127.189.138.158 left intact
* Re-using existing connection with host 127.189.138.158
> GET /node/snapshot/snapshot_46_50.committed HTTP/1.1
Host: 127.189.138.158:34139
Accept: */*
Range: bytes=0-82516

* Request completely sent off
< HTTP/1.1 206 PARTIAL_CONTENT
< accept-ranges: bytes
< content-length: 82516
< content-range: bytes 0-82516/82516
< content-type: application/octet-stream
< 
* Connection #0 to host 127.189.138.158 left intact

@cjen1-msft cjen1-msft marked this pull request as ready for review September 30, 2025 16:34
@achamayou achamayou enabled auto-merge October 3, 2025 08:30
@achamayou achamayou added auto-backport Automatically backport this PR to LTS branch 6.x-todo PRs which should be backported to 6.x labels Oct 3, 2025
@achamayou achamayou added this pull request to the merge queue Oct 3, 2025
Merged via the queue into microsoft:main with commit a9da025 Oct 3, 2025
45 checks passed
@achamayou achamayou deleted the fetch-sessions branch October 3, 2025 09:54
achamayou added a commit to achamayou/CCF that referenced this pull request Oct 8, 2025
achamayou added a commit that referenced this pull request Oct 9, 2025
@achamayou achamayou added the backported This PR was successfully backported to LTS branch label Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.x-todo PRs which should be backported to 6.x auto-backport Automatically backport this PR to LTS branch backported This PR was successfully backported to LTS branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants