Browse Source

trac[775] fix the bug that if new configure failed, we need notify configure manager

hanfeng 14 years ago
parent
commit
44f4b82933

+ 8 - 2
src/bin/auth/main.cc

@@ -172,9 +172,15 @@ main(int argc, char* argv[]) {
         // all initial configurations, but as a short term workaround we
         // handle the traditional "database_file" setup by directly calling
         // updateConfig().
+        // if server load configure failed, we won't exit, give user second chance
+        // to correct the configure.
         auth_server->setConfigSession(config_session);
-        configureAuthServer(*auth_server, config_session->getFullConfig());
-        auth_server->updateConfig(ElementPtr());
+        try {
+            configureAuthServer(*auth_server, config_session->getFullConfig());
+            auth_server->updateConfig(ElementPtr());
+        } catch (const isc::Exception& ex) {
+            cout << "[bin10-auth] Server load config failed:" << ex.what() << endl;
+        }
 
         if (uid != NULL) {
             changeUser(uid);

+ 3 - 0
src/lib/server_common/portconfig.cc

@@ -115,6 +115,9 @@ installListenAddresses(const AddressList& newAddresses,
             dlog("Unable to recover from error;", true);
             dlog(string("Rollback failed with: ") + e2.what(), true);
         }
+        //Anyway the new configure has problem, we need to notify configure
+        //manager the new configure doesn't work
+        throw;
     }
 }
 

+ 1 - 1
src/lib/server_common/tests/portconfig_unittest.cc

@@ -175,7 +175,7 @@ TEST_F(InstallListenAddresses, rollback) {
     EXPECT_NO_THROW(installListenAddresses(valid_, store_, dnss_));
     checkAddresses(valid_, "Before rollback");
     // This should not bind them, but should leave the original addresses
-    EXPECT_NO_THROW(installListenAddresses(invalid_, store_, dnss_));
+    EXPECT_THROW(installListenAddresses(invalid_, store_, dnss_), exception);
     checkAddresses(valid_, "After rollback");
 }