Skip to content

Commit

Permalink
Improve OTA mux scheduling when dealing with subscription failures
Browse files Browse the repository at this point in the history
Associate a retry count with each OTA mux subscription failure and abort after 3 delayed attempts.
In this context, failure includes repeated tuning errors, but excludes lack of adapter availability.
  • Loading branch information
smithereens committed Apr 20, 2021
1 parent 98a7c6c commit 545d1af
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/epggrab.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ struct epggrab_ota_mux
mtimer_t om_data_timer; ///< Any EPG data seen?
mtimer_t om_handlers_timer; ///< Run handlers callback
int64_t om_retry_time; ///< Next time to retry
int om_retry_count; ///< how may times have we retried

char *om_force_modname;///< Force this module

Expand Down
29 changes: 21 additions & 8 deletions src/epggrab/otamux.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ epggrab_ota_kick_cb ( void *p )
mpegts_network_t *net;
uint8_t failed;
uint8_t fatal;
} networks[64], *net; /* more than 64 networks? - you're a king */
} networks[64], *net; /* more than 64 networks? - you're a king */
int i, r, networks_count = 0, epg_flag, kick = 1;
const char *modname;

Expand Down Expand Up @@ -610,7 +610,7 @@ epggrab_ota_kick_cb ( void *p )
if (net->failed) {
TAILQ_INSERT_TAIL(&epggrab_ota_pending, om, om_q_link);
om->om_q_type = EPGGRAB_OTA_MUX_PENDING;
om->om_retry_time = mclk() + mono2sec(60);
om->om_retry_time = mclk() + sec2mono(60);
goto done;
}
break;
Expand Down Expand Up @@ -673,13 +673,26 @@ epggrab_ota_kick_cb ( void *p )
SUBSCRIPTION_TABLES))) {
if (r != SM_CODE_NO_ADAPTERS) {
tvhtrace(LS_EPGGRAB, "subscription failed for %s (result %d)", mm->mm_nicename, r);
TAILQ_INSERT_TAIL(&epggrab_ota_pending, om, om_q_link);
om->om_q_type = EPGGRAB_OTA_MUX_PENDING;
om->om_retry_time = mclk() + mono2sec(60);
if (r == SM_CODE_NO_FREE_ADAPTER)
net->failed = 1;
if (r == SM_CODE_TUNING_FAILED)
if( om->om_retry_count < 3 ) {
TAILQ_INSERT_TAIL(&epggrab_ota_pending, om, om_q_link);
om->om_q_type = EPGGRAB_OTA_MUX_PENDING;
if (r == SM_CODE_NO_FREE_ADAPTER) {
/* wait for active mux to finish OTA grab */
om->om_retry_time = mclk() + sec2mono(60);
om->om_retry_count = 0;
}
else {
/* cannot tune - increase retry count and try again later */
om->om_retry_time = mclk() + sec2mono(30);
++(om->om_retry_count);
}
net->failed = 1;
}
else {
tvhtrace(LS_EPGGRAB, "too many failed attempts to tune %s (subscribe)", mm->mm_nicename);
net->fatal = 1;
om->om_retry_count = 0;
}
} else {
tvhtrace(LS_EPGGRAB, "no free adapter for %s (subscribe)", mm->mm_nicename);
net->fatal = 1;
Expand Down

0 comments on commit 545d1af

Please sign in to comment.