Fix MessageChannel leaks (#646)

This commit is contained in:
David Zhao
2022-04-22 10:53:20 -07:00
committed by GitHub
parent 2e182afb61
commit b7d22c4f34
8 changed files with 161 additions and 117 deletions
+19 -9
View File
@@ -102,15 +102,25 @@ func (r *LocalRouter) StartParticipantSignal(ctx context.Context, roomName livek
reqChan = r.getOrCreateMessageChannel(r.requestChannels, string(key))
resChan = r.getOrCreateMessageChannel(r.responseChannels, string(key))
r.onNewParticipant(
ctx,
roomName,
pi,
// request source
reqChan,
// response sink
resChan,
)
go func() {
err := r.onNewParticipant(
ctx,
roomName,
pi,
// request source
reqChan,
// response sink
resChan,
)
if err != nil {
reqChan.Close()
resChan.Close()
logger.Errorw("could not handle new participant", err,
"room", roomName,
"participant", pi.Identity,
)
}
}()
return livekit.ConnectionID(pi.Identity), reqChan, resChan, nil
}