From: Jaroslav Kysela Date: Wed, 27 May 2015 13:27:13 +0000 (+0200) Subject: epggrab: otamux - improve shutdown sequence X-Git-Tag: v4.2.1~2445 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=88a447405a01bf8ed063759f32a7d641705582b5;p=thirdparty%2Ftvheadend.git epggrab: otamux - improve shutdown sequence --- diff --git a/src/epggrab/otamux.c b/src/epggrab/otamux.c index 10416c1c3..7623ea79e 100644 --- a/src/epggrab/otamux.c +++ b/src/epggrab/otamux.c @@ -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)