mirror of
https://github.com/livekit/livekit.git
synced 2026-08-29 03:18:47 +00:00
leave signal context open after stream closes (#1887)
This commit is contained in:
+5
-14
@@ -133,17 +133,6 @@ func (r *signalService) RelaySignal(stream psrpc.ServerStream[*rpc.RelaySignalRe
|
||||
"connID", ss.ConnectionId,
|
||||
)
|
||||
|
||||
// copy the context to prevent a race between the session handler closing
|
||||
// and the delivery of any parting messages from the client. take care to
|
||||
// copy the incoming rpc headers to avoid dropping any session vars.
|
||||
ctx, cancel := context.WithCancel(metadata.NewContextWithIncomingHeader(context.Background(), metadata.IncomingHeader(stream.Context())))
|
||||
|
||||
// wait until room setup finishes to cancel the session context even if the
|
||||
// stream has closed. this is required to complete setup i/o after room api
|
||||
// has discarded the temp client.
|
||||
sessionHandlerDone := make(chan struct{})
|
||||
defer close(sessionHandlerDone)
|
||||
|
||||
sink := routing.NewSignalMessageSink(routing.SignalSinkParams[*rpc.RelaySignalResponse, *rpc.RelaySignalRequest]{
|
||||
Logger: l,
|
||||
Stream: stream,
|
||||
@@ -163,11 +152,13 @@ func (r *signalService) RelaySignal(stream psrpc.ServerStream[*rpc.RelaySignalRe
|
||||
l.Infow("signal stream closed", "error", err)
|
||||
|
||||
reqChan.Close()
|
||||
|
||||
<-sessionHandlerDone
|
||||
cancel()
|
||||
}()
|
||||
|
||||
// copy the context to prevent a race between the session handler closing
|
||||
// and the delivery of any parting messages from the client. take care to
|
||||
// copy the incoming rpc headers to avoid dropping any session vars.
|
||||
ctx := metadata.NewContextWithIncomingHeader(context.Background(), metadata.IncomingHeader(stream.Context()))
|
||||
|
||||
err = r.sessionHandler(ctx, livekit.RoomName(ss.RoomName), *pi, livekit.ConnectionID(ss.ConnectionId), reqChan, sink)
|
||||
if err != nil {
|
||||
l.Errorw("could not handle new participant", err)
|
||||
|
||||
Reference in New Issue
Block a user