Commit 324615d7 authored by Neil Williams's avatar Neil Williams 💬 Committed by Rémi Duraffort

LAVA-1165 - skip reading feedback on closed connection

The raw connection object can be affected by asynchronous
events, so despite self.connected and self.raw_connection
being correct at the start, the attempt to disconnect cleanly
can fail with an invalid file descriptor ValueError.

Change-Id: Ie882f20c0fa80e15f49c5ce7b46b194a1325872b
parent 8b0d03cd
......@@ -159,16 +159,19 @@ class Connection(object):
logger = logging.getLogger('dispatcher')
if not self.tags:
raise LAVABug("'disconnect' not implemented")
if 'telnet' in self.tags:
logger.info("Disconnecting from telnet: %s", reason)
self.sendcontrol(']')
self.sendline('quit', disconnecting=True)
elif 'ssh' in self.tags:
logger.info("Disconnecting from ssh: %s", reason)
self.sendline('', disconnecting=True)
self.sendline('~.', disconnecting=True)
else:
raise LAVABug("'disconnect' not supported for %s" % self.tags)
try:
if 'telnet' in self.tags:
logger.info("Disconnecting from telnet: %s", reason)
self.sendcontrol(']')
self.sendline('quit', disconnecting=True)
elif 'ssh' in self.tags:
logger.info("Disconnecting from ssh: %s", reason)
self.sendline('', disconnecting=True)
self.sendline('~.', disconnecting=True)
else:
raise LAVABug("'disconnect' not supported for %s" % self.tags)
except ValueError: # protection against file descriptor == -1
logger.debug("Already disconnected")
self.connected = False
self.raw_connection.close(force=True)
self.raw_connection = None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment