From e7f29214c0f8521eae8cf5cdfffef7ad2d6720f2 Mon Sep 17 00:00:00 2001 From: baseballyama Date: Mon, 28 Sep 2026 23:46:56 +0900 Subject: [PATCH] MT#55283 Keep the takeover grace period until media is accepted 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. Ref #2184 Change-Id: Ib06a170d271e8aea709abc57cbfd3bcc59196ab5 (cherry picked from commit 1d783ba1b9d21c08d1aa17e2e1588a6872e88aaa) (cherry picked from commit 4f9c4f3f130af65f211c12fd15f4fd43accf3b1c) --- daemon/media_socket.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/daemon/media_socket.c b/daemon/media_socket.c index fe230d544..0f1a952ce 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -3510,8 +3510,6 @@ static int stream_packet(struct packet_handler_ctx *phc) { if (!phc->mp.stream->selected_sfd) goto out; - CALL_CLEAR(phc->mp.call, FOREIGN_MEDIA); - if (CALL_ISSET(phc->mp.call, DROP_TRAFFIC)) goto drop; @@ -3553,6 +3551,9 @@ static int stream_packet(struct packet_handler_ctx *phc) { if (media_packet_address_check(phc)) goto drop; + // only media we accept ends the grace period after a takeover + CALL_CLEAR(phc->mp.call, FOREIGN_MEDIA); + PS_SET(phc->mp.stream, RECEIVED); if (rtpe_config.active_switchover && IS_FOREIGN_CALL(phc->mp.call))