Commit 660d7d78 authored by hanfeng's avatar hanfeng
Browse files

[trac775] fix the bug that if name server bind port failed, name server will...

[trac775] fix the bug that if name server bind port failed, name server will exist, in that case, we can't reset the port number
parent e23c4b1e
......@@ -95,11 +95,17 @@ installListenAddresses(const AddressList& newAddresses,
catch (const exception& e) {
* We couldn't set it. So return it back. If that fails as well,
* we have a problem.
* If one of the addresses isn't set successfully, we will restore
* the old addresses, the behavior is that either all address are
* set successuflly or none of them will be used. whether this
* behavior is user desired, maybe we need revisited it later. And
* if address setting is more smarter, it should check whether some
* part of the new address already in used to avoid interuption the
* service.
* If that fails, bad luck, but we are useless anyway, so just die
* and let boss start us again.
* If the address setting still failed, we can live with it, since
* user will get error info, command control can be used to set new
* address. So we just catch the exception without propagating outside
dlog(string("Unable to set new address: ") + e.what(), true);
try {
......@@ -108,9 +114,7 @@ installListenAddresses(const AddressList& newAddresses,
catch (const exception& e2) {
dlog("Unable to recover from error;", true);
dlog(string("Rollback failed with: ") + e2.what(), true);
throw; // Let it fly a little bit further
......@@ -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_THROW(installListenAddresses(invalid_, store_, dnss_), IOError);
EXPECT_NO_THROW(installListenAddresses(invalid_, store_, dnss_));
checkAddresses(valid_, "After rollback");
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment