[vlc-devel] [PATCH] schedule timer with interval once valid UDP received

Natalie Landsberg natalie.landsberg97 at gmail.com
Thu Oct 29 15:50:57 CET 2020

> The comment seems to imply that the patch reintroduces a data race.

Looking at the code again…. It seems as though the updateTimer is never actually scheduled on an interval. 
It’s only called as single shots. I’m not sure whether that was removed, or never there in the first place. 
And why some streams would happily continue for quite a while without it.

My suggestion: Add vlc_timer_schedule with interval after it is confirmed 
that UDP packet can be received on the socket.

This way, the timer is still disarmed if it was armed before (amt_recv_relay_mem_query has a single shot)
and it is scheduled on its intended interval.

I've tested that this indeed works with a stream and sends the membership reports on a 125 interval,
but will continue testing as well.
 modules/access/amt.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/modules/access/amt.c b/modules/access/amt.c
index 52bf0271ef..40caa5e14f 100644
--- a/modules/access/amt.c
+++ b/modules/access/amt.c
@@ -746,6 +746,10 @@ static bool open_amt_tunnel( stream_t *p_access )
             block_Release( pkt );
             msg_Dbg( p_access, "Got UDP packet from multicast group via AMT relay %s, continuing...", relay_ip );
+            /* Arms the timer again for a single shot from this callback. That way, the
+            * time spent in amt_send_mem_update() is taken into consideration. */
+            vlc_timer_schedule( sys->updateTimer, false,
+                                VLC_TICK_FROM_SEC( sys->relay_igmp_query.qqic ), VLC_TICK_FROM_SEC( sys->relay_igmp_query.qqic ) );
             break;   /* found an active server sending UDP packets, so exit loop */
2.24.3 (Apple Git-128)

More information about the vlc-devel mailing list