Skip to content
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

Streams Hold References on Connections #3931

Merged
merged 2 commits into from
Oct 24, 2023
Merged

Conversation

nibanks
Copy link
Member

@nibanks nibanks commented Oct 19, 2023

Description

Make sure to keep the connection alive as long as the stream.

Testing

CI/CD

Documentation

N/A

@nibanks nibanks requested a review from a team as a code owner October 19, 2023 18:47
@codecov
Copy link

codecov bot commented Oct 19, 2023

Codecov Report

Merging #3931 (2034f03) into main (81858e4) will decrease coverage by 0.02%.
Report is 5 commits behind head on main.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #3931      +/-   ##
==========================================
- Coverage   86.62%   86.60%   -0.02%     
==========================================
  Files          56       56              
  Lines       16889    16893       +4     
==========================================
+ Hits        14630    14631       +1     
- Misses       2259     2262       +3     
Files Coverage Δ
src/core/connection.c 81.76% <100.00%> (+0.17%) ⬆️
src/core/connection.h 97.23% <ø> (-1.66%) ⬇️
src/core/stream.c 89.79% <100.00%> (-1.00%) ⬇️

... and 17 files with indirect coverage changes

@ManickaP
Copy link
Member

Does this mean that we don't have to keep connection alive anymore until all streams are closed?

Because we have stream ref counting which holds back ConnectionClose call until the count is 0.

@nibanks
Copy link
Member Author

nibanks commented Oct 20, 2023

Does this mean that we don't have to keep connection alive anymore until all streams are closed?

Because we have stream ref counting which holds back ConnectionClose call until the count is 0.

Not necessarily. At least not with just this PR. We might end up going that direction (especially if you really want/need it), but right now, we're working on solving a very small race edge case where even if you close a stream and then the connection (all on the QUIC callback) while you were calling send on your thread, it's possible for MsQuic to use-after-free. We've only seen this with SMB in extremely rare cases; and we're trying to fix it.

FYI, this PR as it stands right now though, is causing deadlocks. 😦 We need to fix this first, but I think once it is fixed, it'd be easy enough to support closing in different orders.

@ManickaP
Copy link
Member

Oh, I see, thanks for the explanation. We don't need it as we do have a working solution. I just got excited, because it would simplified our code a little.

@nibanks nibanks added the Area: Core Related to the shared, core protocol logic label Oct 20, 2023
Copy link
Contributor

@ProjectsByJackHe ProjectsByJackHe left a comment

Choose a reason for hiding this comment

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

All tests pass except for a handshake test, but its testing using some randomness and this PR doesn't directly impact handshakes, so LGTM!

@nibanks nibanks merged commit 102a491 into main Oct 24, 2023
397 of 399 checks passed
@nibanks nibanks deleted the nibanks/stream-conn-ref branch October 24, 2023 11:57
ami-GS added a commit that referenced this pull request Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Core Related to the shared, core protocol logic
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants