-
Notifications
You must be signed in to change notification settings - Fork 79
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
set close state before unregisterStream #350
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #350 +/- ##
=======================================
Coverage 81.17% 81.18%
=======================================
Files 51 51
Lines 3347 3348 +1
=======================================
+ Hits 2717 2718 +1
Misses 484 484
Partials 146 146
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
de94b90
to
b97aee4
Compare
b97aee4
to
de3c406
Compare
When does this happen? |
In the particular real case I noticed, a DTLS CloseNotify was received which closes the DTLS Conn decryption channel which sets all Reads to be EOFs. That is then received by the SCTP Assocation's readLoop and it unrolls from there. |
I think this change is fine. I believe the case you're mentioning happens when we close a webrtc connection and pion/webrtc closes the peerconnection by closing the DTLS connection and doesn't send a SCTP Abort chunk as the specs recommend:
|
Wrote my reply too soon :). Yes, you're correct. I think due to DTLS being unordered, there's a chance we can still get that notification even if the SCTP abort is sent. There's also the case of bad implementations cause this race to happen as well. |
Although
OpenStream
checks state before creating a stream,readLoop
'sunregisterStream
can be called outside of a directClose
. When this happens,setState(closed)
happens after unregisterStream which is an incorrect ordering causing anOpenStream
to proceed. readLoop should set the closed state prior to unregistering streams.Repro with carefully placed sleeps to mimic an internal close of connections being closed: