From a434cd446c015980dad5ff97ac5ae33e007a5bb3 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Fri, 2 Oct 2009 20:03:33 +0000 Subject: Fix nasty core hang, which would manifest itself as a lockup upon shutdown for bcfg2-{server,info,admin} The root cause of this issue was our use of external threads. Without a channel for data requesting plugin (and hence thread) shutdown, plugin threads would continue, unabated, forever. This would cause the python interpreter to hang forever waiting for a futex. Added a new shutdown method to Bcfg2.Server.Plugin.Plugin which sets a state flag upon shutdown request. Plugin threads must cycle periodically, even if no work is available, to ensure that the shutdown flag is honored in a reasonable amount of time. Also, the shutdown method is triggered using atexit. This means that scripts may need to explicitly sys.exit or raise SystemExit, depending on circumstances. This addresses at least one, but probably more tickets, however I am currently offline. git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5472 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Core.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/lib/Server/Core.py') diff --git a/src/lib/Server/Core.py b/src/lib/Server/Core.py index 758241c98..acee2542f 100644 --- a/src/lib/Server/Core.py +++ b/src/lib/Server/Core.py @@ -1,6 +1,7 @@ '''Bcfg2.Server.Core provides the runtime support for bcfg2 modules''' __revision__ = '$Revision$' +import atexit import logging import lxml.etree import select @@ -55,6 +56,7 @@ class Core(Component): self.revision = '-1' self.password = password self.encoding = encoding + atexit.register(self.shutdown) if '' in plugins: plugins.remove('') @@ -132,7 +134,10 @@ class Core(Component): except: logger.error("Unexpected instantiation failure for plugin %s" % (plugin), exc_info=1) - + + def shutdown(self): + for plugin in self.plugins.values(): + plugin.shutdown() def validate_data(self, metadata, data, base_cls): for plugin in self.plugins.values(): -- cgit v1.2.3-1-g7c22