From e0028b308a77748d93ab4947690ee95335b10d85 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 2 Jul 2014 13:37:20 +0200 Subject: [PATCH] subscriptions: add missing service_stop() call for the BAD_SERVICE state --- src/service.c | 2 +- src/service.h | 1 + src/subscriptions.c | 13 +++++++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/service.c b/src/service.c index f811c527..0e02d961 100644 --- a/src/service.c +++ b/src/service.c @@ -262,7 +262,7 @@ service_stream_destroy(service_t *t, elementary_stream_t *es) /** * Service lock must be held */ -static void +void service_stop(service_t *t) { elementary_stream_t *st; diff --git a/src/service.h b/src/service.h index 68b1797a..a7738db1 100644 --- a/src/service.h +++ b/src/service.h @@ -439,6 +439,7 @@ void service_init(void); void service_done(void); int service_start(service_t *t, int instance); +void service_stop(service_t *t); void service_build_filter(service_t *t); diff --git a/src/subscriptions.c b/src/subscriptions.c index 44cd8a37..d437100e 100644 --- a/src/subscriptions.c +++ b/src/subscriptions.c @@ -200,6 +200,7 @@ subscription_reschedule(void) { static int reenter = 0; th_subscription_t *s; + service_t *t; service_instance_t *si; streaming_message_t *sm; int error; @@ -215,17 +216,21 @@ subscription_reschedule(void) if (s->ths_mmi) continue; if (!s->ths_service && !s->ths_channel) continue; - if(s->ths_service != NULL && s->ths_current_instance != NULL) { + t = s->ths_service; + if(t != NULL && s->ths_current_instance != NULL) { /* Already got a service */ if(s->ths_state != SUBSCRIPTION_BAD_SERVICE) continue; /* And it not bad, so we're happy */ - s->ths_service->s_streaming_status = 0; - s->ths_service->s_status = SERVICE_IDLE; + t->s_streaming_status = 0; + t->s_status = SERVICE_IDLE; subscription_unlink_service0(s, SM_CODE_BAD_SOURCE, 0); + if(t && LIST_FIRST(&t->s_subscriptions) == NULL) + service_stop(t); + si = s->ths_current_instance; assert(si != NULL); @@ -240,7 +245,7 @@ subscription_reschedule(void) if (s->ths_channel) tvhtrace("subscription", "find service for %s weight %d", channel_get_name(s->ths_channel), s->ths_weight); - else + else tvhtrace("subscription", "find instance for %s weight %d", s->ths_service->s_nicename, s->ths_weight); si = service_find_instance(s->ths_service, s->ths_channel,