Skip to content

Fix ServerAcceptContext smart pointer handling and lifetime#6125

Merged
guhetier merged 1 commit into
mainfrom
guhetier/server_accept_smartptr_copilot
Jul 1, 2026
Merged

Fix ServerAcceptContext smart pointer handling and lifetime#6125
guhetier merged 1 commit into
mainfrom
guhetier/server_accept_smartptr_copilot

Conversation

@guhetier

Copy link
Copy Markdown
Collaborator

Description

ServerAcceptContext stored its connection as a raw TestConnection** and was initialized by casting a UniquePtr<TestConnection> to a raw pointer. The smart pointer was also declared after the TestListener, giving it a shorter lifetime than the listener that references it through its context.

  • Change ServerAcceptContext::NewConnection to UniquePtr<TestConnection>* and pass the smart pointer directly (no cast).
  • Manage the accepted connection through reset() in the accept callbacks instead of raw assignment/delete.
  • Move each Server declaration before its TestListener so the connection outlives the listener.

Testing

Test-only change; covered by existing handshake/data/datagram tests. Built testlib locally with no errors.

Documentation

No documentation impact.

ServerAcceptContext stored its connection as a raw TestConnection** and was initialized by casting a UniquePtr<TestConnection> to a raw pointer. The smart pointer was also declared after the TestListener, giving it a shorter lifetime than the listener that references it through its context.

- Change ServerAcceptContext::NewConnection to UniquePtr<TestConnection>* and pass the smart pointer directly (no cast).
- Manage the accepted connection through reset() in the accept callbacks instead of raw assignment/delete.
- Move each Server declaration before its TestListener so the connection outlives the listener.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@guhetier
guhetier marked this pull request as ready for review June 30, 2026 22:22
@guhetier
guhetier requested a review from a team as a code owner June 30, 2026 22:22
@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.40%. Comparing base (40f08c6) to head (41099a6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6125      +/-   ##
==========================================
- Coverage   86.03%   85.40%   -0.64%     
==========================================
  Files          60       60              
  Lines       18911    18911              
==========================================
- Hits        16271    16151     -120     
- Misses       2640     2760     +120     

☔ 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.

@guhetier
guhetier merged commit 07bbcb7 into main Jul 1, 2026
499 checks passed
@guhetier
guhetier deleted the guhetier/server_accept_smartptr_copilot branch July 1, 2026 16:59
guhetier added a commit that referenced this pull request Jul 1, 2026
Now that #6125 changed ServerAcceptContext to take a UniquePtr<TestConnection>*,
pass &Server directly instead of casting to TestConnection**.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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