Skip to content

Prevent sending CONN_CLOSE when closing the connection silently#5522

Merged
guhetier merged 3 commits intomainfrom
guhetier/conn_close_on_silent
Oct 20, 2025
Merged

Prevent sending CONN_CLOSE when closing the connection silently#5522
guhetier merged 3 commits intomainfrom
guhetier/conn_close_on_silent

Conversation

@guhetier
Copy link
Collaborator

@guhetier guhetier commented Oct 15, 2025

Description

This fixes an intermittent test failure due to connection being able to send a CONN_CLOSE frame after being silently closed.
This was a regression introduce by #5107.

If a connection was closed locally with the "silent" flag, it would still send a CONN_CLOSE frame when receiving a frame from the peer.
This fix prevents this behavior in a generic way by adding a check when adding send flags.

This minimal fix needs to be backported to v2.5.
A follow up PR with a refactoring of the connection close state will follow.

Testing

Already covered.

Documentation

N/A

@codecov
Copy link

codecov bot commented Oct 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.65%. Comparing base (8eb3104) to head (55eb64e).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5522   +/-   ##
=======================================
  Coverage   84.65%   84.65%           
=======================================
  Files          59       59           
  Lines       18621    18623    +2     
=======================================
+ Hits        15763    15765    +2     
  Misses       2858     2858           

☔ View full report in Codecov by Sentry.
📢 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 marked this pull request as ready for review October 17, 2025 16:20
@guhetier guhetier requested a review from a team as a code owner October 17, 2025 16:20
@guhetier guhetier requested a review from anrossi October 17, 2025 16:33
if ((ClosedRemotely && Connection->State.ClosedRemotely) ||
(!ClosedRemotely && Connection->State.ClosedLocally)) {
//
// Already closed.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to set ClosedSilently if the connection is already closed? Is it required?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. We could be in "closing" state, and be sending CONN_CLOSE frames as the answer to any incoming packet, which we should stop doing when we get a second "silent" close.

I am not sure when potentially get a second close, but the code below makes it clear it can happen.

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to provide a specific high-level example scenario where that behavior is expected or required, but I can take on face value that a connection may "close" gracefully in some context, and then decide it wants to more forcefully ("silently") close.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll add that in the follow up refactor PR I am working on.
My best guess is that it could happen if we have a protocol error causing a silent close right after an application close.

@guhetier guhetier merged commit bb6ad40 into main Oct 20, 2025
467 checks passed
@guhetier guhetier deleted the guhetier/conn_close_on_silent branch October 20, 2025 16:26
guhetier added a commit that referenced this pull request Oct 20, 2025
* Prevent sending CONN_CLOSE when closing the connection silently
* Update clog
guhetier added a commit that referenced this pull request Oct 21, 2025
…ntly (#5522) (#5532)

* Prevent sending CONN_CLOSE when closing the connection silently (#5522)
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