From 5e591459481d1c0f3a42ab9f5902289f3bc220c5 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Thu, 26 Feb 2015 15:09:15 +0100 Subject: [PATCH] If you type reload inside iou you are no longer disconnected --- gns3server/modules/iou/ioucon.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/gns3server/modules/iou/ioucon.py b/gns3server/modules/iou/ioucon.py index f5496da0..2b5556ab 100644 --- a/gns3server/modules/iou/ioucon.py +++ b/gns3server/modules/iou/ioucon.py @@ -159,10 +159,6 @@ class Console: raise NotImplementedError("Only routers have fileno()") -class Router: - pass - - class TTY(Console): def read(self, fileno, bufsize): @@ -370,7 +366,7 @@ class TelnetServer(Console): return False -class IOU(Router): +class IOU: def __init__(self, ttyC, ttyS, stop_event): self.ttyC = ttyC @@ -616,8 +612,13 @@ def start_ioucon(cmdline_args, stop_event): try: if args.telnet_server: with TelnetServer(addr, nport, stop_event) as console: - with IOU(ttyC, ttyS, stop_event) as router: - send_recv_loop(console, router, b'', stop_event) + # We loop inside the Telnet server otherwise the client is disconnected when user use the reload command inside a terminal + while not stop_event.is_set(): + try: + with IOU(ttyC, ttyS, stop_event) as router: + send_recv_loop(console, router, b'', stop_event) + except ConnectionRefusedError: + pass else: with IOU(ttyC, ttyS, stop_event) as router, TTY() as console: send_recv_loop(console, router, esc_char, stop_event)