From e2a932698c30277f72595b1cfcf4b170da2072e5 Mon Sep 17 00:00:00 2001 From: "Blake J. Harnden" Date: Thu, 27 Jul 2017 16:03:27 -0700 Subject: [PATCH] appear to have fixed the gui shutdown issue with messages being sent out of order, causing a node to remain with a red box --- daemon/core/corehandlers.py | 6 +++++- daemon/core/session.py | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/daemon/core/corehandlers.py b/daemon/core/corehandlers.py index 8f6a4b03..15c187c1 100644 --- a/daemon/core/corehandlers.py +++ b/daemon/core/corehandlers.py @@ -134,6 +134,7 @@ class CoreRequestHandler(SocketServer.BaseRequestHandler): # remove client from session broker and shutdown if there are no clients self.session.broker.session_clients.remove(self) if not self.session.broker.session_clients: + logger.info("no session clients left, initiating shutdown") self.session.shutdown() return SocketServer.BaseRequestHandler.finish(self) @@ -672,7 +673,10 @@ class CoreRequestHandler(SocketServer.BaseRequestHandler): flags = MessageFlags.DELETE.value | MessageFlags.LOCAL.value replies.append(coreapi.CoreNodeMessage.pack(flags, tlvdata)) - self.session.check_shutdown() + if self.session.check_shutdown(): + tlvdata = "" + tlvdata += coreapi.CoreEventTlv.pack(EventTlvs.TYPE.value, self.session.state) + replies.append(coreapi.CoreEventMessage.pack(0, tlvdata)) # Node modify message (no add/del flag) else: try: diff --git a/daemon/core/session.py b/daemon/core/session.py index e6ed3214..d28e6574 100644 --- a/daemon/core/session.py +++ b/daemon/core/session.py @@ -906,14 +906,15 @@ class Session(object): and links remain. """ node_count = self.get_node_count() - logger.info("checking shutdown for session %d: %d nodes remaining", self.session_id, node_count) - # TODO: do we really want a check that finds 0 nodes to initiate a shutdown state? + shutdown = False if node_count == 0: - self.set_state(state=EventTypes.SHUTDOWN_STATE.value, send_event=True) + shutdown = True + self.set_state(state=EventTypes.SHUTDOWN_STATE.value) # TODO: this seems redundant as it occurs during shutdown as well self.sdt.shutdown() + return shutdown def short_session_id(self): """