From: Jaroslav Kysela Date: Fri, 22 Jan 2016 15:41:09 +0000 (+0100) Subject: mpegts service: add asserts to master/slave linking X-Git-Tag: v4.2.1~1136 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b756409459028225a651f9b2410ea77e2a3ce092;p=thirdparty%2Ftvheadend.git mpegts service: add asserts to master/slave linking --- diff --git a/src/input/mpegts/mpegts_service.c b/src/input/mpegts/mpegts_service.c index c1d1c6ab1..35ca9510b 100644 --- a/src/input/mpegts/mpegts_service.c +++ b/src/input/mpegts/mpegts_service.c @@ -965,6 +965,8 @@ mpegts_service_link ( mpegts_service_t *master, mpegts_service_t *slave ) { pthread_mutex_lock(&slave->s_stream_mutex); pthread_mutex_lock(&master->s_stream_mutex); + assert(LIST_SAFE_ENTRY(master, s_masters_link)); + assert(LIST_SAFE_ENTRY(slave, s_slaves_link)); LIST_INSERT_HEAD(&slave->s_masters, master, s_masters_link); LIST_INSERT_HEAD(&master->s_slaves, slave, s_slaves_link); pthread_mutex_unlock(&master->s_stream_mutex); diff --git a/src/queue.h b/src/queue.h index 1551ea3ef..3388b46fc 100644 --- a/src/queue.h +++ b/src/queue.h @@ -36,6 +36,9 @@ LIST_ENTRY_INIT(elm, field); \ } +#define LIST_SAFE_ENTRY(elm, field) \ + ((elm)->field.le_next == NULL && (elm)->field.le_prev == NULL) + #define LIST_MOVE(newhead, oldhead, field) do { \ if((oldhead)->lh_first) { \ (oldhead)->lh_first->field.le_prev = &(newhead)->lh_first; \