Repository navigation
sip: a retrieve right after the parker's BYE keeps its audio and gets no hold music - #403
Merged
Merged
Conversation
… no hold music
The parker's phone gets its BYE before parkRun's byeA (or w.bye) returns,
and a retrieve can land in that window. parkRetrieved attaches the
retriever to the parker's relay leg (attachParty -> handOverLeg). Then
parkRun went on as if nothing had happened:
- relay.SetTarget(parkerLeg, nil) cleared the leg the retriever had just
been attached to. The parked party's audio was dropped until the
retriever's own RTP latched the leg again. A phone that sends nothing
first, or sends from its SDP address only after hearing something,
stayed one-way.
- parkHold started the music on hold on the parked party's leg and
stored it in pk.music. parkRetrieved had already passed its
stopParkMusic, so the music played over the retrieved call until
parkHold's loop saw the halt.
parkRun now releases the parker's leg only while the call is still
parked. It checks c.park and pk.phase under c.mu, which is the lock
parkRetrieved takes to leave the parked phase, and returns without
entering parkHold once a retrieve has won. parkHold starts the music
under the same lock, and only for a call that is still parked and not
ended. So a retrieve either comes after the clear and attaches over it,
or comes before and the leg and the party are left alone. A retrieve
that comes after the music started stops it, as before.
TestCallParkRetrieveAsParkerLeaves holds the park goroutine right after
the parker's BYE (parkerGoneHook, tests only) and retrieves in that
window. It then checks two things: the parked party gets no RTP while
nobody talks, and the parked party's first packet reaches the
retriever's SDP address before the retriever has sent anything. Before
the fix both checks fail ("received 1 RTP packets ... (music on hold)",
"the retriever's SDP address did not get the parked party's audio"). After
the fix, -race -count=50 passes 50/50. The park, pickup and session-timer
tests pass with -race -count=3, and the internal/sip package passes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
The parker's phone gets its BYE before
parkRun'sbyeA(orw.bye) returns, and a retrieve can land in that window.parkRetrievedattaches the retriever to the parker's relay leg (attachParty->handOverLeg,park.go:528-531). ThenparkRuncarried on unconditionally (park.go:395-402before this change):relay.SetTarget(parkerLeg, nil)cleared the leg the retriever had just been attached to. The parked party's audio was dropped until the retriever's own RTP latched the leg again, so the call could stay one-way.parkHoldstarted the music on hold on the parked party's leg.parkRetrievedhad already calledstopParkMusic, so the music played over the retrieved call untilparkHoldsaw the halt.Fix
parkRunreleases the parker's leg only while the call is still parked. It checksc.park == pk && pk.phase == phaseParkedunderc.mu, the same lockparkRetrievedtakes to leave that phase. If a retrieve has already won,parkRunreturns without enteringparkHold.parkHoldstarts the music under the same lock, and only for a call that is still parked and not ended.A retrieve now either comes after the clear and attaches over it, or comes first and finds the leg and the party untouched.
Test
TestCallParkRetrieveAsParkerLeavesholds the park goroutine right after the parker's BYE. It usesparkerGoneHook, a new test-only hook in the style ofcallerByeHook. The test retrieves in that window and then checks two things:Verification
received 1 RTP packets ... (music on hold)andthe retriever's SDP address did not get the parked party's audio.go test -race -count=50 -run TestCallParkRetrieveAsParkerLeaves ./internal/sip/passes 50/50.-race -count=3over the park, pickup and session-timer-after-park tests passes.go test ./internal/sip/passes.