]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[github41] Initialize logging before reading configuration
authorTomek Mrugalski <tomasz@isc.org>
Thu, 8 Feb 2018 04:49:18 +0000 (04:49 +0000)
committerTomek Mrugalski <tomasz@isc.org>
Thu, 8 Feb 2018 04:49:18 +0000 (04:49 +0000)
More precisely, before reading the "Dhcp4" and "Dhcp6" configurations to
log errors thrown because of any configuration loading issues.

# Conflicts:
# src/bin/dhcp4/kea_controller.cc
# src/bin/dhcp6/kea_controller.cc

src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp6/ctrl_dhcp6_srv.cc

index 6a82e07be5030f3dfb31638ead02990e8e9bca33..c30e6e843daac7265da1a4e3d74e9619ae0e441a 100644 (file)
@@ -319,6 +319,10 @@ ControlledDhcpv4Srv::commandConfigSetHandler(const string&,
     Daemon::configureLogger(args->get("Logging"),
                             CfgMgr::instance().getStagingCfg());
 
+    // Let's apply the new logging. We do it early, so we'll be able to print
+    // out what exactly is wrong with the new socnfig in case of problems.
+    CfgMgr::instance().getStagingCfg()->applyLoggingCfg();
+
     // Now we configure the server proper.
     ConstElementPtr result = processConfig(dhcp4);
 
@@ -332,6 +336,11 @@ ControlledDhcpv4Srv::commandConfigSetHandler(const string&,
 
         // Use new configuration.
         CfgMgr::instance().commit();
+    } else {
+        // Ok, we applied the logging from the upcoming configuration, but
+        // there were problems with the config. As such, we need to back off
+        // and revert to the previous logging configuration.
+        CfgMgr::instance().getCurrentCfg()->applyLoggingCfg();
     }
 
     return (result);
index dceb6367fbd5474bcc1627afccd23ee1d17a0ea6..4f333243fb7aec0df42da0e3303b3dc81b34ca59 100644 (file)
@@ -322,6 +322,10 @@ ControlledDhcpv6Srv::commandConfigSetHandler(const string&,
     Daemon::configureLogger(args->get("Logging"),
                             CfgMgr::instance().getStagingCfg());
 
+    // Let's apply the new logging. We do it early, so we'll be able to print
+    // out what exactly is wrong with the new socnfig in case of problems.
+    CfgMgr::instance().getStagingCfg()->applyLoggingCfg();
+
     // Now we configure the server proper.
     ConstElementPtr result = processConfig(dhcp6);
 
@@ -335,6 +339,11 @@ ControlledDhcpv6Srv::commandConfigSetHandler(const string&,
 
         // Use new configuration.
         CfgMgr::instance().commit();
+    } else {
+        // Ok, we applied the logging from the upcoming configuration, but
+        // there were problems with the config. As such, we need to back off
+        // and revert to the previous logging configuration.
+        CfgMgr::instance().getCurrentCfg()->applyLoggingCfg();
     }
 
     return (result);