From 429634450213c62c76ac954be186a455c81cf937 Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Wed, 31 Mar 2010 14:43:30 +0100 Subject: [PATCH] handle losing connection to the webserver so we don't get stuck firing off loads of ajax requests --- deluge/ui/web/js/deluge-all/EventsManager.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/deluge/ui/web/js/deluge-all/EventsManager.js b/deluge/ui/web/js/deluge-all/EventsManager.js index 3ed924035..df669ff45 100644 --- a/deluge/ui/web/js/deluge-all/EventsManager.js +++ b/deluge/ui/web/js/deluge-all/EventsManager.js @@ -74,6 +74,7 @@ Deluge.EventsManager = Ext.extend(Ext.util.Observable, { deluge.client.web.register_event_listener(eventName); }); this.running = true; + this.errorCount = 0; this.getEvents(); }, @@ -102,10 +103,14 @@ Deluge.EventsManager = Ext.extend(Ext.util.Observable, { }, // private - onGetEventsFailure: function(events) { - // the request timed out so we just want to open up another - // one. - if (this.running) this.getEvents(); + onGetEventsFailure: function(result, error) { + // the request timed out or we had a communication failure + if (!this.running) return; + if (!error.isTimeout && this.errorCount++ >= 3) { + this.stop(); + return; + } + this.getEvents(); } });