Skip to content

Commit

Permalink
use stoppable workers to stop answerer
Browse files Browse the repository at this point in the history
  • Loading branch information
bashar-515 committed Jan 14, 2025
1 parent 69619cf commit f3fd1b8
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions rpc/wrtc_signaling_answerer.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,7 @@ func (ans *webrtcSignalingAnswerer) Stop() {
ans.startStopMu.Lock()
defer ans.startStopMu.Unlock()

// Code adding workers must atomically check the `closeCtx` before adding to the `bgWorkers`
// wait group. Canceling the context must not split those two operations. We ensure this
// atomicity by acquiring the `bgWorkersMu` write lock.
ans.bgWorkersMu.Lock()
ans.cancelBgWorkers()
// Background workers require the `bgWorkersMu`. Release the mutex before calling `Wait`.
ans.bgWorkersMu.Unlock()
ans.bgWorkers.Wait()
ans.sw.Stop()

ans.connMu.Lock()
defer ans.connMu.Unlock()
Expand Down

0 comments on commit f3fd1b8

Please sign in to comment.