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

avoid lock contention when accepting new connections #4313

Merged
merged 2 commits into from
Feb 9, 2024

Conversation

marten-seemann
Copy link
Member

The server used to hold the packet handler map's lock while creating the connection struct for a newly accepted connection. This was intended to make sure that no two connections with the same Destination Connection ID could be created.

This is a corner case: it can only happen if two Initial packets with the same Destination Connection ID are received at the same time. If the second one is received after the first one has already been processed, it would be routed to the first connection. We don't need to optimized for this corner case. It's ok to create a new connection in that case, and immediately close it if this collision is detected.

The server used to hold the packet handler map's lock while creating the
connection struct for a newly accepted connection. This was intended to
make sure that no two connections with the same Destination Connection
ID could be created.

This is a corner case: it can only happen if two Initial packets with
the same Destination Connection ID are received at the same time. If
the second one is received after the first one has already been
processed, it would be routed to the first connection. We don't need to
optimized for this corner case. It's ok to create a new connection in
that case, and immediately close it if this collision is detected.
Copy link

codecov bot commented Feb 7, 2024

Codecov Report

Attention: 13 lines in your changes are missing coverage. Please review.

Comparison is base (c22a3c8) 84.15% compared to head (11fe0f7) 84.17%.
Report is 3 commits behind head on master.

Files Patch % Lines
server.go 75.00% 11 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4313      +/-   ##
==========================================
+ Coverage   84.15%   84.17%   +0.03%     
==========================================
  Files         150      150              
  Lines       15368    15374       +6     
==========================================
+ Hits        12932    12941       +9     
+ Misses       1938     1933       -5     
- Partials      498      500       +2     

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

@marten-seemann marten-seemann added this to the v0.42 milestone Feb 7, 2024
server.go Outdated Show resolved Hide resolved
@marten-seemann marten-seemann merged commit 8e93770 into master Feb 9, 2024
34 checks passed
@marten-seemann marten-seemann deleted the connection-creation-contention branch February 9, 2024 04:55
mgjeong pushed a commit to mgjeong/quic-go that referenced this pull request Feb 13, 2024
* avoid lock contention when accepting new connections

The server used to hold the packet handler map's lock while creating the
connection struct for a newly accepted connection. This was intended to
make sure that no two connections with the same Destination Connection
ID could be created.

This is a corner case: it can only happen if two Initial packets with
the same Destination Connection ID are received at the same time. If
the second one is received after the first one has already been
processed, it would be routed to the first connection. We don't need to
optimized for this corner case. It's ok to create a new connection in
that case, and immediately close it if this collision is detected.

* only pass 0-RTT to the connection if it was actually accepted
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.

None yet

2 participants