Browse Source

Fix problem with stopped IOService

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/vorner-recursor-config@3351 e5f2f494-b856-4b98-b285-d166d9295462
Michal Vaner 14 years ago
parent
commit
db9ded2871
1 changed files with 7 additions and 2 deletions
  1. 7 2
      src/lib/cc/session.cc

+ 7 - 2
src/lib/cc/session.cc

@@ -171,7 +171,7 @@ SessionImpl::readData(void* data, size_t datalen) {
         asio::async_read(socket_, asio::buffer(data, datalen),
                          boost::bind(&setResult, &read_result, _1));
         asio::deadline_timer timer(socket_.io_service());
-    
+
         if (getTimeout() != 0) {
             timer.expires_from_now(boost::posix_time::milliseconds(getTimeout()));
             timer.async_wait(boost::bind(&setResult, &timer_result, _1));
@@ -182,7 +182,12 @@ SessionImpl::readData(void* data, size_t datalen) {
         // 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) {
-            socket_.io_service().run_one();
+            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();
+            }
 
             // Don't cancel the timer if we haven't set it
             if (read_result && getTimeout() != 0) {