From ea4f6ba518cb90b40c08dc096d6c9225c0033e83 Mon Sep 17 00:00:00 2001 From: tgoff0 Date: Fri, 22 May 2015 00:54:28 +0000 Subject: [PATCH] fixed issues with shutting down a distributed batch mode --- daemon/core/session.py | 17 +++++++++-------- daemon/sbin/core-daemon | 2 ++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/daemon/core/session.py b/daemon/core/session.py index 2d4fed92..f572a51e 100644 --- a/daemon/core/session.py +++ b/daemon/core/session.py @@ -241,19 +241,20 @@ class Session(object): time.ctime())) self.writestate(state) self.runhook(state) - if self.isconnected() and sendevent: + if sendevent: tlvdata = "" tlvdata += coreapi.CoreEventTlv.pack(coreapi.CORE_TLV_EVENT_TYPE, state) msg = coreapi.CoreEventMessage.pack(0, tlvdata) # send Event Message to connected handlers (e.g. GUI) - try: - if returnevent: - replies.append(msg) - else: - self.broadcastraw(None, msg) - except Exception, e: - self.warn("Error sending Event Message: %s" % e) + if self.isconnected(): + try: + if returnevent: + replies.append(msg) + else: + self.broadcastraw(None, msg) + except Exception, e: + self.warn("Error sending Event Message: %s" % e) # also inform slave servers tmp = self.broker.handlerawmsg(msg) return replies diff --git a/daemon/sbin/core-daemon b/daemon/sbin/core-daemon index 5e1fe0a1..bb05211c 100755 --- a/daemon/sbin/core-daemon +++ b/daemon/sbin/core-daemon @@ -1245,6 +1245,8 @@ class CoreRequestHandler(SocketServer.BaseRequestHandler): self.info("request to terminate session %s" % sid) session.setstate(state=coreapi.CORE_EVENT_DATACOLLECT_STATE, info=True, sendevent=True) + session.setstate(state=coreapi.CORE_EVENT_SHUTDOWN_STATE, + info=True, sendevent=True) session.shutdown() else: self.warn("unhandled session flags for session %s" % sid)