From adc59990be19e64cf1ef332239924618431502b7 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Sun, 17 Aug 2014 23:04:47 +0200 Subject: [PATCH] subcriptions: reschedule - add the early retry scheme for the busy situations --- src/subscriptions.c | 9 +++++++++ src/subscriptions.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/src/subscriptions.c b/src/subscriptions.c index 67d0bf9f..a77987a4 100644 --- a/src/subscriptions.c +++ b/src/subscriptions.c @@ -296,6 +296,8 @@ subscription_reschedule(void) if (!s->ths_channel) s->ths_service = si->si_s; + + s->ths_last_error = 0; } error = s->ths_testing_error; @@ -313,6 +315,13 @@ subscription_reschedule(void) s->ths_current_instance = si; if(si == NULL) { + if (s->ths_last_error != error || s->ths_last_find + 2 >= dispatch_clock) { + tvhtrace("subscription", "instance not available, retrying"); + if (s->ths_last_error != error) + s->ths_last_find = dispatch_clock; + s->ths_last_error = error; + continue; + } /* No service available */ sm = streaming_msg_create_code(SMT_NOSTART, error); streaming_target_deliver(s->ths_output, sm); diff --git a/src/subscriptions.h b/src/subscriptions.h index fad0edec..6bf4fa8a 100644 --- a/src/subscriptions.h +++ b/src/subscriptions.h @@ -76,6 +76,9 @@ typedef struct th_subscription { int ths_flags; + time_t ths_last_find; + int ths_last_error; + streaming_message_t *ths_start_message; char *ths_hostname;