]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
epggrab: otamux - improve shutdown sequence
authorJaroslav Kysela <perex@perex.cz>
Wed, 27 May 2015 13:27:13 +0000 (15:27 +0200)
committerJaroslav Kysela <perex@perex.cz>
Wed, 27 May 2015 13:27:13 +0000 (15:27 +0200)
src/epggrab/otamux.c

index 10416c1c31e9cd11fe2037e5cef827530c79466f..7623ea79ee777fe1595b5c45db361cc8e075603b 100644 (file)
@@ -54,6 +54,7 @@ epggrab_ota_head_t           epggrab_ota_active;
 gtimer_t                     epggrab_ota_kick_timer;
 gtimer_t                     epggrab_ota_start_timer;
 
+int                          epggrab_ota_running;
 int                          epggrab_ota_pending_flag;
 
 pthread_mutex_t              epggrab_ota_mutex;
@@ -322,6 +323,9 @@ epggrab_ota_register
   int save = 0;
   epggrab_ota_map_t *map;
 
+  if (!epggrab_ota_running)
+    return NULL;
+
   if (ota == NULL) {
     /* Find mux entry */
     const char *uuid = idnode_uuid_as_str(&mm->mm_id);
@@ -666,7 +670,7 @@ epggrab_ota_service_add ( epggrab_ota_map_t *map, epggrab_ota_mux_t *ota,
 {
   epggrab_ota_svc_link_t *svcl;
 
-  if (uuid == NULL)
+  if (uuid == NULL || !epggrab_ota_running)
     return;
   SKEL_ALLOC(epggrab_svc_link_skel);
   epggrab_svc_link_skel->uuid = (char *)uuid;
@@ -686,7 +690,7 @@ void
 epggrab_ota_service_del ( epggrab_ota_map_t *map, epggrab_ota_mux_t *ota,
                           epggrab_ota_svc_link_t *svcl, int save )
 {
-  if (svcl == NULL)
+  if (svcl == NULL || !epggrab_ota_running)
     return;
   epggrab_ota_service_trace(ota, svcl, "delete");
   RB_REMOVE(&map->om_svcs, svcl, link);
@@ -818,6 +822,8 @@ epggrab_ota_init ( void )
     }
     htsmsg_destroy(c);
   }
+
+  epggrab_ota_running = 1;
 }
 
 void
@@ -873,6 +879,7 @@ epggrab_ota_shutdown ( void )
   epggrab_ota_mux_t *ota;
 
   pthread_mutex_lock(&global_lock);
+  epggrab_ota_running = 0;
   while ((ota = TAILQ_FIRST(&epggrab_ota_active)) != NULL)
     epggrab_ota_free(&epggrab_ota_active, ota);
   while ((ota = TAILQ_FIRST(&epggrab_ota_pending)) != NULL)