fix hanging goroutine
This commit is contained in:
@ -119,7 +119,12 @@ func (signalingServer SignalingServer) handleRedisPubSub(ctx context.Context, na
|
|||||||
}
|
}
|
||||||
|
|
||||||
ch := pubsub.Channel()
|
ch := pubsub.Channel()
|
||||||
for msg := range ch {
|
for {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return nil
|
||||||
|
case msg := <-ch:
|
||||||
|
|
||||||
switch msg.Channel {
|
switch msg.Channel {
|
||||||
case signalingServer.redisKeyPrefix + ":" + room + ":discover":
|
case signalingServer.redisKeyPrefix + ":" + room + ":discover":
|
||||||
if err := stream.Send(&proto.SignalingMessage{
|
if err := stream.Send(&proto.SignalingMessage{
|
||||||
@ -175,6 +180,7 @@ func (signalingServer SignalingServer) handleRedisPubSub(ctx context.Context, na
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user