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 dropping packets immediately in mux #2814

Merged
merged 1 commit into from
Aug 2, 2024
Merged

Avoid dropping packets immediately in mux #2814

merged 1 commit into from
Aug 2, 2024

Conversation

lactyy
Copy link
Contributor

@lactyy lactyy commented Jul 19, 2024

Description

As discussed in this thread on the Gophers Slack, internal/mux needs a pending queue for packets that would dropped in some situations. (e.g. ICE transport blocks until it is in a connected state, losing any DTLS packets received in the meantime)

Sorry, I accidentally closed the issue before. I've reopened an issue with fixes.

Reference issue

N/A

Copy link

codecov bot commented Jul 19, 2024

Codecov Report

Attention: Patch coverage is 80.95238% with 4 lines in your changes missing coverage. Please review.

Project coverage is 65.06%. Comparing base (f29ef99) to head (cef9fd4).

Files Patch % Lines
internal/mux/mux.go 80.95% 3 Missing and 1 partial ⚠️

❗ There is a different number of reports uploaded between BASE (f29ef99) and HEAD (cef9fd4). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (f29ef99) HEAD (cef9fd4)
go 2 0
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #2814       +/-   ##
===========================================
- Coverage   78.92%   65.06%   -13.87%     
===========================================
  Files          89       67       -22     
  Lines        8317     3237     -5080     
===========================================
- Hits         6564     2106     -4458     
+ Misses       1276     1005      -271     
+ Partials      477      126      -351     
Flag Coverage Δ
go ?
wasm 65.06% <80.95%> (+0.17%) ⬆️

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.

@Sean-Der
Copy link
Member

Thank you @lactyy! Great to see this finally fixed.

What do you think of spawning goroutine only if something needs to go in the pending queue? When the queue is drained the routine exits

Otherwise each PeerConnection gets another goroutine that will mostly go unused. I have users report doing 10k+ on a machine, so I worry what the impact will be.

Would it be possible to add a unit test also? You could spin up some fake dispatch and confirm that it gets the packet eventually.

@lactyy
Copy link
Contributor Author

lactyy commented Jul 26, 2024

Hello, @Sean-Der! Sorry for the late response, was this okay? I changed some of the code and added a unit test.

Buffer a small amount of packets in the internal/mux to allow remotes to
send DTLS traffic before ICE has completed
@Sean-Der Sean-Der merged commit cbe3465 into pion:master Aug 2, 2024
15 checks passed
@Sean-Der
Copy link
Member

Sean-Der commented Aug 2, 2024

Hey @lactyy mind trying this again now that it is merged!

I instead process the queue w/e a new dispatch is added. I set a limit of 15 packets (but we can raise it!)

@lactyy
Copy link
Contributor Author

lactyy commented Aug 2, 2024

Hello @Sean-Der, I can confirm this has been fixed in the latest commit. thank you!

@Sean-Der
Copy link
Member

Sean-Der commented Aug 2, 2024

Thank you for opening the PR @lactyy! I am sure that bothered lots of people, but they never put the time in to help out :)

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