Skip to content

Commit

Permalink
fix afterClosed call more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohan Totting committed Jun 14, 2024
1 parent 635db69 commit 787cb1e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1034,10 +1034,14 @@ func (c *Client) processPendingTracks() {

// make sure to call this when client's done to clean everything
func (c *Client) afterClosed() {
c.mu.Lock()
state := c.state.Load()
if state != ClientStateEnded {
c.state.Store(ClientStateEnded)
if state == ClientStateEnded {
return
}
c.mu.Unlock()

c.state.Store(ClientStateEnded)

c.internalDataChannel.Close()

Expand Down

0 comments on commit 787cb1e

Please sign in to comment.