]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3112] catch all exception when running IOService run, run_one and poll
authorRazvan Becheriu <razvan@isc.org>
Mon, 30 Oct 2023 19:24:50 +0000 (21:24 +0200)
committerRazvan Becheriu <razvan@isc.org>
Mon, 11 Dec 2023 07:52:05 +0000 (09:52 +0200)
src/lib/asiolink/io_service_thread_pool.cc
src/lib/process/d_controller.cc

index 8baf7208407f50aa7615186f8ca246f7d7c725a3..8919385cffd67a8f58e0e6135cdd0b4bc64c35a2 100644 (file)
@@ -164,7 +164,12 @@ IoServiceThreadPool::setState(State state) {
     case State::PAUSED: {
         // Stop IOService.
         if (!io_service_->stopped()) {
-            io_service_->poll();
+            try {
+                io_service_->poll();
+            } catch (...) {
+                // Catch all exceptions.
+                // Logging is not available.
+            }
             io_service_->stop();
         }
 
@@ -180,7 +185,12 @@ IoServiceThreadPool::setState(State state) {
     case State::STOPPED: {
         // Stop IOService.
         if (!io_service_->stopped()) {
-            io_service_->poll();
+            try {
+                io_service_->poll();
+            } catch (...) {
+                // Catch all exceptions.
+                // Logging is not available.
+            }
             io_service_->stop();
         }
 
@@ -215,8 +225,13 @@ IoServiceThreadPool::threadWork() {
                 }
             }
 
-            // Run the IOService.
-            io_service_->run();
+            try {
+                // Run the IOService.
+                io_service_->run();
+            } catch (...) {
+                // Catch all exceptions.
+                // Logging is not available.
+            }
 
             {
                 std::unique_lock<std::mutex> lck(mutex_);
index 420442c132c09c0cabde2a023723d50da8dfd8a3..26f371fb8ec8dcceffd3bb4b8a1bd9017a729ac2 100644 (file)
@@ -837,7 +837,13 @@ DControllerBase::~DControllerBase() {
     }
 
     io_signal_set_.reset();
-    getIOService()->poll();
+    try {
+        getIOService()->poll();
+    } catch (...) {
+        // Don't want to throw exceptions from the destructor. The process
+        // is shutting down anyway.
+        ;
+    }
 }
 
 std::string