service: report better status responses when subscription fails

This commit is contained in:
Adam Sutton 2013-12-01 22:35:10 +00:00
parent a1029481d9
commit e33dabee8b
2 changed files with 10 additions and 3 deletions

View file

@ -417,7 +417,8 @@ service_find_instance
/* Failed */
if(si == NULL) {
*error = SM_CODE_NO_FREE_ADAPTER;
if (*error < SM_CODE_NO_FREE_ADAPTER)
*error = SM_CODE_NO_FREE_ADAPTER;
return NULL;
}
@ -425,7 +426,9 @@ service_find_instance
tvhtrace("service", "will start new instance %d", si->si_instance);
if (service_start(si->si_s, si->si_instance)) {
tvhtrace("service", "tuning failed");
*error = SM_CODE_TUNING_FAILED;
si->si_error = SM_CODE_TUNING_FAILED;
if (*error < SM_CODE_TUNING_FAILED)
*error = SM_CODE_TUNING_FAILED;
si = NULL;
}
return si;

View file

@ -238,6 +238,7 @@ subscription_reschedule(void)
s->ths_service = si->si_s;
}
error = s->ths_testing_error;
if (s->ths_channel)
tvhtrace("subscription", "find service for %s weight %d",
channel_get_name(s->ths_channel), s->ths_weight);
@ -319,6 +320,7 @@ subscription_input_direct(void *opauqe, streaming_message_t *sm)
static void
subscription_input(void *opauqe, streaming_message_t *sm)
{
int error;
th_subscription_t *s = opauqe;
if(s->ths_state == SUBSCRIPTION_TESTING_SERVICE) {
@ -335,7 +337,9 @@ subscription_input(void *opauqe, streaming_message_t *sm)
sm->sm_code & (TSS_GRACEPERIOD | TSS_ERRORS)) {
// No, mark our subscription as bad_service
// the scheduler will take care of things
s->ths_testing_error = tss2errcode(sm->sm_code);
error = tss2errcode(sm->sm_code);
if (error > s->ths_testing_error)
s->ths_testing_error = error;
s->ths_state = SUBSCRIPTION_BAD_SERVICE;
streaming_msg_free(sm);
return;