Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
epggrab: otamux - improve shutdown sequence
  • Loading branch information
perexg committed May 27, 2015
1 parent a39af0d commit 88a4474
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/epggrab/otamux.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -818,6 +822,8 @@ epggrab_ota_init ( void )
}
htsmsg_destroy(c);
}

epggrab_ota_running = 1;
}

void
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 88a4474

Please sign in to comment.