new file: changelog_unreleased/4145-an-empty-config-test-command-can-affect-ha-connections
modified: src/bin/dhcp4/json_config_parser.cc
modified: src/bin/dhcp6/json_config_parser.cc
modified: src/lib/util/multi_threading_mgr.h
modified: src/lib/util/tests/multi_threading_mgr_unittest.cc
--- /dev/null
+[bug] tmark
+ Corrected an issue that was causing an
+ HA peer to not restart its dedicated listener
+ after handling a config-test command.
+ Applies to both kea-dhcp4 and kea-dhcp6.
+ (Gitlab #4145)
LOG_DEBUG(dhcp4_logger, DBG_DHCP4_COMMAND, DHCP4_CONFIG_START)
.arg(server.redactConfig(config_set)->str());
- if (check_only) {
- MultiThreadingMgr::instance().setTestMode(true);
- }
+ MtTestMode();
auto answer = processDhcp4Config(config_set);
LOG_DEBUG(dhcp6_logger, DBG_DHCP6_COMMAND, DHCP6_CONFIG_START)
.arg(server.redactConfig(config_set)->str());
- if (check_only) {
- MultiThreadingMgr::instance().setTestMode(true);
- }
+ MtTestMode();
auto answer = processDhcp6Config(config_set);
virtual ~MultiThreadingCriticalSection();
};
+/// @brief RAII wrapper for MT test mode.
+///
+/// The constructor enables test mode, the destructor disables it.
+class MtTestMode : public boost::noncopyable {
+public:
+ MtTestMode() {
+ MultiThreadingMgr::instance().setTestMode(true);
+ }
+
+ ~MtTestMode() {
+ MultiThreadingMgr::instance().setTestMode(false);
+ }
+};
+
} // namespace util
} // namespace isc
// Retest CriticalSections.
runCriticalSections({}, {});
}
+
+/// @brief Verifies that the RAII wrapper for MT test mode works.
+TEST_F(CriticalSectionCallbackTest, mtTestMode) {
+ ASSERT_FALSE(MultiThreadingMgr::instance().isTestMode());
+ {
+ MtTestMode mt;
+ ASSERT_TRUE(MultiThreadingMgr::instance().isTestMode());
+ }
+
+ ASSERT_FALSE(MultiThreadingMgr::instance().isTestMode());
+}