From: Jaroslav Kysela Date: Mon, 19 Jun 2017 12:21:22 +0000 (+0200) Subject: subscription: call correctly service stop when instance is bad, fixes #4438 X-Git-Tag: v4.2.3~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5f74b60c4fbc1e57135ee0a46be66d18ba0940b;p=thirdparty%2Ftvheadend.git subscription: call correctly service stop when instance is bad, fixes #4438 --- diff --git a/src/service.c b/src/service.c index e126c9be1..7cd0a9af9 100644 --- a/src/service.c +++ b/src/service.c @@ -364,9 +364,6 @@ service_stop(service_t *t) t->s_tt_commercial_advice = COMMERCIAL_UNKNOWN; - assert(LIST_FIRST(&t->s_streaming_pad.sp_targets) == NULL); - assert(LIST_FIRST(&t->s_subscriptions) == NULL); - /** * Clean up each stream */ diff --git a/src/subscriptions.c b/src/subscriptions.c index 2eb998e4a..03da4b1e7 100644 --- a/src/subscriptions.c +++ b/src/subscriptions.c @@ -134,7 +134,7 @@ subscription_link_service(th_subscription_t *s, service_t *t) * Called from service code */ static int -subscription_unlink_service0(th_subscription_t *s, int reason, int stop) +subscription_unlink_service0(th_subscription_t *s, int reason, int resched) { streaming_message_t *sm; service_t *t = s->ths_service; @@ -147,7 +147,7 @@ subscription_unlink_service0(th_subscription_t *s, int reason, int stop) streaming_target_disconnect(&t->s_streaming_pad, &s->ths_input); - if(stop && t->s_running) { + if(!resched && t->s_running) { // Send a STOP message to the subscription client sm = streaming_msg_create_code(SMT_STOP, reason); streaming_target_deliver(s->ths_output, sm); @@ -158,11 +158,11 @@ subscription_unlink_service0(th_subscription_t *s, int reason, int stop) LIST_REMOVE(s, ths_service_link); - if (stop && (s->ths_flags & SUBSCRIPTION_ONESHOT) != 0) + if (!resched && (s->ths_flags & SUBSCRIPTION_ONESHOT) != 0) mtimer_arm_rel(&s->ths_remove_timer, subscription_unsubscribe_cb, s, 0); stop: - if(LIST_FIRST(&t->s_subscriptions) == NULL) + if(resched || LIST_FIRST(&t->s_subscriptions) == NULL) service_stop(t); return 1; } @@ -170,7 +170,7 @@ stop: void subscription_unlink_service(th_subscription_t *s, int reason) { - subscription_unlink_service0(s, reason, 1); + subscription_unlink_service0(s, reason, 0); } /* ************************************************************************** @@ -373,7 +373,7 @@ subscription_reschedule(void) /* Already got a service */ if(subgetstate(s) != SUBSCRIPTION_BAD_SERVICE) - continue; /* And it not bad, so we're happy */ + continue; /* And it is not bad, so we're happy */ tvhwarn(LS_SUBSCRIPTION, "%04X: service instance is bad, reason: %s", shortid(s), streaming_code2txt(s->ths_testing_error)); @@ -384,7 +384,7 @@ subscription_reschedule(void) si = s->ths_current_instance; assert(si != NULL); - subscription_unlink_service0(s, SM_CODE_BAD_SOURCE, 0); + subscription_unlink_service0(s, SM_CODE_BAD_SOURCE, 1); si->si_error = s->ths_testing_error; time(&si->si_error_time);