ensured the shutdown event doesn't get sent until all node delete replies have been sent

This commit is contained in:
Rod A Santiago 2016-12-14 17:24:21 -08:00
parent 3f6040a0f3
commit 6e610f4309

View file

@ -306,6 +306,7 @@ class CoreRequestHandler(SocketServer.BaseRequestHandler):
self.msgq = []
self.msgcv = threading.Condition()
self.nodestatusreq = {}
self._shutdownlock = threading.Lock()
numthreads = int(server.cfg['numthreads'])
if numthreads < 1:
raise ValueError, \
@ -666,6 +667,8 @@ class CoreRequestHandler(SocketServer.BaseRequestHandler):
n = self.session.obj(nodenum)
except KeyError:
pass
with self._shutdownlock:
self.session.delobj(nodenum)
if msg.flags & coreapi.CORE_API_STR_FLAG:
@ -674,6 +677,7 @@ class CoreRequestHandler(SocketServer.BaseRequestHandler):
nodenum)
flags = coreapi.CORE_API_DEL_FLAG | coreapi.CORE_API_LOC_FLAG
replies.append(coreapi.CoreNodeMessage.pack(flags, tlvdata))
for reply in self.session.checkshutdown():
replies.append(reply)
# Node modify message (no add/del flag)