Browse Source

[5090] Applied propose fix by stopping the IO service on run exists

Francis Dupont 8 years ago
parent
commit
9485112d93
1 changed files with 13 additions and 8 deletions
  1. 13 8
      src/bin/agent/ctrl_agent_process.cc

+ 13 - 8
src/bin/agent/ctrl_agent_process.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2016-2017 Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // 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
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -31,15 +31,20 @@ void
 CtrlAgentProcess::run() {
 CtrlAgentProcess::run() {
     LOG_INFO(agent_logger, CTRL_AGENT_STARTED).arg(VERSION);
     LOG_INFO(agent_logger, CTRL_AGENT_STARTED).arg(VERSION);
 
 
-    while (!shouldShutdown()) {
-        try {
+    try {
+        while (!shouldShutdown()) {
             getIoService()->run_one();
             getIoService()->run_one();
-
-        } catch (const std::exception& ex) {
-            LOG_FATAL(agent_logger, CTRL_AGENT_FAILED).arg(ex.what());
-            isc_throw(DProcessBaseError,
-                      "Process run method failed: " << ex.what());
         }
         }
+        stopIOService();
+    } catch (const std::exception& ex) {
+        LOG_FATAL(agent_logger, CTRL_AGENT_FAILED).arg(ex.what());
+        try {
+            stopIOService();
+        } catch (...) {
+            // Ignore double errors
+        }
+        isc_throw(DProcessBaseError,
+                  "Process run method failed: " << ex.what());
     }
     }
 
 
     LOG_DEBUG(agent_logger, DBGLVL_START_SHUT, CTRL_AGENT_RUN_EXIT);
     LOG_DEBUG(agent_logger, DBGLVL_START_SHUT, CTRL_AGENT_RUN_EXIT);