Skip to content

Commit

Permalink
move OnClose back to defer, need to deal with race differently
Browse files Browse the repository at this point in the history
  • Loading branch information
boks1971 committed Nov 20, 2023
1 parent 0e1c8fe commit 9a727bc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions signalclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,6 @@ func (c *SignalClient) Close() {
if isStarted {
<-c.readerClosedCh
}
if conn != nil && c.OnClose != nil {
c.OnClose()
}
}

func (c *SignalClient) SendICECandidate(candidate webrtc.ICECandidateInit, target livekit.SignalTarget) error {
Expand Down Expand Up @@ -352,6 +349,10 @@ func (c *SignalClient) readWorker() {
c.isStarted.Store(false)
c.conn.Store(nil)
close(c.readerClosedCh)

if c.OnClose != nil {
c.OnClose()
}
}()
if pending := c.pendingResponse; pending != nil {
c.handleResponse(pending)
Expand Down

0 comments on commit 9a727bc

Please sign in to comment.