From 4fb7dca71e88fac26e27672b09cf3fea3c44e017 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Tue, 10 Sep 2013 21:15:02 +0100 Subject: [PATCH] subscription: for stupid mistake causing double free()'s --- src/input/mpegts/mpegts_mux.c | 2 +- src/subscriptions.c | 6 ++++-- src/subscriptions.h | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/input/mpegts/mpegts_mux.c b/src/input/mpegts/mpegts_mux.c index a0edd5d7..ab52083e 100644 --- a/src/input/mpegts/mpegts_mux.c +++ b/src/input/mpegts/mpegts_mux.c @@ -656,7 +656,7 @@ mpegts_mux_unsubscribe_by_name LIST_FOREACH(mmi, &mm->mm_instances, mmi_mux_link) LIST_FOREACH(s, &mmi->mmi_subs, ths_mmi_link) - if (!strcmp(s->ths_title, "initscan")) + if (!strcmp(s->ths_title, name)) subscription_unsubscribe(s); } diff --git a/src/subscriptions.c b/src/subscriptions.c index ad66da9d..1b34f155 100644 --- a/src/subscriptions.c +++ b/src/subscriptions.c @@ -252,8 +252,8 @@ subscription_reschedule(void) static void subscription_input_null(void *opaque, streaming_message_t *sm) { - if (sm->sm_type == SMT_STOP) { - th_subscription_t *s = opaque; + th_subscription_t *s = opaque; + if (sm->sm_type == SMT_STOP && s->ths_state != SUBSCRIPTION_ZOMBIE) { LIST_INSERT_HEAD(&subscriptions_remove, s, ths_remove_link); gtimer_arm(&subscription_reschedule_timer, subscription_reschedule_cb, NULL, 0); @@ -348,6 +348,8 @@ subscription_unsubscribe(th_subscription_t *s) lock_assert(&global_lock); + s->ths_state = SUBSCRIPTION_ZOMBIE; + service_instance_list_clear(&s->ths_instances); LIST_REMOVE(s, ths_global_link); diff --git a/src/subscriptions.h b/src/subscriptions.h index 7095897e..5287c6f2 100644 --- a/src/subscriptions.h +++ b/src/subscriptions.h @@ -39,6 +39,7 @@ typedef struct th_subscription { SUBSCRIPTION_TESTING_SERVICE, SUBSCRIPTION_GOT_SERVICE, SUBSCRIPTION_BAD_SERVICE, + SUBSCRIPTION_ZOMBIE } ths_state; int ths_testing_error;