From 546dd716277e7249687c6f9239f271088fe91782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Sun, 4 May 2008 15:52:49 +0000 Subject: [PATCH] Travers muxer list in a safe manner --- parsers.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/parsers.c b/parsers.c index 0bc12835..90e20321 100644 --- a/parsers.c +++ b/parsers.c @@ -768,7 +768,7 @@ parser_compute_duration(th_transport_t *t, th_stream_t *st, th_pkt_t *pkt) static void parser_deliver(th_transport_t *t, th_stream_t *st, th_pkt_t *pkt) { - th_muxer_t *tm; + th_muxer_t *tm, *next; int64_t dts, pts, ptsoff; assert(pkt->pkt_dts != AV_NOPTS_VALUE); @@ -821,10 +821,13 @@ parser_deliver(th_transport_t *t, th_stream_t *st, th_pkt_t *pkt) avgstat_add(&st->st_rate, pkt->pkt_payloadlen, dispatch_clock); - /* Alert all muxers tied to us that a new packet has arrived */ - - LIST_FOREACH(tm, &t->tht_muxers, tm_transport_link) + /* Alert all muxers tied to us that a new packet has arrived. + Muxers may remove themself as a direct action of receiving a packet + (serviceprober), so we need to traverse in a safe manner */ + for(tm = LIST_FIRST(&t->tht_muxers); tm != NULL; tm = next) { + next = LIST_NEXT(tm, tm_transport_link); tm->tm_new_pkt(tm, st, pkt); + } /* Unref (and possibly free) the packet, muxers are supposed to increase refcount or copy packet if they need anything */