Swap result sink atomically rather than closing and setting. (#4216)

To prevent WriteMessage after Close potentially.
This commit is contained in:
Raja Subramanian
2026-01-03 03:17:58 +05:30
committed by GitHub
parent 46651c1978
commit 335f4c33fb
10 changed files with 80 additions and 66 deletions
+4 -4
View File
@@ -378,7 +378,7 @@ func TestDisableCodecs(t *testing.T) {
// negotiated codec should not contain h264
sink := &routingfakes.FakeMessageSink{}
participant.SetResponseSink(sink)
participant.SwapResponseSink(sink, types.SignallingCloseReasonUnknown)
var answer webrtc.SessionDescription
var answerId uint32
var answerReceived atomic.Bool
@@ -435,7 +435,7 @@ func TestDisablePublishCodec(t *testing.T) {
}
sink := &routingfakes.FakeMessageSink{}
participant.SetResponseSink(sink)
participant.SwapResponseSink(sink, types.SignallingCloseReasonUnknown)
var publishReceived atomic.Bool
sink.WriteMessageCalls(func(msg proto.Message) error {
if res, ok := msg.(*livekit.SignalResponse); ok {
@@ -570,7 +570,7 @@ func TestPreferMediaCodecForPublisher(t *testing.T) {
offerId := uint32(23)
sink := &routingfakes.FakeMessageSink{}
participant.SetResponseSink(sink)
participant.SwapResponseSink(sink, types.SignallingCloseReasonUnknown)
var answer webrtc.SessionDescription
var answerId uint32
var answerReceived atomic.Bool
@@ -690,7 +690,7 @@ func TestPreferAudioCodecForRed(t *testing.T) {
offerId := uint32(0xffffff)
sink := &routingfakes.FakeMessageSink{}
participant.SetResponseSink(sink)
participant.SwapResponseSink(sink, types.SignallingCloseReasonUnknown)
var answer webrtc.SessionDescription
var answerId uint32
var answerReceived atomic.Bool