Browse Source

[640] addressed new review comments

Jelte Jansen 13 years ago
parent
commit
373435e919

+ 1 - 1
src/bin/cmdctl/cmdctl.py.in

@@ -313,7 +313,7 @@ class CommandControl():
             # The 'value' of a specification update can be either
             # The 'value' of a specification update can be either
             # a specification, or None. In the first case, simply
             # a specification, or None. In the first case, simply
             # set it. If it is None, delete the module if it is
             # set it. If it is None, delete the module if it is
-            # known (and ignore otherwise).
+            # known.
             with self._lock:
             with self._lock:
                 if args[1] is None:
                 if args[1] is None:
                     if args[0] in self.modules_spec:
                     if args[0] in self.modules_spec:

+ 12 - 7
src/bin/xfrout/xfrout.py.in

@@ -974,13 +974,18 @@ class XfroutServer:
         self._notifier.shutdown()
         self._notifier.shutdown()
         if self._unix_socket_server:
         if self._unix_socket_server:
             self._unix_socket_server.shutdown()
             self._unix_socket_server.shutdown()
-
+        self._wait_for_threads()
-            # Wait for all threads to terminate
+
-            main_thread = threading.currentThread()
+    def _wait_for_threads(self):
-            for th in threading.enumerate():
+        # Wait for all threads to terminate. this is a call that is only used
-                if th is main_thread:
+        # in shutdown(), but it has its own method, so we can test shutdown
-                    continue
+        # without involving thread operations (the test would override this
-                th.join()
+        # method)
+        main_thread = threading.currentThread()
+        for th in threading.enumerate():
+            if th is main_thread:
+                continue
+            th.join()
 
 
     def command_handler(self, cmd, args):
     def command_handler(self, cmd, args):
         if cmd == "shutdown":
         if cmd == "shutdown":

+ 6 - 12
src/lib/config/ccsession.cc

@@ -490,20 +490,14 @@ ModuleCCSession::ModuleCCSession(
 }
 }
 
 
 ModuleCCSession::~ModuleCCSession() {
 ModuleCCSession::~ModuleCCSession() {
-    // Logging itself can possibly throw too
-    // TODO: add exception-free logging calls
     try {
     try {
-        try {
+        sendStopping();
-            sendStopping();
+    } catch (const std::exception& exc) {
-        } catch (const std::exception& exc) {
+        LOG_ERROR(config_logger,
-            LOG_ERROR(config_logger,
+                  CONFIG_CCSESSION_STOPPING).arg(exc.what());
-                      CONFIG_CCSESSION_STOPPING).arg(exc.what());
-        } catch (...) {
-            LOG_ERROR(config_logger,
-                      CONFIG_CCSESSION_STOPPING_UNKNOWN);
-        }
     } catch (...) {
     } catch (...) {
-        // Can't really do anything at this point...
+        LOG_ERROR(config_logger,
+                  CONFIG_CCSESSION_STOPPING_UNKNOWN);
     }
     }
 };
 };
 
 

+ 0 - 4
src/lib/python/isc/config/ccsession.py

@@ -438,9 +438,6 @@ class UIModuleCCSession(MultiConfigData):
             be run after each interaction (at this moment). It is usually
             be run after each interaction (at this moment). It is usually
             also combined with request_current_config(). For that reason,
             also combined with request_current_config(). For that reason,
             we provide update_specs_and_config() which calls both."""
             we provide update_specs_and_config() which calls both."""
-        # this step should be unnecessary but is the current way cmdctl returns stuff
-        # so changes are needed there to make this clean (we need a command to simply get the
-        # full specs for everything, including commands etc, not separate gets for that)
         specs = self._conn.send_GET('/module_spec')
         specs = self._conn.send_GET('/module_spec')
         self.clear_specifications()
         self.clear_specifications()
         for module in specs.keys():
         for module in specs.keys():
@@ -612,7 +609,6 @@ class UIModuleCCSession(MultiConfigData):
             # answer is either an empty dict (on success), or one
             # answer is either an empty dict (on success), or one
             # containing errors
             # containing errors
             if answer == {}:
             if answer == {}:
-                self.update_specs_and_config()
                 self.clear_local_changes()
                 self.clear_local_changes()
             elif "error" in answer:
             elif "error" in answer:
                 raise ModuleCCSessionError("Error: " + str(answer["error"]) + "\n" + "Configuration not committed")
                 raise ModuleCCSessionError("Error: " + str(answer["error"]) + "\n" + "Configuration not committed")

+ 4 - 9
src/lib/python/isc/config/tests/cfgmgr_test.py

@@ -337,8 +337,10 @@ class TestConfigManager(unittest.TestCase):
         # Send the 'ok' that cfgmgr expects back to the fake queue first
         # Send the 'ok' that cfgmgr expects back to the fake queue first
         self.fake_session.group_sendmsg(my_ok_answer, "ConfigManager")
         self.fake_session.group_sendmsg(my_ok_answer, "ConfigManager")
 
 
+        config_version = config_data.BIND10_CONFIG_DATA_VERSION
         self._handle_msg_helper({ "command": [ "set_config",
         self._handle_msg_helper({ "command": [ "set_config",
-                                               [self.name, new_config] ] },
+                                               [ { "version": config_version,
+                                                 self.name: new_config } ] ] },
                                 my_ok_answer)
                                 my_ok_answer)
 
 
         # The cfgmgr should have eaten the ok message, and sent out an update
         # The cfgmgr should have eaten the ok message, and sent out an update
@@ -349,7 +351,7 @@ class TestConfigManager(unittest.TestCase):
 
 
         # Config should have been updated
         # Config should have been updated
         self.assertEqual(self.cm.config.data, {self.name: new_config,
         self.assertEqual(self.cm.config.data, {self.name: new_config,
-                            'version': config_data.BIND10_CONFIG_DATA_VERSION})
+                            'version': config_version})
 
 
         # and the queue should now be empty again
         # and the queue should now be empty again
         self.assertEqual(len(self.fake_session.message_queue), 0)
         self.assertEqual(len(self.fake_session.message_queue), 0)
@@ -439,13 +441,6 @@ class TestConfigManager(unittest.TestCase):
                                 None)
                                 None)
         self.assertEqual(len(self.fake_session.message_queue), 0)
         self.assertEqual(len(self.fake_session.message_queue), 0)
 
 
-        # If the module does not exist, or is not seen as 'running', the
-        # same message should not cause new messages to be sent
-        self._handle_msg_helper({ "command": [ "stopping",
-                                               { "module_name": "Foo"}] },
-                                None)
-        self.assertEqual(len(self.fake_session.message_queue), 0)
-
     def test_set_config_virtual(self):
     def test_set_config_virtual(self):
         """Test that if the module is virtual, we don't send it over the
         """Test that if the module is virtual, we don't send it over the
            message bus, but call the checking function.
            message bus, but call the checking function.