diff --git a/classes.py b/classes.py index 65fbc13..239d21c 100644 --- a/classes.py +++ b/classes.py @@ -105,7 +105,6 @@ class Irc(): self.pingfreq = self.serverdata.get('pingfreq') or 90 self.pingtimeout = self.pingfreq * 3 - self.connected.clear() self.pseudoclient = None self.lastping = time.time() @@ -319,12 +318,8 @@ class Irc(): log.error('(%s) Disconnected from IRC: %s: %s', self.name, type(e).__name__, str(e)) - was_successful = self.connected.is_set() self.disconnect() - # Internal hook signifying that a network has disconnected. - self.callHooks([None, 'PYLINK_DISCONNECT', {'was_successful': checks_ok and was_successful}]) - # If autoconnect is enabled, loop back to the start. Otherwise, # return and stop. autoconnect = self.serverdata.get('autoconnect') @@ -343,6 +338,8 @@ class Irc(): def disconnect(self): """Handle disconnects from the remote server.""" + was_successful = self.connected.is_set() + log.debug('(%s) disconnect: got %s for was_successful state', self.name, was_successful) log.debug('(%s) disconnect: Clearing self.connected state.', self.name) self.connected.clear() @@ -366,6 +363,9 @@ class Irc(): log.debug('(%s) disconnect: Setting self.aborted to True.', self.name) self.aborted.set() + # Internal hook signifying that a network has disconnected. + self.callHooks([None, 'PYLINK_DISCONNECT', {'was_successful': was_successful}]) + log.debug('(%s) disconnect: Clearing state via initVars().', self.name) self.initVars() diff --git a/plugins/relay.py b/plugins/relay.py index 019e0ae..18abdd5 100644 --- a/plugins/relay.py +++ b/plugins/relay.py @@ -1509,9 +1509,11 @@ def handle_disconnect(irc, numeric, command, args): # Announce the disconnects to every leaf channel where the disconnected network is the owner announcement = conf.conf.get('relay', {}).get('disconnect_announcement') + log.debug('(%s) relay: last connection successful: %s', irc.name, args.get('was_successful')) if announcement and args.get('was_successful'): with db_lock: for chanpair, entrydata in db.items(): + log.debug('(%s) relay: Looking up %s', irc.name, chanpair) if chanpair[0] == irc.name: for leaf in entrydata['links']: log.debug('(%s) relay: Announcing disconnect to %s%s', irc.name,