From: Chris Porter Date: Fri, 17 Oct 2008 08:19:41 +0000 (+0100) Subject: Few changes to the backend to prevent ping timeouts with the new retry logic. X-Git-Url: https://jfr.im/git/irc/quakenet/qwebirc.git/commitdiff_plain/4e22156614d898d7ce118d4391c332d29aef1331 Few changes to the backend to prevent ping timeouts with the new retry logic. --- diff --git a/js/irc/ircconnection.js b/js/irc/ircconnection.js index 9c95828..619251b 100644 --- a/js/irc/ircconnection.js +++ b/js/irc/ircconnection.js @@ -1,3 +1,5 @@ +/* This could do with a rewrite from scratch. */ + var IRCConnection = new Class({ Implements: [Events, Options], options: { @@ -38,9 +40,15 @@ var IRCConnection = new Class({ return true; }, __timeout: function() { + if(this.lastactiverequest) { + this.lastactiverequest.cancel(); + this.lastactiverequest = null; + alert("warning: last active request"); + } if(this.activerequest) { - this.activerequest.cancel(); - this.activerequest = null; + this.lastactiverequest = this.activerequest; + /*this.activerequest.cancel(); + this.activerequest = null;*/ } if($defined(this.timeoutid)) { $clear(this.timeoutid); @@ -50,13 +58,17 @@ var IRCConnection = new Class({ }, recv: function() { var r = new Request.JSON({url: "/e/s/" + this.sessionid + "?t=" + this.counter++, onComplete: function(o) { - this.activerequest = null; + if(this.lastactiverequest != r) + this.activerequest = null; + if($defined(this.timeoutid)) { $clear(this.timeoutid); this.timeoutid = null; } - + if(o) { + if(this.lastactiverequest == r) + this.lastactiverequest = null; this.lasttry = false; if(o[0] == false) { if(!this.disconnected) { @@ -70,6 +82,10 @@ var IRCConnection = new Class({ this.fireEvent("recv", [x]); }, this); } else { + if(this.lastactiverequest == r) { + this.lastactiverequest = null; + return; + } if(!this.disconnected) { if(this.lasttry) { this.disconnected = true; diff --git a/qwebirc/ajaxengine.py b/qwebirc/ajaxengine.py index ff6bd8e..78c1c4d 100644 --- a/qwebirc/ajaxengine.py +++ b/qwebirc/ajaxengine.py @@ -41,7 +41,7 @@ class IRCSession: def subscribe(self, channel): if len(self.subscriptions) >= config.MAXSUBSCRIPTIONS: - self.subscriptions.pop(0) + self.subscriptions.pop(0).close() self.subscriptions.append(channel) self.flush() @@ -111,6 +111,9 @@ class SingleUseChannel(Channel): self.request.finish() return False + def close(self): + self.request.finish() + class MultipleUseChannel(Channel): def write(self, data): self.request.write(data)