[svn] commit: r3444 - /experiments/kambe-auth-stats/src/bin/auth/asio_link.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Nov 4 12:45:19 UTC 2010


Author: naokikambe
Date: Thu Nov  4 12:45:18 2010
New Revision: 3444

Log:
- not stopping timer if 'sendtoStats' failed
- start first timer just before 'io_service.run()'

Modified:
    experiments/kambe-auth-stats/src/bin/auth/asio_link.cc

Modified: experiments/kambe-auth-stats/src/bin/auth/asio_link.cc
==============================================================================
--- experiments/kambe-auth-stats/src/bin/auth/asio_link.cc (original)
+++ experiments/kambe-auth-stats/src/bin/auth/asio_link.cc Thu Nov  4 12:45:18 2010
@@ -603,14 +603,7 @@
             tcp6_server_ = TCPServerPtr(new TCPServer(auth_server, io_service_,
                                                       *v6addr, portnum));
         }
-        if (auth_server_ != NULL) {
-            // start deadline_timer
-            dltimer_ = DlTimerPtr(new asio::deadline_timer(io_service_));
-            dltimer_->expires_from_now(boost::posix_time::seconds(
-                                           auth_server_->getTimeoutSec()));
-            dltimer_->async_wait(boost::bind(&IOServiceImpl::AsWaitHandler,
-                                             this, asio::placeholders::error));
-        }
+        dltimer_ = DlTimerPtr(new asio::deadline_timer(io_service_));
     } catch (const asio::system_error& err) {
         // We need to catch and convert any ASIO level exceptions.
         // This can happen for unavailable address, binding a privilege port
@@ -632,14 +625,15 @@
              << endl;
         return;
     }
-    if (auth_server_ == NULL || !(auth_server_->sendtoStats()))
+    if (auth_server_ == NULL || dltimer_ == NULL)
         return;
+    auth_server_->sendtoStats();
     dltimer_->cancel(); // cancel the last operation if not done.
     dltimer_->expires_at(dltimer_->expires_at()
-                         + boost::posix_time::seconds(
-                             auth_server_->getTimeoutSec()));
-    dltimer_->async_wait(boost::bind(&IOServiceImpl::AsWaitHandler,
-                                     this, asio::placeholders::error));
+        + boost::posix_time::seconds(auth_server_->getTimeoutSec()));
+    dltimer_->async_wait(
+        boost::bind(&IOServiceImpl::AsWaitHandler,
+                    this, asio::placeholders::error));
 }
 
 IOService::IOService(AuthSrv* auth_server, const char& port,
@@ -675,6 +669,19 @@
 
 void
 IOService::run() {
+    // start deadline_timer
+    try {
+        if (impl_->auth_server_ != NULL) {
+            impl_->dltimer_->expires_from_now(
+                boost::posix_time::seconds(impl_->auth_server_->getTimeoutSec()));
+            impl_->dltimer_->async_wait(
+                boost::bind(&IOServiceImpl::AsWaitHandler,
+                            impl_, asio::placeholders::error));
+        }
+    } catch (const asio::system_error& err) {
+        isc_throw(IOError, "Failed to start deadline_timer: " <<
+                  err.what());
+    }
     impl_->io_service_.run();
 }
 




More information about the bind10-changes mailing list