Persist peer address confirmation and learning mode in Redis - #2184
Open
baseballyama wants to merge 2 commits into
Open
baseballyama wants to merge 2 commits into
baseballyama wants to merge 2 commits into
Conversation
A call restored from Redis starts with every sfd unconfirmed and every stream's el_flags at zero, which is EL_DELAYED, regardless of what the offer asked for or what --endpoint-learning is set to. After a keyspace-notification failover, all adopted calls therefore re-learn their peer at the same time, and strict-source has nothing to compare against until they have. Write the sfd's confirmed flag and the stream's el_flags and learned_endpoint to the record, and read them back on restore. The two stream fields were so far only part of the rollback snapshot. Move them into the shared stream encoder and decoder, so that both use the same definition. Records without the new keys restore as before. Fixes sipwise#2182
After a takeover, FOREIGN_MEDIA holds off the media timeout until the call receives media. The flag is cleared by the first packet that arrives on any of the call's sockets, before the packet is checked, so a packet that is then dropped, for example because of strict-source, ends the grace period without refreshing the stream's last packet time. A call that was restored longer than the timeout ago is then closed on the next timer run, before its real media has had a chance to arrive. With the peer address confirmation now restored from Redis, this is what happens to an adopted strict-source call when a stray packet arrives ahead of the peer's first one. Clear the flag only once a packet has passed the address check. The timer still clears it for kernel-forwarded media, and the grace period stays bounded by the timeout after the takeover.
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.
close: #2182
A call restored from Redis re-learns its peer address, and the learning mode requested in the offer is lost (#2182). This writes the sfd's
confirmedflag and the stream'sel_flagsandlearned_endpointto the record and reads them back on restore. Records without the new keys restore as before.The second commit is needed once the confirmation survives a takeover. The first packet that arrives after
activeclearedFOREIGN_MEDIAeven if it was then dropped by strict-source, and a call that had been restored longer thantimeoutago was closed before its real media arrived.Tested with two instances using keyspace notifications and
active-switchover, kernel forwarding. 100 calls withendpoint-learning-offandstrict-sourcecarried genuine RTP, and spoofed RTP was sent to every media port while switching over:The Redis tests now expect the new keys, and the keyspace subscription test checks that a restored stream comes back confirmed.
This PR and #2185 touch the same test files but merge cleanly with each other.
This PR was prepared with the assistance of Claude Code (Claude Opus 5.5). The measurements are from our own test environment.