-
Notifications
You must be signed in to change notification settings - Fork 56
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
Make read notify use sync.Cond instead of chan #304
Conversation
Note: This adds more allocs (per test). I'm not sure that truly matters. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #304 +/- ##
==========================================
+ Coverage 83.08% 83.24% +0.15%
==========================================
Files 39 39
Lines 2726 2751 +25
==========================================
+ Hits 2265 2290 +25
+ Misses 335 334 -1
- Partials 126 127 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
1c4dd6e
to
4d3a2f6
Compare
b10f7e8
to
9c247b8
Compare
the races should be sorted by the recent set of changes. this proposal ads significant complexity and overhead with no clear benefit. composing channel reads is a lot easier than juggling multiple synchronization primitives. to use a cond we would have to either make changes to |
The race that is fixed is one present in #299 where a read is missed. The recent set of changes fixed the closing case (so, all future reads are satisfied). The same critical section /~https://github.com/pion/transport/blob/master/packetio/buffer.go#L262-L264 still has an issue with concurrent readers. I'll revise this into something simpler hopefully, but it needs to be addressed. |
concurrent reads work as expected now. if there is more than one goroutine waiting in the read loop one makes progress after each write and when the buffer closes they both exit. |
We've hit a few cases where using a channel as a notify mechanism is subject to races when we are running multi consumer multi producer scenarios. A sync.Cond is more suitable for this given we can properly broadcast when read deadlines are hit, which this change supports.
I thought we were there with d55a60c but it then revealed #299 where reads can miss an event which is especially pertinent in the simulcast probing test.
Fixes: #299