Handle Close() correctly to cause EOF on remote #44
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This fixes the follow (related) problems:
(1) Bug with a comparison between senderLastTSN and peerLastTSN.
(2) for loop inside stream.ReadSCTP() has a multiple of lock/unlock phases, which is causing s.readErr was evaluated before checking reassembly queue when it acquires a lock again. Consequently, io.EOF was returned when there's a data in the reassembly queue.
(3) Related to (2), the condition variable was not associated with the mutex. Probably this is why multiple of lock/unlock were needed. (at least, read from the queue and evaluate error when no data, has to be atomic!)
(4) When sender side closes a stream and sends a reset, if there’s a DATA chunk in the pending queue (TSN not assigned yet), the data will be lost.
(5) There is only one instance of paramOutgoingResetRequest and chunkReconfig at a time. Therefore, it would not work if there are multiple streams and they are resetting at the same time (with different TSN).
Please see pion/webrtc#652 for more details
Reference issue
Fixes pion/webrtc#652