Parcourir la source

More fixes of stopped asio::io_service

It stops itself when there's no more work and tells nobody about it. So
we need detect it was stopped (there seem to be no other way than trying
and looking at how many events it processed), reset and try again.

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/vorner-recursor-config@3352 e5f2f494-b856-4b98-b285-d166d9295462
Michal Vaner il y a 14 ans
Parent
commit
fec9e5c111
1 fichiers modifiés avec 11 ajouts et 2 suppressions
  1. 11 2
      src/lib/asiolink/asiolink.cc

+ 11 - 2
src/lib/asiolink/asiolink.cc

@@ -187,12 +187,21 @@ IOService::clearServers() {
 
 void
 IOService::run() {
-    impl_->io_service_.run();
+    if (!impl_->io_service_.run()) {
+        // We got the io_service in stopped state and it didn't work
+        // Reset it and try again
+        impl_->io_service_.reset();
+        impl_->io_service_.run();
+    }
 }
 
 void
 IOService::run_one() {
-    impl_->io_service_.run_one();
+    if (!impl_->io_service_.run_one()) {
+        // Same as in run() - we got it in stopped state
+        impl_->io_service_.reset();
+        impl_->io_service_.run_one();
+    }
 }
 
 void