From 018e3c145176ba226f90460c85145aed1fc204f6 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Mon, 16 Feb 2015 17:40:13 +0100 Subject: [PATCH] Fix IOU closing --- gns3server/modules/iou/iou_vm.py | 16 +++++++++------- gns3server/modules/iou/ioucon.py | 1 + gns3server/modules/vpcs/vpcs_vm.py | 1 + 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gns3server/modules/iou/iou_vm.py b/gns3server/modules/iou/iou_vm.py index 6d2caf55..b3e6c855 100644 --- a/gns3server/modules/iou/iou_vm.py +++ b/gns3server/modules/iou/iou_vm.py @@ -110,8 +110,10 @@ class IOUVM(BaseVM): else: self._console = self._manager.port_manager.get_free_console_port() + @asyncio.coroutine def close(self): + yield from self.stop() if self._console: self._manager.port_manager.release_console_port(self._console) self._console = None @@ -498,14 +500,14 @@ class IOUVM(BaseVM): Stops the IOU process. """ - # stop console support - if self._ioucon_thread: - self._ioucon_thread_stop_event.set() - if self._ioucon_thread.is_alive(): - self._ioucon_thread.join(timeout=3.0) # wait for the thread to free the console port - self._ioucon_thread = None - if self.is_running(): + # stop console support + if self._ioucon_thread: + self._ioucon_thread_stop_event.set() + if self._ioucon_thread.is_alive(): + self._ioucon_thread.join(timeout=3.0) # wait for the thread to free the console port + self._ioucon_thread = None + self._terminate_process_iou() try: yield from asyncio.wait_for(self._iou_process.wait(), timeout=3) diff --git a/gns3server/modules/iou/ioucon.py b/gns3server/modules/iou/ioucon.py index 6dbd782d..d4889433 100644 --- a/gns3server/modules/iou/ioucon.py +++ b/gns3server/modules/iou/ioucon.py @@ -357,6 +357,7 @@ class TelnetServer(Console): sock_fd.listen(socket.SOMAXCONN) self.sock_fd = sock_fd log.info("Telnet server ready for connections on {}:{}".format(self.addr, self.port)) + log.info(self.stop_event.is_set()) return self diff --git a/gns3server/modules/vpcs/vpcs_vm.py b/gns3server/modules/vpcs/vpcs_vm.py index 1b85bf1f..0d0bab91 100644 --- a/gns3server/modules/vpcs/vpcs_vm.py +++ b/gns3server/modules/vpcs/vpcs_vm.py @@ -73,6 +73,7 @@ class VPCSVM(BaseVM): else: self._console = self._manager.port_manager.get_free_console_port() + @asyncio.coroutine def close(self): self._terminate_process()