]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2855] Add BIND10Server._shutdown_module() method for shutdown processing
authorMukund Sivaraman <muks@isc.org>
Fri, 21 Jun 2013 13:51:54 +0000 (19:21 +0530)
committerMukund Sivaraman <muks@isc.org>
Sun, 30 Jun 2013 15:57:02 +0000 (21:27 +0530)
src/lib/python/isc/server_common/bind10_server.py.in
src/lib/python/isc/server_common/tests/bind10_server_test.py

index 89e051d2752cc81293cb103419987ad2a2575c6e..f46d7724c3ba3eac2d019b85b430bf4a8d2e4f35 100644 (file)
@@ -54,6 +54,12 @@ class BIND10Server:
                      interest on remote modules, etc.  If it raises an
                      exception, the server will be immediately stopped.
                      Parameter: None, Return: None
+      _shutdown_module: can be optionally defined for module-specific
+                        finalization. This is called right before the
+                        module CC session is stopped. If it raises an
+                        exception, the server shutdown will still
+                        continue.
+                        Parameter: None, Return: None
 
     """
     # Will be set to True when the server should stop and shut down.
@@ -181,6 +187,7 @@ class BIND10Server:
                 # propagate it)
                 self._mod_cc.check_command(True)
 
+        self._shutdown_module()
         self._mod_cc.send_stopping()
 
     def _command_handler(self, cmd, args):
@@ -202,6 +209,10 @@ class BIND10Server:
         """The default implementation of the module specific initialization"""
         pass
 
+    def _shutdown_module(self):
+        """The default implementation of the module specific finalization"""
+        pass
+
     def watch_fileno(self, fileno, rcallback=None, wcallback=None, \
                          xcallback=None):
         """Register the fileno for the internal select() call.
index 45d84f801a52b4b27c653267390dfe07f210f32e..f93eed639502d0a2cb662a525091ddd6f081fda8 100755 (executable)
@@ -166,6 +166,16 @@ class TestBIND10Server(unittest.TestCase):
         self.assertTrue(self.__server.shutdown)
         self.assertEqual((0, None), isc.config.parse_answer(answer))
 
+    def test_run_with_shutdown_module(self):
+        """Check run() with module specific shutdown method."""
+        self.shutdown_called = False
+        def check_called():
+            self.shutdown_called = True
+        self.__server.__shutdown = True
+        self.__server._shutdown_module = check_called
+        self.assertEqual(0, self.__server.run('test'))
+        self.assertTrue(self.shutdown_called)
+
     def test_other_command(self):
         self.__server._mod_command_handler = self.__server.mod_command_handler
         answer = self.__server._command_handler('other command', None)