Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
service/bouquet: fix the channel destroy when service associated to t…
…he bouquet is destroyed, fixes #3245
  • Loading branch information
perexg committed Nov 12, 2015
1 parent 71cfeb0 commit 6b11d91
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 28 deletions.
13 changes: 7 additions & 6 deletions src/bouquet.c
Expand Up @@ -33,7 +33,7 @@ typedef struct bouquet_download {

bouquet_tree_t bouquets;

static void bouquet_remove_service(bouquet_t *bq, service_t *s);
static void bouquet_remove_service(bouquet_t *bq, service_t *s, int delconf);
static uint64_t bouquet_get_channel_number0(bouquet_t *bq, service_t *t);
static void bouquet_download_trigger(bouquet_t *bq);
static void bouquet_download_stop(void *aux);
Expand Down Expand Up @@ -155,7 +155,7 @@ bouquet_destroy(bouquet_t *bq)
*
*/
void
bouquet_destroy_by_service(service_t *t)
bouquet_destroy_by_service(service_t *t, int delconf)
{
bouquet_t *bq;
service_lcn_t *sl;
Expand All @@ -164,7 +164,7 @@ bouquet_destroy_by_service(service_t *t)

RB_FOREACH(bq, &bouquets, bq_link)
if (idnode_set_exists(bq->bq_services, &t->s_id))
bouquet_remove_service(bq, t);
bouquet_remove_service(bq, t, delconf);
while ((sl = LIST_FIRST(&t->s_lcns)) != NULL) {
LIST_REMOVE(sl, sl_link);
free(sl);
Expand Down Expand Up @@ -398,12 +398,13 @@ bouquet_notify_service_enabled(service_t *t)
*
*/
static void
bouquet_remove_service(bouquet_t *bq, service_t *s)
bouquet_remove_service(bouquet_t *bq, service_t *s, int delconf)
{
tvhtrace("bouquet", "remove service %s from %s",
s->s_nicename, bq->bq_name ?: "<unknown>");
idnode_set_remove(bq->bq_services, &s->s_id);
bouquet_unmap_channel(bq, s);
if (delconf)
bouquet_unmap_channel(bq, s);
}

/*
Expand Down Expand Up @@ -438,7 +439,7 @@ bouquet_completed(bouquet_t *bq, uint32_t seen)
if (!idnode_set_exists(bq->bq_active_services, bq->bq_services->is_array[z]))
idnode_set_add(remove, bq->bq_services->is_array[z], NULL, NULL);
for (z = 0; z < remove->is_count; z++)
bouquet_remove_service(bq, (service_t *)remove->is_array[z]);
bouquet_remove_service(bq, (service_t *)remove->is_array[z], 1);
idnode_set_free(remove);

/* Remove no longer used LCNs */
Expand Down
2 changes: 1 addition & 1 deletion src/bouquet.h
Expand Up @@ -77,7 +77,7 @@ bouquet_t * bouquet_create(const char *uuid, htsmsg_t *conf,

void bouquet_delete(bouquet_t *bq);

void bouquet_destroy_by_service(service_t *t);
void bouquet_destroy_by_service(service_t *t, int delconf);
void bouquet_destroy_by_channel_tag(channel_tag_t *ct);

void bouquet_notify_service_enabled(service_t *t);
Expand Down
6 changes: 4 additions & 2 deletions src/input/mpegts/iptv/iptv_auto.c
Expand Up @@ -298,7 +298,7 @@ iptv_auto_network_process(void *aux, const char *last_url,
{
auto_private_t *ap = aux;
iptv_network_t *in = ap->in_network;
mpegts_mux_t *mm;
mpegts_mux_t *mm, *mm2;
int r = -1, count, n, i;
http_arg_list_t remove_args;
char *argv[10];
Expand Down Expand Up @@ -328,11 +328,13 @@ iptv_auto_network_process(void *aux, const char *last_url,

if (r == 0) {
count = 0;
LIST_FOREACH(mm, &in->mn_muxes, mm_network_link)
for (mm = LIST_FIRST(&in->mn_muxes); mm; mm = mm2) {
mm2 = LIST_NEXT(mm, mm_network_link);
if (((iptv_mux_t *)mm)->im_delete_flag) {
mm->mm_delete(mm, 1);
count++;
}
}
if (count > 0)
tvhinfo("iptv", "removed %d mux(es) from network '%s'", count, in->mn_network_name);
} else {
Expand Down
30 changes: 13 additions & 17 deletions src/input/mpegts/iptv/iptv_mux.c
Expand Up @@ -250,31 +250,27 @@ iptv_mux_config_save ( mpegts_mux_t *mm )
static void
iptv_mux_delete ( mpegts_mux_t *mm, int delconf )
{
char *url, *url_sane, *url_raw, *muxname;
iptv_mux_t *im = (iptv_mux_t*)mm;
iptv_mux_t *im = (iptv_mux_t*)mm, copy;
char ubuf[UUID_HEX_SIZE];

if (delconf)
hts_settings_remove("input/iptv/networks/%s/muxes/%s/config",
idnode_uuid_as_sstr(&mm->mm_network->mn_id),
idnode_uuid_as_str(&mm->mm_id, ubuf));

url = im->mm_iptv_url; // Workaround for silly printing error
url_sane = im->mm_iptv_url_sane;
url_raw = im->mm_iptv_url_raw;
muxname = im->mm_iptv_muxname;
free(im->mm_iptv_interface);
free(im->mm_iptv_svcname);
free(im->mm_iptv_env);
free(im->mm_iptv_hdr);
free(im->mm_iptv_tags);
free(im->mm_iptv_icon);
free(im->mm_iptv_epgid);
copy = *im; /* keep pointers */
mpegts_mux_delete(mm, delconf);
free(url);
free(url_sane);
free(url_raw);
free(muxname);
free(copy.mm_iptv_url);
free(copy.mm_iptv_url_sane);
free(copy.mm_iptv_url_raw);
free(copy.mm_iptv_muxname);
free(copy.mm_iptv_interface);
free(copy.mm_iptv_svcname);
free(copy.mm_iptv_env);
free(copy.mm_iptv_hdr);
free(copy.mm_iptv_tags);
free(copy.mm_iptv_icon);
free(copy.mm_iptv_epgid);
}

static void
Expand Down
4 changes: 2 additions & 2 deletions src/service.c
Expand Up @@ -806,6 +806,8 @@ service_destroy(service_t *t, int delconf)
while((s = LIST_FIRST(&t->s_subscriptions)) != NULL)
subscription_unlink_service(s, SM_CODE_SOURCE_DELETED);

bouquet_destroy_by_service(t, delconf);

while ((ilm = LIST_FIRST(&t->s_channels)))
idnode_list_unlink(ilm, delconf ? t : NULL);

Expand All @@ -815,8 +817,6 @@ service_destroy(service_t *t, int delconf)

t->s_status = SERVICE_ZOMBIE;

bouquet_destroy_by_service(t);

TAILQ_INIT(&t->s_filt_components);
while((st = TAILQ_FIRST(&t->s_components)) != NULL)
service_stream_destroy(t, st);
Expand Down

0 comments on commit 6b11d91

Please sign in to comment.