Browse Source

[master] Merge branch 'trac4293'

Stephen Morris 9 years ago
parent
commit
06204c5d34
2 changed files with 25 additions and 18 deletions
  1. 6 5
      src/lib/dhcpsrv/dhcpsrv_messages.mes
  2. 19 13
      src/lib/dhcpsrv/memfile_lease_mgr.cc

+ 6 - 5
src/lib/dhcpsrv/dhcpsrv_messages.mes

@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 2012-2016 Internet Systems Consortium, Inc. ("ISC")
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -375,10 +375,11 @@ An informational message issued when the Memfile lease database backend
 starts the periodic Lease File Cleanup.
 
 % DHCPSRV_MEMFILE_LFC_UNREGISTER_TIMER_FAILED failed to unregister timer 'memfile-lfc': %1
-This error message is logged when Memfile backend fails to unregister
-timer used for lease file cleanup scheduling. This is highly unlikely
-and indicates programming error. The message include the reason for this
-error.
+This debug message is logged when Memfile backend fails to unregister
+timer used for lease file cleanup scheduling. There are several reasons
+why this could occur, although the most likely cause is that the system
+is being shut down and some other component has unregistered the timer.
+The message includes the reason for this error.
 
 % DHCPSRV_MEMFILE_NEEDS_DOWNGRADING version of lease file: %1 schema is later than version %2
 A warning message issued when the schema of the lease file loaded by the server

+ 19 - 13
src/lib/dhcpsrv/memfile_lease_mgr.cc

@@ -128,23 +128,29 @@ LFCSetup::LFCSetup(asiolink::IntervalTimer::Callback callback)
 LFCSetup::~LFCSetup() {
     try {
         // If we're here it means that either the process is terminating
-        // or we're reconfiguring the server. In the latter case the
-        // thread has been stopped probably, but we need to handle the
-        // former case so we call stopThread explicitly here.
+        // or we're reconfiguring the server. In both cases the thread has
+        // probably been stopped already, but we make sure by calling
+        // stopThread explicitly here.
         timer_mgr_->stopThread();
-        // This may throw exception if the timer hasn't been registered
-        // but if the LFC Setup instance exists it means that the timer
-        // must have been registered or such registration have been
-        // attempted. The registration may fail if the duplicate timer
-        // exists or if the TimerMgr's worker thread is running but if
-        // this happens it is a programming error. In any case, we
-        // don't want exceptions being thrown from the destructor so
-        // we just log an error here.
+
+        // Remove the timer. This will throw an exception if the timer does not
+        // exist.  There are several possible reasons for this:
+        // a) It hasn't been registered (although if the LFC Setup instance
+        //    exists it means that the timer must have been registered or that
+        //    such registration has been attempted).
+        // b) The registration may fail if the duplicate timer exists or if the
+        //    TimerMgr's worker thread is running but if this happens it is a
+        //    programming error.
+        // c) The program is shutting down and the timer has been removed by
+        //    another component.
         timer_mgr_->unregisterTimer("memfile-lfc");
 
     } catch (const std::exception& ex) {
-        LOG_ERROR(dhcpsrv_logger, DHCPSRV_MEMFILE_LFC_UNREGISTER_TIMER_FAILED)
-            .arg(ex.what());
+        // We don't want exceptions being thrown from the destructor so we just
+        // log a message here.  The message is logged at debug severity as
+        // we don't want an error message output during shutdown.
+        LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE,
+                  DHCPSRV_MEMFILE_LFC_UNREGISTER_TIMER_FAILED).arg(ex.what());
     }
 }