Skip to content

Commit 1a0a6f9

Browse files
author
Razvan Becheriu
committed
[#3300] revert fix and move poll
1 parent 9e0aa1c commit 1a0a6f9

File tree

4 files changed

+28
-30
lines changed

4 files changed

+28
-30
lines changed

src/bin/dhcp4/ctrl_dhcp4_srv.cc

+11-12
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,16 @@ ControlledDhcpv4Srv::commandConfigSetHandler(const string&,
450450
LOG_FATAL(dhcp4_logger, DHCP4_CONFIG_UNRECOVERABLE_ERROR);
451451
}
452452

453+
/// Let postponed hook initializations to run.
454+
try {
455+
getIOService()->poll();
456+
} catch (const std::exception& ex) {
457+
std::ostringstream err;
458+
err << "Error initializing hooks: "
459+
<< ex.what();
460+
return (isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str()));
461+
}
462+
453463
return (result);
454464
}
455465

@@ -913,7 +923,7 @@ ControlledDhcpv4Srv::processConfig(isc::data::ConstElementPtr config) {
913923

914924
// Allow DB reconnect on startup. The database connection parameters specify
915925
// respective details.
916-
std::shared_ptr<DbConnectionInitWithRetry> dbr(new DbConnectionInitWithRetry());
926+
DbConnectionInitWithRetry retry;
917927

918928
// Single stream instance used in all error clauses
919929
std::ostringstream err;
@@ -1092,17 +1102,6 @@ ControlledDhcpv4Srv::processConfig(isc::data::ConstElementPtr config) {
10921102
return (isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str()));
10931103
}
10941104

1095-
dbr.reset();
1096-
1097-
/// Let postponed hook initializations to run.
1098-
try {
1099-
ControlledDhcpv4Srv::getInstance()->getIOService()->poll();
1100-
} catch (const std::exception& ex) {
1101-
err << "Error initializing hooks: "
1102-
<< ex.what();
1103-
return (isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str()));
1104-
}
1105-
11061105
return (answer);
11071106
}
11081107

src/bin/dhcp4/tests/hooks_unittest.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -4052,7 +4052,7 @@ TEST_F(LoadUnloadDhcpv4SrvTest, startServiceFail) {
40524052
// section which loads the callout library #4, which implements
40534053
// dhcp4_srv_configured callout and a failing start service.
40544054
string config_str =
4055-
"{"
4055+
"{ \"Dhcp4\": {"
40564056
" \"interfaces-config\": {"
40574057
" \"interfaces\": [ ]"
40584058
" },"
@@ -4069,13 +4069,13 @@ TEST_F(LoadUnloadDhcpv4SrvTest, startServiceFail) {
40694069
" \"library\": \"" + std::string(CALLOUT_LIBRARY_4) + "\""
40704070
" }"
40714071
" ]"
4072-
"}";
4072+
"} }";
40734073

40744074
ConstElementPtr config = Element::fromJSON(config_str);
40754075

40764076
// Configure the server.
40774077
ConstElementPtr answer;
4078-
ASSERT_NO_THROW(answer = srv->processConfig(config));
4078+
ASSERT_NO_THROW(answer = srv->processCommand("config-set", config));
40794079

40804080
// Make sure there was an error with expected message.
40814081
int status_code;

src/bin/dhcp6/ctrl_dhcp6_srv.cc

+11-12
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,16 @@ ControlledDhcpv6Srv::commandConfigSetHandler(const string&,
452452
LOG_FATAL(dhcp6_logger, DHCP6_CONFIG_UNRECOVERABLE_ERROR);
453453
}
454454

455+
/// Let postponed hook initializations to run.
456+
try {
457+
getIOService()->poll();
458+
} catch (const std::exception& ex) {
459+
std::ostringstream err;
460+
err << "Error initializing hooks: "
461+
<< ex.what();
462+
return (isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str()));
463+
}
464+
455465
return (result);
456466
}
457467

@@ -918,7 +928,7 @@ ControlledDhcpv6Srv::processConfig(isc::data::ConstElementPtr config) {
918928

919929
// Allow DB reconnect on startup. The database connection parameters specify
920930
// respective details.
921-
std::shared_ptr<DbConnectionInitWithRetry> dbr(new DbConnectionInitWithRetry());
931+
DbConnectionInitWithRetry retry;
922932

923933
// Single stream instance used in all error clauses
924934
std::ostringstream err;
@@ -1112,17 +1122,6 @@ ControlledDhcpv6Srv::processConfig(isc::data::ConstElementPtr config) {
11121122
return (isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str()));
11131123
}
11141124

1115-
dbr.reset();
1116-
1117-
/// Let postponed hook initializations to run.
1118-
try {
1119-
ControlledDhcpv6Srv::getInstance()->getIOService()->poll();
1120-
} catch (const std::exception& ex) {
1121-
err << "Error initializing hooks: "
1122-
<< ex.what();
1123-
return (isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str()));
1124-
}
1125-
11261125
return (answer);
11271126
}
11281127

src/bin/dhcp6/tests/hooks_unittest.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -5846,7 +5846,7 @@ TEST_F(LoadUnloadDhcpv6SrvTest, startServiceFail) {
58465846
// section which loads the callout library #4, which implements
58475847
// dhcp6_srv_configured callout and a failing start service.
58485848
string config_str =
5849-
"{"
5849+
"{ \"Dhcp6\": {"
58505850
" \"interfaces-config\": {"
58515851
" \"interfaces\": [ ]"
58525852
" },"
@@ -5864,13 +5864,13 @@ TEST_F(LoadUnloadDhcpv6SrvTest, startServiceFail) {
58645864
" \"library\": \"" + std::string(CALLOUT_LIBRARY_4) + "\""
58655865
" }"
58665866
" ]"
5867-
"}";
5867+
"} }";
58685868

58695869
ConstElementPtr config = Element::fromJSON(config_str);
58705870

58715871
// Configure the server.
58725872
ConstElementPtr answer;
5873-
ASSERT_NO_THROW(answer = srv->processConfig(config));
5873+
ASSERT_NO_THROW(answer = srv->processCommand("config-set", config));
58745874

58755875
// Make sure there was an error with expected message.
58765876
int status_code;

0 commit comments

Comments
 (0)