-
Notifications
You must be signed in to change notification settings - Fork 618
Fix Rust connection callback context cleanup and add regression test #5618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@microsoft-github-policy-service agree |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5618 +/- ##
=======================================
Coverage ? 85.28%
=======================================
Files ? 60
Lines ? 18663
Branches ? 0
=======================================
Hits ? 15917
Misses ? 2746
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| } | ||
| } | ||
| // Context already cleaned (e.g. after ShutdownComplete). Nothing to do. | ||
| None => StatusCode::QUIC_STATUS_SUCCESS.into(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this scenario is possible assuming the logic is sound. ShutdownComplete is the last event delivered to an application by MsQuic (see QUIC_CONNECTION_EVENT.md), and the rust wrapper own the context so it should never be freed before ShutdownComplete.
We can expect it to be present, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review! I found a case where the context can be None:
When Connection::drop() is called from outside the callback (e.g., after transferring ownership via a channel), close_inner() does:
take_callback_ctx()→ context becomesnullConnectionClose()→ MsQuic triggersShutdownCompletesynchronously before returning- The callback is invoked with a
nullcontext
This is demonstrated in the test where we drop(server_conn) from the main thread. Should we:
- Keep handling
Noneto support both patterns (close from callback vs close from outside)? - Or change
close_inner()to drop the context after the handle is fully closed?
I lean towards option 2, dropping the context after ConnectionClose() returns would ensure the callback always has a valid context, and expect() would be safe. This also aligns better with your expectation that ShutdownComplete always has a context. What do you think?
… None context case
Description
Closes: #5520
Testing
Testing
Documentation
Is there any documentation impact for this change?