Nir Soffer has uploaded a new change for review. Change subject: clientIF: Clean up shutdown process ......................................................................
clientIF: Clean up shutdown process clientIF.serve used to check if shutdown process has started once every 3 seconds, leading to unwanted delay, that may cause vdsm to be killed before a profile was written. This patch changes clientIF.serve to start the bindings and return, allowing the upper layer to wait for a shutdown signal in a more efficiant way. This allows stopping a profile when shutdown signal is received, before starting the shutdown process, ensuring that a profile is written even if shutdown process got stuck and vdsm is killed. This way is also more safe, as prepareForShutdown is called from the main thread, instead of the signal handler context, where it is not safe to call any code. In particular, setting a threading.Event in this context cause a deadlock. Change-Id: If7bfa9f7da81ffdfb581299cd14ec4edb50be5fb Signed-off-by: Nir Soffer <nsof...@redhat.com> --- M vdsm/clientIF.py M vdsm/vdsm 2 files changed, 10 insertions(+), 7 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/12/26112/1 diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py index b8f1928..48c8860 100644 --- a/vdsm/clientIF.py +++ b/vdsm/clientIF.py @@ -228,11 +228,9 @@ finally: self._shutdownSemaphore.release() - def serve(self): + def start(self): for binding in self.bindings.values(): binding.start() - while self._enabled: - time.sleep(3) def _getUUIDSpecPath(self, uuid): try: diff --git a/vdsm/vdsm b/vdsm/vdsm index 1f72755..652797c 100755 --- a/vdsm/vdsm +++ b/vdsm/vdsm @@ -49,11 +49,11 @@ def serve_clients(log): cif = None irs = None + running = [True] def sigtermHandler(signum, frame): - if cif: - log.debug("Received signal %s" % signum) - cif.prepareForShutdown() + log.debug("Received signal %s" % signum) + running[0] = False def sigusr1Handler(signum, frame): if irs: @@ -75,7 +75,12 @@ from clientIF import clientIF # must import after config is read cif = clientIF.getInstance(irs, log) - cif.serve() + cif.start() + try: + while running[0]: + signal.pause() + finally: + cif.prepareForShutdown() def run(pidfile=None): -- To view, visit http://gerrit.ovirt.org/26112 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If7bfa9f7da81ffdfb581299cd14ec4edb50be5fb Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer <nsof...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches