appear to have fixed the gui shutdown issue with messages being sent out of order, causing a node to remain with a red box

This commit is contained in:
Blake J. Harnden 2017-07-27 16:03:27 -07:00
parent 14a5d11c4e
commit e2a932698c
2 changed files with 9 additions and 4 deletions

View file

@ -134,6 +134,7 @@ class CoreRequestHandler(SocketServer.BaseRequestHandler):
# remove client from session broker and shutdown if there are no clients # remove client from session broker and shutdown if there are no clients
self.session.broker.session_clients.remove(self) self.session.broker.session_clients.remove(self)
if not self.session.broker.session_clients: if not self.session.broker.session_clients:
logger.info("no session clients left, initiating shutdown")
self.session.shutdown() self.session.shutdown()
return SocketServer.BaseRequestHandler.finish(self) return SocketServer.BaseRequestHandler.finish(self)
@ -672,7 +673,10 @@ class CoreRequestHandler(SocketServer.BaseRequestHandler):
flags = MessageFlags.DELETE.value | MessageFlags.LOCAL.value flags = MessageFlags.DELETE.value | MessageFlags.LOCAL.value
replies.append(coreapi.CoreNodeMessage.pack(flags, tlvdata)) 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) # Node modify message (no add/del flag)
else: else:
try: try:

View file

@ -906,14 +906,15 @@ class Session(object):
and links remain. and links remain.
""" """
node_count = self.get_node_count() node_count = self.get_node_count()
logger.info("checking shutdown for session %d: %d nodes remaining", self.session_id, 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: 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 # TODO: this seems redundant as it occurs during shutdown as well
self.sdt.shutdown() self.sdt.shutdown()
return shutdown
def short_session_id(self): def short_session_id(self):
""" """