From a46ce6b1094e3967d01421dae0df1a144e32a7ba Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Fri, 4 Apr 2003 08:30:16 +0000 Subject: [PATCH] Changed the way Irc handles unresponded-to PINGs. --- src/irclib.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/irclib.py b/src/irclib.py index 6c35bf4eb..0f49417ec 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -282,7 +282,7 @@ class Irc(object): self.queue = IrcMsgQueue() self.fastqueue = queue() self.lastping = time.time() - self.lastpong = time.time()+60 + self.outstandingPongs = set() self.lastTake = 0 self.driver = None # The driver should set this later. self.queue.enqueue(ircmsgs.user(self.user, self.ident)) @@ -330,8 +330,8 @@ class Irc(object): else: self.lastTake = now msg = self.queue.dequeue() - elif self.lastping - self.lastpong > 180: - # Our ping hasn't be responded to. + elif len(self.outstandingPongs) > 2: + # Our pings hasn't be responded to. if hasattr(self.driver, 'scheduleReconnect'): self.driver.scheduleReconnect() self.driver.die() @@ -340,6 +340,8 @@ class Irc(object): debug.msg('Irc.takeMsg throttling.', 'verbose') else: self.lastping = now + now = str(int(now)) + self.outstandingPongs.add(now) msg = ircmsgs.ping(str(int(now))) if msg: for callback in self.callbacks: @@ -399,7 +401,7 @@ class Irc(object): ircdb.users.setUser(self.nick, u) atexit.register(lambda: catch(ircdb.users.delUser(self.nick))) elif msg.command == 'PONG': - self.lastpong = time.time() + self.outstandingPongs.remove(msg.args[1]) elif msg.command == 'ERROR': if msg.args[0].startswith('Closing Link'): if hasattr(self.driver, 'scheduleReconnect'):