From: JINMEI Tatuya Date: Tue, 23 Oct 2012 07:01:59 +0000 (-0700) Subject: [2212] make sure catching internal error exceptions. X-Git-Tag: trac2487_base~23^2~20 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c37eaa23d920b79d3f344c8fbafbdcda37231b47;p=thirdparty%2Fkea.git [2212] make sure catching internal error exceptions. with fixing trivial conflicts: src/bin/auth/tests/datasrc_clients_builder_unittest.cc --- diff --git a/src/bin/auth/auth_messages.mes b/src/bin/auth/auth_messages.mes index bdbd2fdac1..a87c50e948 100644 --- a/src/bin/auth/auth_messages.mes +++ b/src/bin/auth/auth_messages.mes @@ -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. diff --git a/src/bin/auth/datasrc_clients_mgr.h b/src/bin/auth/datasrc_clients_mgr.h index 90ed56a44b..e7a2048db9 100644 --- a/src/bin/auth/datasrc_clients_mgr.h +++ b/src/bin/auth/datasrc_clients_mgr.h @@ -419,7 +419,13 @@ DataSrcClientsBuilderBase::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(); } } diff --git a/src/bin/auth/tests/datasrc_clients_builder_unittest.cc b/src/bin/auth/tests/datasrc_clients_builder_unittest.cc index 5d237d5a06..037ced71b6 100644 --- a/src/bin/auth/tests/datasrc_clients_builder_unittest.cc +++ b/src/bin/auth/tests/datasrc_clients_builder_unittest.cc @@ -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) { diff --git a/src/bin/auth/tests/test_datasrc_clients_mgr.cc b/src/bin/auth/tests/test_datasrc_clients_mgr.cc index 44c8b7d299..82937c0c5e 100644 --- a/src/bin/auth/tests/test_datasrc_clients_mgr.cc +++ b/src/bin/auth/tests/test_datasrc_clients_mgr.cc @@ -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 diff --git a/src/bin/auth/tests/test_datasrc_clients_mgr.h b/src/bin/auth/tests/test_datasrc_clients_mgr.h index 4abffa2d65..9b1a3672cd 100644 --- a/src/bin/auth/tests/test_datasrc_clients_mgr.h +++ b/src/bin/auth/tests/test_datasrc_clients_mgr.h @@ -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)