Implement a more ellegant comet reconnection strategy
This commit is contained in:
parent
57c9329149
commit
18141cbec1
2 changed files with 12 additions and 6 deletions
|
@ -158,11 +158,14 @@ comet_mailbox_poll(http_connection_t *hc, const char *remain, void *opaque)
|
|||
{
|
||||
comet_mailbox_t *cmb = NULL;
|
||||
const char *cometid = http_arg_get(&hc->hc_req_args, "boxid");
|
||||
const char *immediate = http_arg_get(&hc->hc_req_args, "immediate");
|
||||
int im = immediate ? atoi(immediate) : 0;
|
||||
time_t reqtime;
|
||||
struct timespec ts;
|
||||
htsmsg_t *m;
|
||||
|
||||
usleep(100000); /* Always sleep 0.1 sec to avoid comet storms */
|
||||
if(!im)
|
||||
usleep(100000); /* Always sleep 0.1 sec to avoid comet storms */
|
||||
|
||||
pthread_mutex_lock(&comet_mutex);
|
||||
|
||||
|
@ -182,7 +185,7 @@ comet_mailbox_poll(http_connection_t *hc, const char *remain, void *opaque)
|
|||
|
||||
cmb->cmb_last_used = 0; /* Make sure we're not flushed out */
|
||||
|
||||
if(cmb->cmb_messages == NULL)
|
||||
if(!im && cmb->cmb_messages == NULL)
|
||||
pthread_cond_timedwait(&comet_cond, &comet_mutex, &ts);
|
||||
|
||||
m = htsmsg_create_map();
|
||||
|
|
|
@ -29,19 +29,22 @@ tvheadend.cometPoller = function() {
|
|||
|
||||
Ext.Ajax.request({
|
||||
url: 'comet',
|
||||
params : boxid ? { boxid: boxid } : null,
|
||||
params : {
|
||||
boxid: (boxid ? boxid : null),
|
||||
immediate: failures > 0 ? 1 : 0
|
||||
},
|
||||
success: function(result, request) {
|
||||
parse_comet_response(result.responseText);
|
||||
|
||||
if(failures > 2) {
|
||||
if(failures > 1) {
|
||||
tvheadend.log('Reconnected to Tvheadend',
|
||||
'font-weight: bold; color: #080');
|
||||
}
|
||||
failures = 0;
|
||||
},
|
||||
failure: function(result, request) {
|
||||
cometRequest.delay(failures > 10 ? 5000 : failures * 500);
|
||||
if(failures > 2) {
|
||||
cometRequest.delay(failures ? 1000 : 1);
|
||||
if(failures == 1) {
|
||||
tvheadend.log('There seems to be a problem with the ' +
|
||||
'live update feed from Tvheadend. ' +
|
||||
'Trying to reconnect...',
|
||||
|
|
Loading…
Add table
Reference in a new issue