From fa297e32738808425e83031a59a0aa3a95e9725b Mon Sep 17 00:00:00 2001 From: Sean DuBois Date: Sat, 5 Oct 2024 23:35:34 -0400 Subject: [PATCH] Fix incorrect client retransmissions introduced by ec76652f161d0. If Client has gone to finished we know that server sent Finished. No reason to ever re-send messages. Resolves pion/webrtc#2909 --- handshaker.go | 6 +++++- handshaker_test.go | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/handshaker.go b/handshaker.go index 946cf4bc..5e16808a 100644 --- a/handshaker.go +++ b/handshaker.go @@ -338,7 +338,11 @@ func (s *handshakeFSM) finish(ctx context.Context, c flightConn) (handshakeState select { case state := <-c.recvHandshake(): close(state.done) - return handshakeSending, nil + if s.state.isClient { + return handshakeFinished, nil + } else { + return handshakeSending, nil + } case <-ctx.Done(): return handshakeErrored, ctx.Err() } diff --git a/handshaker_test.go b/handshaker_test.go index 39b7ff20..de82a571 100644 --- a/handshaker_test.go +++ b/handshaker_test.go @@ -225,8 +225,8 @@ func TestHandshaker(t *testing.T) { t.Errorf("Client is not finished") } // there should be no `Finished` last retransmit from client - if cntClientFinishedLastRetransmit != 4 { - t.Errorf("Number of client finished last retransmit is wrong, expected: %d times, got: %d times", 4, cntClientFinishedLastRetransmit) + if cntClientFinishedLastRetransmit != 0 { + t.Errorf("Number of client finished last retransmit is wrong, expected: %d times, got: %d times", 0, cntClientFinishedLastRetransmit) } if cntServerFinished < 1 { t.Errorf("Number of server finished is wrong, expected: at least %d times, got: %d times", 1, cntServerFinished)