Skip to content

Commit

Permalink
Clear selected pair on ICE failed (#612)
Browse files Browse the repository at this point in the history
When ICE times out and fails, all candidates are deleted.

That means all the candidates are closed and their underlying
conns are clsoed.

But, the selected pair could still be valid. On a subsequenct
`Write`, ICE transport conn will get the selected pair and
write to the pair. As the pair is still valid, write will
flow through to the local candidate `writeTo`.

But, as all candidates and their underlying conns are closed,
`Write` will return a `io.ErrClosedPipe` error.

There are cases where it is not ignored and causes a broken
pipe after an ICERestart.

When the `Write` error propagates back to sctp/association,
the writeLoop is exited.

So, sending data channel traffic after a successful ICERestart
still fails as the SCTP association errored out and write loop exited.

I have copied the changes that are done when ICERestart happens
to when ICE state is set to failed (except for gathering state
and resetting ufrag/pwd). In my testing, it is working well,
i. e. can continue data channel after ICE Restart whereas
previously it was failing every time. But, I am not sure of all
the implications of this change.

Update authors

Update AUTHORS.txt
  • Loading branch information
boks1971 authored Sep 2, 2023
1 parent 949c2e3 commit c62fd28
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Artur Shellunts <[email protected]>
Assad Obaid <[email protected]>
Atsushi Watanabe <[email protected]>
backkem <[email protected]>
boks1971 <[email protected]>
buptczq <[email protected]>
cgojin <[email protected]>
Chao Yuan <[email protected]>
Expand Down
4 changes: 4 additions & 0 deletions agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,10 @@ func (a *Agent) updateConnectionState(newState ConnectionState) {
if a.connectionState != newState {
// Connection has gone to failed, release all gathered candidates
if newState == ConnectionStateFailed {
a.removeUfragFromMux()
a.checklist = make([]*CandidatePair, 0)
a.pendingBindingRequests = make([]bindingRequest, 0)
a.setSelectedPair(nil)
a.deleteAllCandidates()
}

Expand Down

0 comments on commit c62fd28

Please sign in to comment.