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

Fix detached datachannels handling #2976

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sukunrt
Copy link
Member

@sukunrt sukunrt commented Dec 23, 2024

#2696 introduced removing datachannels from the sctptransport for better garbage collection.

That PR introduced a race condition for data channels created before connection establishment. When an out of band negotiated data channel, created before peerconnection establishment is detached, there's a race between the data channel being removed from r.dataChannels and it being copied in to the existing data channel slice in the acceptDataChannels goroutine.

This PR fixes this race by copying the slice before any datachannels could be detached.

Copy link

codecov bot commented Dec 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.90%. Comparing base (fbf79c1) to head (fb0e2a1).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2976      +/-   ##
==========================================
- Coverage   77.93%   77.90%   -0.03%     
==========================================
  Files          89       89              
  Lines       10526    10523       -3     
==========================================
- Hits         8203     8198       -5     
- Misses       1834     1837       +3     
+ Partials      489      488       -1     
Flag Coverage Δ
go 79.48% <100.00%> (-0.03%) ⬇️
wasm 63.45% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Member

@Sean-Der Sean-Der left a comment

Choose a reason for hiding this comment

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

Thank you! Mind fixing lint error and we can land :)

#2696 introduced removing
datachannels from the sctptransport for better garbage collection.

That PR introduced a race condition for data channels created before
connection establishment. When an out of band negotiated data channel,
created before peerconnection establishment is detached, there's a race
between the data channel being removed from `r.dataChannels` and it
being copied in to the existing data channel slice in the
acceptDataChannels goroutine.

This PR fixes this race by copying the slice before any datachannels
could be detached.
@sukunrt sukunrt force-pushed the sukun/detached-dc-fix branch from 32e8aaf to fb0e2a1 Compare December 24, 2024 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants