Browse 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 14 years ago
parent
commit
fec9e5c111
1 changed files with 11 additions and 2 deletions
  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