]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
subscription: call correctly service stop when instance is bad, fixes #4438
authorJaroslav Kysela <perex@perex.cz>
Mon, 19 Jun 2017 12:21:22 +0000 (14:21 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 19 Jun 2017 12:21:54 +0000 (14:21 +0200)
src/service.c
src/subscriptions.c

index e126c9be187286d64b9e5298e84f3340de936351..7cd0a9af9eec782de5a528c5f6d7b6d1b9591637 100644 (file)
@@ -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
    */
index 2eb998e4a9ecfbaf327fb65847ea87bb22b8d5ad..03da4b1e78ffbc11a7337b2717db0094449d2573 100644 (file)
@@ -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);