Skip to content

feat: add Client::duplicate - #325

Open
larseggert wants to merge 11 commits into
mainfrom
client-duplicate
Open

larseggert wants to merge 11 commits into
mainfrom
client-duplicate

Conversation

@larseggert

@larseggert larseggert commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Adds Client::duplicate(), which uses SSL_ImportFD to create a new client with the same TLS configuration and no handshake state, e.g. for restarting a connection after Version Negotiation. The duplicate rebinds the callbacks and extension handlers NSS copies, and starts without resumption tokens. Requires the NSS fix for bug 2086988.

Two tests fail until NSS ships the fix for bug 2086988.
It creates a new client with the same TLS configuration and no handshake state, e.g. to restart after Version Negotiation.
Copilot AI balanced review requested due to automatic review settings October 30, 2026 07:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@codspeed

codspeed Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 1 benchmark is dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 186 untouched benchmarks


Comparing client-duplicate (d5131b3) with main (f98228f)

Open in CodSpeed

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No whole-change observations.

Comment thread src/agent.rs Resolved
Copilot AI balanced review requested due to automatic review settings October 30, 2026 07:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No findings.

Comment thread src/agent.rs Resolved
Copilot AI balanced review requested due to automatic review settings November 6, 2026 06:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Duplicated clients inherit shared mutable extension handlers, allowing their handshakes to alter the original client's negotiation state instead of starting with no handlers.

1 open issue

Review effort: Balanced

Comment thread src/agent.rs Resolved

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No findings.

Copilot AI balanced review requested due to automatic review settings November 6, 2026 09:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The duplication tests only verify an empty queue when the source has no tokens, so they could miss received tickets being incorrectly copied to a duplicate.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread tests/agent.rs Resolved

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No findings.

@Frosne

Frosne commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

https://bugzilla.mozilla.org/show_bug.cgi?id=2086988 TLS part is landed, I kept the bug opened in order to address the DTLS part

Comment thread src/agent.rs
/// # Errors
///
/// Errors returned if the client was closed, or if the socket can't be created or configured.
pub fn duplicate(&self) -> Res<Self> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am curious if you'd benefit from smth like

#define SSL_ResetCallbacks(fd)                 \
    SSL_EXPERIMENTAL_API("SSL_ResetCallbacks", \
                         (PRFileDesc * _fd), (fd))

@Frosne Frosne Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah but it could be used only for a duplication, so we can just implement a SSL_ImportFDConfig (or give it a better name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something in this shape:

static void
ssl_ResetAppCallbacks(sslSocket *ss)
{
    ss->alertReceivedCallback = NULL;
    ss->alertReceivedCallbackArg = NULL;
   {...}
}

SECStatus
SSLExp_ImportFDConfig(PRFileDesc *model, PRFileDesc *fd, PRFileDesc **out)
{
    sslSocket *ms = ssl_FindSocket(model);
    PRFileDesc *imported = ssl_ImportFD(model, fd, ms->protocolVariant);
    ResetAppCallbacks(imported);
    out = imported; 
    return SECSuccess;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok!

Copilot AI balanced review requested due to automatic review settings November 23, 2026 15:03

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No findings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The regression test uses a fresh client, leaving unverified that duplication excludes existing resumption tickets and requires a full handshake when the source has resumption enabled.

2 open issues

Review effort: Balanced

Comment thread src/agent.rs Resolved
@codecov-commenter

codecov-commenter commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.71930% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.45%. Comparing base (e22ba15) to head (d5131b3).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
src/agent.rs 87.03% 1 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #325      +/-   ##
==========================================
+ Coverage   75.89%   76.45%   +0.56%     
==========================================
  Files          28       28              
  Lines        3423     3479      +56     
  Branches     3423     3479      +56     
==========================================
+ Hits         2598     2660      +62     
+ Misses        608      599       -9     
- Partials      217      220       +3     
Flag Coverage Δ
freebsd ?
linux 76.42% <87.71%> (+0.56%) ⬆️
macos 76.42% <87.71%> (+0.56%) ⬆️
windows 76.44% <87.71%> (+0.56%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No findings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed because the tests do not verify that a duplicate completes its handshake and receives both secrets after the original is dropped with callbacks already installed.

2 open issues

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 23, 2026 15:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human verification is needed to confirm the minimum supported NSS 3.134 includes the bug 2086988 fix and validate cloned callback lifetimes across handshake modes and drop orders.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No findings.

@larseggert
larseggert requested review from Frosne and martinthomson and a balanced review from Copilot November 23, 2026 15:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The snapshot cannot establish whether NSS 3.134 includes the fix for bug 2086988 or whether callback lifetimes remain safe across socket duplication and drop-order cases.

No open issues 🎉

Review effort: Balanced

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No findings.

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.

5 participants