[svn] commit: r3422 - in /branches/vorner-recursor-config/src/lib: asiolink/asiolink.cc cc/session.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Nov 3 10:09:36 UTC 2010


Author: vorner
Date: Wed Nov  3 10:09:36 2010
New Revision: 3422

Log:
Better way to stop io_service from running out of work

Instead of detecting when it stopped, use dummy work object to keep it
busy.

Modified:
    branches/vorner-recursor-config/src/lib/asiolink/asiolink.cc
    branches/vorner-recursor-config/src/lib/cc/session.cc

Modified: branches/vorner-recursor-config/src/lib/asiolink/asiolink.cc
==============================================================================
--- branches/vorner-recursor-config/src/lib/asiolink/asiolink.cc (original)
+++ branches/vorner-recursor-config/src/lib/asiolink/asiolink.cc Wed Nov  3 10:09:36 2010
@@ -52,6 +52,8 @@
                   SimpleCallback* checkin, DNSLookup* lookup,
                   DNSAnswer* answer);
     asio::io_service io_service_;
+    // So it does not run out of work when there are no listening sockets
+    asio::io_service::work work_;
 
     typedef boost::shared_ptr<UDPServer> UDPServerPtr;
     typedef boost::shared_ptr<TCPServer> TCPServerPtr;
@@ -107,6 +109,7 @@
                              SimpleCallback* checkin,
                              DNSLookup* lookup,
                              DNSAnswer* answer) :
+    work_(io_service_),
     checkin_(checkin),
     lookup_(lookup),
     answer_(answer)
@@ -187,21 +190,12 @@
 
 void
 IOService::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();
-    }
+    impl_->io_service_.run();
 }
 
 void
 IOService::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();
-    }
+    impl_->io_service_.run_one();
 }
 
 void

Modified: branches/vorner-recursor-config/src/lib/cc/session.cc
==============================================================================
--- branches/vorner-recursor-config/src/lib/cc/session.cc (original)
+++ branches/vorner-recursor-config/src/lib/cc/session.cc Wed Nov  3 10:09:36 2010
@@ -182,12 +182,7 @@
         // When one of them has a result, cancel the other, and wait
         // until the cancel is processed before we continue
         while (!read_result && !timer_result) {
-            if (!socket_.io_service().run_one()) {
-                // We run out of work last time we did readData
-                // and there seems to be no way to test if it is running.
-                // We know when it returns 0, it is stopped.
-                socket_.io_service().reset();
-            }
+            socket_.io_service().run_one();
 
             // Don't cancel the timer if we haven't set it
             if (read_result && getTimeout() != 0) {




More information about the bind10-changes mailing list