From b83aba0b13578fbd87485229bccd116e9423ed81 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 7 May 2017 13:56:55 -0700 Subject: [PATCH] inspircd: stop ENDBURST timers when irc.aborted gets set --- protocols/inspircd.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/protocols/inspircd.py b/protocols/inspircd.py index aef0f1c..f6331e4 100644 --- a/protocols/inspircd.py +++ b/protocols/inspircd.py @@ -370,12 +370,18 @@ class InspIRCdProtocol(TS6BaseProtocol): self._send(uplink, 'SERVER %s * 1 %s :%s' % (name, sid, desc)) self.irc.servers[sid] = IrcServer(uplink, name, internal=True, desc=desc) - endburstf = lambda: self._send(sid, 'ENDBURST') - if endburst_delay: + def endburstf(): # Delay ENDBURST by X seconds if requested. - threading.Timer(endburst_delay, endburstf, ()).start() + if self.irc.aborted.wait(endburst_delay): + # We managed to catch the abort flag before sending ENDBURST, so break + log.debug('(%s) stopping endburstf() for %s as aborted was set', self.irc.name, sid) + return + self._send(sid, 'ENDBURST') + + if endburst_delay: + threading.Thread(target=endburstf).start() else: # Else, send burst immediately - endburstf() + self._send(sid, 'ENDBURST') return sid def squit(self, source, target, text='No reason given'):