]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
channel: avoid recursive changed callback calls, fixes #4408
authorJaroslav Kysela <perex@perex.cz>
Tue, 6 Jun 2017 17:39:57 +0000 (19:39 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 6 Jun 2017 17:39:57 +0000 (19:39 +0200)
src/channels.c
src/channels.h

index 74677fe6d5db482fbe0cc3a88e739d1ac4528c04..3f76b9231643bf5984f9e623f8ba7c574b76e74f 100644 (file)
@@ -73,6 +73,9 @@ channel_class_changed ( idnode_t *self )
 {
   channel_t *ch = (channel_t *)self;
 
+  if (atomic_add(&ch->ch_changed_ref, 1) > 0)
+    goto end;
+
   tvhdebug(LS_CHANNEL, "channel '%s' changed", channel_get_name(ch, channel_blank_name));
 
   /* update the EPG channel <-> channel mapping here */
@@ -81,6 +84,9 @@ channel_class_changed ( idnode_t *self )
 
   /* HTSP */
   htsp_channel_update(ch);
+
+end:
+  atomic_dec(&ch->ch_changed_ref, 0);
 }
 
 static htsmsg_t *
@@ -1009,6 +1015,8 @@ channel_create0
   ch->ch_epgauto  = 1;
   ch->ch_epg_running = -1;
 
+  atomic_set(&ch->ch_changed_ref, 0);
+
   if (conf) {
     ch->ch_load = 1;
     idnode_load(&ch->ch_id, conf);
index 357281df4b4344a093b1b3f17e6d7b6361575740..430252b25413661d684913527b96d919e1cba24c 100644 (file)
@@ -46,6 +46,7 @@ typedef struct channel
   int ch_refcount;
   int ch_load;
   int ch_dont_save;
+  int ch_changed_ref;
 
   /* Channel info */
   int     ch_enabled;