]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2212] make sure catching internal error exceptions.
authorJINMEI Tatuya <jinmei@isc.org>
Tue, 23 Oct 2012 07:01:59 +0000 (00:01 -0700)
committerJINMEI Tatuya <jinmei@isc.org>
Thu, 25 Oct 2012 22:03:06 +0000 (15:03 -0700)
with fixing trivial conflicts:
src/bin/auth/tests/datasrc_clients_builder_unittest.cc

src/bin/auth/auth_messages.mes
src/bin/auth/datasrc_clients_mgr.h
src/bin/auth/tests/datasrc_clients_builder_unittest.cc
src/bin/auth/tests/test_datasrc_clients_mgr.cc
src/bin/auth/tests/test_datasrc_clients_mgr.h

index bdbd2fdac120b8cb93a1ecc28dbe9141a996a623..a87c50e9480ab89f78b0b5fba3bdab697579675c 100644 (file)
@@ -349,3 +349,12 @@ This is a debug message output during the processing of a NOTIFY
 request. The zone manager component has been informed of the request,
 but has returned an error response (which is included in the message). The
 NOTIFY request will not be honored.
+
+% AUTH_DATASRC_CLIENTS_BUILDER_COMMAND_ERROR command execution failure: %1
+The separate thread for maintaining data source clients failed to complete
+a comment given by the main thread.  In most cases this is some kind of
+configuration or temporary errors such as an attempt of non existent zone
+or temporary DB connection failure.  So the event is just logged and the
+thread keeps running.  In some rare cases, however, this may indicate
+an internal bug and it may be better to restart the entire program.
+So the log message should be carefully examined.
index 90ed56a44b5f9e9250513d03dfeafa193e872a9b..e7a2048db9779f9a6ec1a848d4403cad1dc26bf5 100644 (file)
@@ -419,7 +419,13 @@ DataSrcClientsBuilderBase<MutexType, CondVarType>::run() {
             } // the lock is released here.
 
             while (keep_running && !current_commands.empty()) {
-                keep_running = handleCommand(current_commands.front());
+                try {
+                    keep_running = handleCommand(current_commands.front());;
+                } catch (const InternalCommandError& e) {
+                    LOG_ERROR(auth_logger,
+                              AUTH_DATASRC_CLIENTS_BUILDER_COMMAND_ERROR).
+                        arg(e.what());
+                }
                 current_commands.pop_front();
             }
         }
index 5d237d5a06f81b612817ce59edf2f70dad8582ef..037ced71b6c32ffe85660d8e98683303100cf999 100644 (file)
@@ -104,6 +104,11 @@ TEST_F(DataSrcClientsBuilderTest, exception) {
     command_queue.push_back(noop_cmd);
     queue_mutex.throw_from_noop = TestMutex::INTEGER;
     EXPECT_DEATH_IF_SUPPORTED({builder.run();}, "");
+
+    command_queue.push_back(noop_cmd);
+    command_queue.push_back(shutdown_cmd); // we need to stop the loop
+    queue_mutex.throw_from_noop = TestMutex::INTERNAL;
+    builder.run();
 }
 
 TEST_F(DataSrcClientsBuilderTest, condWait) {
index 44c8b7d2996e9fc7705d85c2bf381429e1fa0395..82937c0c5e8f23594a86677de2f03b51083997b5 100644 (file)
@@ -50,6 +50,8 @@ TestDataSrcClientsBuilder::doNoop() {
         isc_throw(Exception, "test exception");
     case TestMutex::INTEGER:
         throw 42;
+    case TestMutex::INTERNAL:
+        isc_throw(InternalCommandError, "internal error, should be ignored");
     }
 }
 } // namespace datasrc_clientmgr_internal
index 4abffa2d657271f1e0b51c13b175955f29c5787e..9b1a3672cdc424b902420c957583a599944e6500 100644 (file)
@@ -43,7 +43,8 @@ public:
     // None: no throw from specialized doNoop()
     // EXCLASS: throw some exception class object
     // INTEGER: throw an integer
-    enum ExceptionFromNoop { NONE, EXCLASS, INTEGER };
+    // INTERNAL: internal error (shouldn't terminate the thread)
+    enum ExceptionFromNoop { NONE, EXCLASS, INTEGER, INTERNAL };
 
     TestMutex() : lock_count(0), unlock_count(0), noop_count(0),
                   throw_from_noop(NONE)