From bb8a548e74d32d31eb885864aed99c37d73a4d19 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 1 May 2016 14:21:50 -0700 Subject: [PATCH] relay: make handle_quit error-tolerant if the target is missing In cases where multiple networks disconnect simultaneously, the relay user for a quitting client from the first dying network might have also disappeared while handle_disconnect was processing the disconnection of a second dying network. This should take into account those situations. --- plugins/relay.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/relay.py b/plugins/relay.py index cc9d7ef..df4508f 100644 --- a/plugins/relay.py +++ b/plugins/relay.py @@ -811,10 +811,15 @@ def handle_join(irc, numeric, command, args): utils.add_hook(handle_join, 'JOIN') def handle_quit(irc, numeric, command, args): + # Lock the user spawning mechanism before proceeding, since we're going to be + # deleting client from the relayusers cache. with spawnlocks[irc.name]: for netname, user in relayusers[(irc.name, numeric)].copy().items(): remoteirc = world.networkobjects[netname] - remoteirc.proto.quit(user, args['text']) + try: # Try to quit the client. If this fails because they're missing, bail. + remoteirc.proto.quit(user, args['text']) + except LookupError: + pass del relayusers[(irc.name, numeric)] utils.add_hook(handle_quit, 'QUIT')