BIND 10 master, updated. c9f6acc81e24c4b8f0eb351123dc7b43f64e0914 Merge branch 'master' into trac452

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Feb 8 09:29:15 UTC 2011


The branch, master has been updated
       via  c9f6acc81e24c4b8f0eb351123dc7b43f64e0914 (commit)
       via  24bb934f0ad2732c50730187376d96ddadefecbc (commit)
       via  f0b6f321beecb5145776a730461b61426a52a4f1 (commit)
       via  3048f118d4b4c9995d7ee258c9405f9d7abbc576 (commit)
       via  2931606d7c3d6709284788890b016ff434d0f5e2 (commit)
       via  3aa87f6826846585666e907b446a3809ccfce560 (commit)
       via  ee7acfccb0cd0d68dc4d7e64ae7fa0655314b444 (commit)
       via  80dd41d265d1e2c366c8ea2dc1e79ee353f1e8f1 (commit)
      from  29c6946c6a6a13a833b6037057debfa82ee19c22 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit c9f6acc81e24c4b8f0eb351123dc7b43f64e0914
Merge: 24bb934f0ad2732c50730187376d96ddadefecbc 29c6946c6a6a13a833b6037057debfa82ee19c22
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date:   Tue Feb 8 12:33:01 2011 +0900

    Merge branch 'master' into trac452

commit 24bb934f0ad2732c50730187376d96ddadefecbc
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date:   Fri Feb 4 17:40:14 2011 +0900

    [trac452] add test of the limitation of statistics interval

commit f0b6f321beecb5145776a730461b61426a52a4f1
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date:   Fri Feb 4 14:41:09 2011 +0900

    [trac452] Modified error message: display the limitation explicitly

commit 3048f118d4b4c9995d7ee258c9405f9d7abbc576
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed Feb 2 16:11:21 2011 +0100

    [trac452] Language corrections

commit 2931606d7c3d6709284788890b016ff434d0f5e2
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date:   Wed Feb 2 21:02:53 2011 +0900

    Modified configuration variable "statistics-interval" to accept interval in seconds.
    
    Upper limit for the value is also introduced; 86400 seconds.

commit 3aa87f6826846585666e907b446a3809ccfce560
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date:   Tue Jan 25 16:32:25 2011 +0900

    Modified IntervalTimer to accept interval in milliseconds (Trac ticket #452)
    
    Modified the interface of IntervalTimer to accept interval in
    milliseconds.
    Tests for IntervalTimer are also modified; now it takes 1.4 seconds.

commit ee7acfccb0cd0d68dc4d7e64ae7fa0655314b444
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date:   Tue Jan 25 15:37:13 2011 +0900

    Changed the type of interval from 'uint32_t' to 'long' (Comment on Trac ticket #513)

commit 80dd41d265d1e2c366c8ea2dc1e79ee353f1e8f1
Author: Yoshitaka Aharen <aharen at jprs.co.jp>
Date:   Tue Jan 25 14:57:20 2011 +0900

    Renamed member functions of asiolink::IntervalTimer (Trac ticket #515)
    
    Renamed IntervalTimer::setupTimer() -> IntervalTimer::setup()
    Renamed IntervalTimerImpl::updateTimer() -> IntervalTimerImpl::update()

-----------------------------------------------------------------------

Summary of changes:
 src/bin/auth/auth_srv.cc                    |   12 ++-
 src/bin/auth/auth_srv.h                     |    3 +-
 src/bin/auth/config.cc                      |    7 ++-
 src/bin/auth/tests/command_unittest.cc      |    2 +-
 src/bin/auth/tests/config_unittest.cc       |    4 +
 src/lib/asiolink/asiolink.cc                |   36 ++++----
 src/lib/asiolink/asiolink.h                 |   47 +++++-------
 src/lib/asiolink/tests/asiolink_unittest.cc |  116 ++++++++++++---------------
 8 files changed, 112 insertions(+), 115 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/auth/auth_srv.cc b/src/bin/auth/auth_srv.cc
index b8d5730..045fe7f 100644
--- a/src/bin/auth/auth_srv.cc
+++ b/src/bin/auth/auth_srv.cc
@@ -354,7 +354,7 @@ AuthSrv::setMemoryDataSrc(const isc::dns::RRClass& rrclass,
 
 uint32_t
 AuthSrv::getStatisticsTimerInterval() const {
-    return (impl_->statistics_timer_.getInterval());
+    return (impl_->statistics_timer_.getInterval() / 1000);
 }
 
 void
@@ -362,11 +362,17 @@ AuthSrv::setStatisticsTimerInterval(uint32_t interval) {
     if (interval == impl_->statistics_timer_.getInterval()) {
         return;
     }
+    if (interval > 86400) {
+        // It can't occur since the value is checked in
+        // statisticsIntervalConfig::build().
+        isc_throw(InvalidParameter, "Too long interval: " << interval);
+    }
     if (interval == 0) {
         impl_->statistics_timer_.cancel();
     } else {
-        impl_->statistics_timer_.setupTimer(
-            boost::bind(&AuthSrv::submitStatistics, this), interval);
+        impl_->statistics_timer_.setup(boost::bind(&AuthSrv::submitStatistics,
+                                                   this),
+                                       interval * 1000);
     }
     if (impl_->verbose_mode_) {
         if (interval == 0) {
diff --git a/src/bin/auth/auth_srv.h b/src/bin/auth/auth_srv.h
index 7806be9..4772a02 100644
--- a/src/bin/auth/auth_srv.h
+++ b/src/bin/auth/auth_srv.h
@@ -318,7 +318,8 @@ public:
     /// If the specified value is non 0, the \c AuthSrv object will submit
     /// its statistics to the statistics module every \c interval seconds.
     /// If it's 0, and \c AuthSrv currently submits statistics, the submission
-    /// will be disabled.
+    /// will be disabled. \c interval must be equal to or shorter than 86400
+    /// seconds (1 day).
     ///
     /// This method should normally not throw an exception; however, its
     /// underlying library routines may involve resource allocation, and
diff --git a/src/bin/auth/config.cc b/src/bin/auth/config.cc
index 1f258e3..5befc6e 100644
--- a/src/bin/auth/config.cc
+++ b/src/bin/auth/config.cc
@@ -179,9 +179,14 @@ public:
     virtual void build(ConstElementPtr config_value) {
         const int32_t config_interval = config_value->intValue();
         if (config_interval < 0) {
-            isc_throw(AuthConfigError, "negative statistics-interval value: "
+            isc_throw(AuthConfigError, "Negative statistics interval value: "
                       << config_interval);
         }
+        if (config_interval > 86400) {
+            isc_throw(AuthConfigError, "Statistics interval value "
+                      << config_interval
+                      << " must be equal to or shorter than 86400");
+        }
         interval_ = config_interval;
     }
     virtual void commit() {
diff --git a/src/bin/auth/tests/command_unittest.cc b/src/bin/auth/tests/command_unittest.cc
index 0ba5e86..f788d9e 100644
--- a/src/bin/auth/tests/command_unittest.cc
+++ b/src/bin/auth/tests/command_unittest.cc
@@ -98,7 +98,7 @@ AuthConmmandTest::stopServer() {
 
 TEST_F(AuthConmmandTest, shutdown) {
     asiolink::IntervalTimer itimer(server.getIOService());
-    itimer.setupTimer(boost::bind(&AuthConmmandTest::stopServer, this), 1);
+    itimer.setup(boost::bind(&AuthConmmandTest::stopServer, this), 1);
     server.getIOService().run();
     EXPECT_EQ(0, rcode);
 }
diff --git a/src/bin/auth/tests/config_unittest.cc b/src/bin/auth/tests/config_unittest.cc
index 0e0aee9..b8b379e 100644
--- a/src/bin/auth/tests/config_unittest.cc
+++ b/src/bin/auth/tests/config_unittest.cc
@@ -365,5 +365,9 @@ TEST_F(StatisticsIntervalConfigTest, badInterval) {
     EXPECT_THROW(parser->build(Element::fromJSON("2.5")),
                  isc::data::TypeError);
     EXPECT_THROW(parser->build(Element::fromJSON("-1")), AuthConfigError);
+    // bounds check: interval value must be equal to or shorter than
+    // 86400 seconds (1 day)
+    EXPECT_NO_THROW(parser->build(Element::fromJSON("86400")));
+    EXPECT_THROW(parser->build(Element::fromJSON("86401")), AuthConfigError);
 }
 }
diff --git a/src/lib/asiolink/asiolink.cc b/src/lib/asiolink/asiolink.cc
index 9adb52b..6fe7666 100644
--- a/src/lib/asiolink/asiolink.cc
+++ b/src/lib/asiolink/asiolink.cc
@@ -656,21 +656,20 @@ private:
 public:
     IntervalTimerImpl(IOService& io_service);
     ~IntervalTimerImpl();
-    void setupTimer(const IntervalTimer::Callback& cbfunc,
-                    const uint32_t interval);
+    void setup(const IntervalTimer::Callback& cbfunc, const long interval);
     void callback(const asio::error_code& error);
     void cancel() {
         timer_.cancel();
         interval_ = 0;
     }
-    uint32_t getInterval() const { return (interval_); }
+    long getInterval() const { return (interval_); }
 private:
     // a function to update timer_ when it expires
-    void updateTimer();
+    void update();
     // a function to call back when timer_ expires
     IntervalTimer::Callback cbfunc_;
-    // interval in seconds
-    uint32_t interval_;
+    // interval in milliseconds
+    long interval_;
     // asio timer
     asio::deadline_timer timer_;
 };
@@ -683,12 +682,13 @@ IntervalTimerImpl::~IntervalTimerImpl()
 {}
 
 void
-IntervalTimerImpl::setupTimer(const IntervalTimer::Callback& cbfunc,
-                              const uint32_t interval)
+IntervalTimerImpl::setup(const IntervalTimer::Callback& cbfunc,
+                         const long interval)
 {
-    // Interval should not be 0.
-    if (interval == 0) {
-        isc_throw(isc::BadValue, "Interval should not be 0");
+    // Interval should not be less than or equal to 0.
+    if (interval <= 0) {
+        isc_throw(isc::BadValue, "Interval should not be less than or "
+                                 "equal to 0");
     }
     // Call back function should not be empty.
     if (cbfunc.empty()) {
@@ -699,19 +699,19 @@ IntervalTimerImpl::setupTimer(const IntervalTimer::Callback& cbfunc,
     // Set initial expire time.
     // At this point the timer is not running yet and will not expire.
     // After calling IOService::run(), the timer will expire.
-    updateTimer();
+    update();
     return;
 }
 
 void
-IntervalTimerImpl::updateTimer() {
+IntervalTimerImpl::update() {
     if (interval_ == 0) {
         // timer has been canceled.  Do nothing.
         return;
     }
     try {
         // Update expire time to (current time + interval_).
-        timer_.expires_from_now(boost::posix_time::seconds(interval_));
+        timer_.expires_from_now(boost::posix_time::millisec(interval_));
     } catch (const asio::system_error& e) {
         isc_throw(isc::Unexpected, "Failed to update timer");
     }
@@ -726,7 +726,7 @@ IntervalTimerImpl::callback(const asio::error_code& cancelled) {
     if (!cancelled) {
         cbfunc_();
         // Set next expire time.
-        updateTimer();
+        update();
     }
 }
 
@@ -739,8 +739,8 @@ IntervalTimer::~IntervalTimer() {
 }
 
 void
-IntervalTimer::setupTimer(const Callback& cbfunc, const uint32_t interval) {
-    return (impl_->setupTimer(cbfunc, interval));
+IntervalTimer::setup(const Callback& cbfunc, const long interval) {
+    return (impl_->setup(cbfunc, interval));
 }
 
 void
@@ -748,7 +748,7 @@ IntervalTimer::cancel() {
     impl_->cancel();
 }
 
-uint32_t
+long
 IntervalTimer::getInterval() const {
     return (impl_->getInterval());
 }
diff --git a/src/lib/asiolink/asiolink.h b/src/lib/asiolink/asiolink.h
index 44ff383..3b3fa93 100644
--- a/src/lib/asiolink/asiolink.h
+++ b/src/lib/asiolink/asiolink.h
@@ -613,38 +613,36 @@ private:
 /// \brief The \c IntervalTimer class is a wrapper for the ASIO
 /// \c asio::deadline_timer class.
 ///
-/// This class is implemented to use \c asio::deadline_timer as
-/// interval timer.
+/// This class is implemented to use \c asio::deadline_timer as interval
+/// timer.
 ///
-/// \c setupTimer() sets a timer to expire on (now + interval) and
-/// a call back function.
+/// \c setup() sets a timer to expire on (now + interval) and a call back
+/// function.
 ///
-/// \c IntervalTimerImpl::callback() is called by the timer when
-/// it expires.
+/// \c IntervalTimerImpl::callback() is called by the timer when it expires.
 ///
-/// The function calls the call back function set by \c setupTimer()
-/// and updates the timer to expire in (now + interval) seconds.
+/// The function calls the call back function set by \c setup() and updates
+/// the timer to expire in (now + interval) milliseconds.
 /// The type of call back function is \c void(void).
 /// 
-/// The call back function will not be called if the instance of this
-/// class is destructed before the timer is expired.
+/// The call back function will not be called if the instance of this class is
+/// destroyed before the timer is expired.
 ///
-/// Note: Destruction of an instance of this class while call back
-/// is pending causes throwing an exception from \c IOService.
+/// Note: Destruction of an instance of this class while call back is pending
+/// causes throwing an exception from \c IOService.
 ///
 /// Sample code:
 /// \code
 ///  void function_to_call_back() {
 ///      // this function will be called periodically
 ///  }
-///  int interval_in_seconds = 1;
+///  int interval_in_milliseconds = 1000;
 ///  IOService io_service;
 ///
 ///  IntervalTimer intervalTimer(io_service);
-///  intervalTimer.setupTimer(function_to_call_back, interval_in_seconds);
+///  intervalTimer.setup(function_to_call_back, interval_in_milliseconds);
 ///  io_service.run();
 /// \endcode
-///
 class IntervalTimer {
 public:
     /// \name The type of timer callback function
@@ -667,7 +665,6 @@ public:
     /// This constructor may also throw \c asio::system_error.
     ///
     /// \param io_service A reference to an instance of IOService
-    ///
     IntervalTimer(IOService& io_service);
 
     /// \brief The destructor.
@@ -676,28 +673,26 @@ public:
     ///
     /// On the destruction of this class the timer will be canceled
     /// inside \c asio::deadline_timer.
-    ///
     ~IntervalTimer();
     //@}
 
     /// \brief Register timer callback function and interval.
     ///
-    /// This function sets callback function and interval in seconds.
+    /// This function sets callback function and interval in milliseconds.
     /// Timer will actually start after calling \c IOService::run().
     ///
     /// \param cbfunc A reference to a function \c void(void) to call back
     /// when the timer is expired (should not be an empty functor)
-    /// \param interval Interval in seconds (greater than 0)
+    /// \param interval Interval in milliseconds (greater than 0)
     ///
     /// Note: IntervalTimer will not pass \c asio::error_code to
     /// call back function. In case the timer is cancelled, the function
     /// will not be called.
     ///
     /// \throw isc::InvalidParameter cbfunc is empty
-    /// \throw isc::BadValue interval is 0
+    /// \throw isc::BadValue interval is less than or equal to 0
     /// \throw isc::Unexpected ASIO library error
-    ///
-    void setupTimer(const Callback& cbfunc, const uint32_t interval);
+    void setup(const Callback& cbfunc, const long interval);
 
     /// Cancel the timer.
     ///
@@ -711,15 +706,11 @@ public:
 
     /// Return the timer interval.
     ///
-    /// This method returns the timer interval in seconds if it's running;
+    /// This method returns the timer interval in milliseconds if it's running;
     /// if the timer has been canceled it returns 0.
     ///
     /// This method never throws an exception.
-    ///
-    /// Note: We may want to change the granularity of the timer to
-    /// milliseconds or even finer.  If and when this happens the semantics
-    /// of the return value of this method will be changed accordingly.
-    uint32_t getInterval() const;
+    long getInterval() const;
 
 private:
     IntervalTimerImpl* impl_;
diff --git a/src/lib/asiolink/tests/asiolink_unittest.cc b/src/lib/asiolink/tests/asiolink_unittest.cc
index be08136..2044d50 100644
--- a/src/lib/asiolink/tests/asiolink_unittest.cc
+++ b/src/lib/asiolink/tests/asiolink_unittest.cc
@@ -1028,13 +1028,12 @@ protected:
             ++count_;
             if (count_ == 1) {
                 // First time of call back.
-                // Call setupTimer() to update callback function
-                // to TimerCallBack.
+                // Call setup() to update callback function to TimerCallBack.
                 test_obj_->timer_called_ = false;
-                timer_.setupTimer(TimerCallBack(test_obj_), 1);
+                timer_.setup(TimerCallBack(test_obj_), 100);
             } else if (count_ == 2) {
                 // Second time of call back.
-                // If it reaches here, re-setupTimer() is failed (unexpected).
+                // If it reaches here, re-setup() is failed (unexpected).
                 // We should stop here.
                 test_obj_->io_service_.stop();
             }
@@ -1055,10 +1054,11 @@ TEST_F(IntervalTimerTest, invalidArgumentToIntervalTimer) {
     // Create asio_link::IntervalTimer and setup.
     IntervalTimer itimer(io_service_);
     // expect throw if call back function is empty
-    EXPECT_THROW(itimer.setupTimer(IntervalTimer::Callback(), 1),
-                     isc::InvalidParameter);
-    // expect throw if interval is 0
-    EXPECT_THROW(itimer.setupTimer(TimerCallBack(this), 0), isc::BadValue);
+    EXPECT_THROW(itimer.setup(IntervalTimer::Callback(), 1),
+                 isc::InvalidParameter);
+    // expect throw if interval is not greater than 0
+    EXPECT_THROW(itimer.setup(TimerCallBack(this), 0), isc::BadValue);
+    EXPECT_THROW(itimer.setup(TimerCallBack(this), -1), isc::BadValue);
 }
 
 TEST_F(IntervalTimerTest, startIntervalTimer) {
@@ -1070,33 +1070,30 @@ TEST_F(IntervalTimerTest, startIntervalTimer) {
     boost::posix_time::ptime start;
     start = boost::posix_time::microsec_clock::universal_time();
     // setup timer
-    itimer.setupTimer(TimerCallBack(this), 1);
-    EXPECT_EQ(1, itimer.getInterval());
+    itimer.setup(TimerCallBack(this), 100);
+    EXPECT_EQ(100, itimer.getInterval());
     io_service_.run();
     // reaches here after timer expired
-    // delta: difference between elapsed time and 1 second
+    // delta: difference between elapsed time and 100 milliseconds.
     boost::posix_time::time_duration delta =
         (boost::posix_time::microsec_clock::universal_time() - start)
-         - boost::posix_time::seconds(1);
+         - boost::posix_time::millisec(100);
     if (delta.is_negative()) {
         delta.invert_sign();
     }
     // expect TimerCallBack is called; timer_called_ is true
     EXPECT_TRUE(timer_called_);
-    // expect interval is 1 second +/- TIMER_MARGIN_MSEC.
+    // expect interval is 100 milliseconds +/- TIMER_MARGIN_MSEC.
     EXPECT_TRUE(delta < TIMER_MARGIN_MSEC);
 }
 
 TEST_F(IntervalTimerTest, destructIntervalTimer) {
-    // Note: This test currently takes 6 seconds. The timer should have
-    // finer granularity and timer periods in this test should be shorter
-    // in the future.
     // This code isn't exception safe, but we'd rather keep the code
     // simpler and more readable as this is only for tests and if it throws
     // the program would immediately terminate anyway.
 
     // The call back function will not be called after the timer is
-    // destructed.
+    // destroyed.
     //
     // There are two timers:
     //  itimer_counter (A)
@@ -1105,31 +1102,30 @@ TEST_F(IntervalTimerTest, destructIntervalTimer) {
     //  itimer_canceller (B)
     //   (Calls TimerCallBackCancelDeleter)
     //     - first time of callback, it stores the counter value of
-    //       callback_canceller and destructs itimer_counter
+    //       callback_canceller and destroys itimer_counter
     //     - second time of callback, it compares the counter value of
     //       callback_canceller with stored value
     //       if they are same the timer was not called; expected result
-    //       if they are different the timer was called after destructed
-    //
-    //     0  1  2  3  4  5  6 (s)
-    // (A) i-----+--x
-    //              ^
-    //              |destruct itimer_counter
-    // (B) i--------+--------s
-    //                       ^stop io_service
-    //                        and test itimer_counter have been stopped
+    //       if they are different the timer was called after destroyed
     //
+    //     0  100  200  300  400  500  600 (ms)
+    // (A) i--------+----x
+    //                   ^
+    //                   |destroy itimer_counter
+    // (B) i-------------+--------------s
+    //                                  ^stop io_service
+    //                                   and check if itimer_counter have been
+    //                                   stopped
 
     // itimer_counter will be deleted in TimerCallBackCancelDeleter
     IntervalTimer* itimer_counter = new IntervalTimer(io_service_);
     IntervalTimer itimer_canceller(io_service_);
     timer_cancel_success_ = false;
     TimerCallBackCounter callback_canceller(this);
-    itimer_counter->setupTimer(callback_canceller, 2);
-    itimer_canceller.setupTimer(
-        TimerCallBackCancelDeleter(this, itimer_counter,
-                                   callback_canceller),
-        3);
+    itimer_counter->setup(callback_canceller, 200);
+    itimer_canceller.setup(
+        TimerCallBackCancelDeleter(this, itimer_counter, callback_canceller),
+        300);
     io_service_.run();
     EXPECT_TRUE(timer_cancel_success_);
 }
@@ -1140,9 +1136,8 @@ TEST_F(IntervalTimerTest, cancel) {
     IntervalTimer itimer_counter(io_service_);
     IntervalTimer itimer_watcher(io_service_);
     unsigned int counter = 0;
-    itimer_counter.setupTimer(TimerCallBackCanceller(counter, itimer_counter),
-                              1);
-    itimer_watcher.setupTimer(TimerCallBack(this), 3);
+    itimer_counter.setup(TimerCallBackCanceller(counter, itimer_counter), 100);
+    itimer_watcher.setup(TimerCallBack(this), 200);
     io_service_.run();
     EXPECT_EQ(1, counter);
     EXPECT_EQ(0, itimer_counter.getInterval());
@@ -1152,36 +1147,31 @@ TEST_F(IntervalTimerTest, cancel) {
 }
 
 TEST_F(IntervalTimerTest, overwriteIntervalTimer) {
-    // Note: This test currently takes 4 seconds. The timer should have
-    // finer granularity and timer periods in this test should be shorter
-    // in the future.
-
-    // Calling setupTimer() multiple times updates call back function
-    // and interval.
+    // Calling setup() multiple times updates call back function and interval.
     //
     // There are two timers:
     //  itimer (A)
     //   (Calls TimerCallBackCounter / TimerCallBack)
     //     - increments internal counter in callback function
     //       (TimerCallBackCounter)
-    //       interval: 2 seconds
+    //       interval: 300 milliseconds
     //     - io_service_.stop() (TimerCallBack)
-    //       interval: 1 second
+    //       interval: 100 milliseconds
     //  itimer_overwriter (B)
     //   (Calls TimerCallBackOverwriter)
-    //     - first time of callback, it calls setupTimer() to change
-    //       call back function and interval of itimer to
-    //       TimerCallBack / 1 second
-    //       after 3 + 1 seconds from the beginning of this test,
+    //     - first time of callback, it calls setup() to change call back
+    //       function to TimerCallBack and interval of itimer to 100
+    //       milliseconds
+    //       after 300 + 100 milliseconds from the beginning of this test,
     //       TimerCallBack() will be called and io_service_ stops.
     //     - second time of callback, it means the test fails.
     //
-    //     0  1  2  3  4  5  6 (s)
-    // (A) i-----+--C--s
-    //              ^  ^stop io_service
-    //              |change call back function
-    // (B) i--------+--------S
-    //                       ^(stop io_service on fail)
+    //     0  100  200  300  400  500  600  700  800 (ms)
+    // (A) i-------------+----C----s
+    //                        ^    ^stop io_service
+    //                        |change call back function
+    // (B) i------------------+-------------------S
+    //                                            ^(stop io_service on fail)
     //
 
     IntervalTimer itimer(io_service_);
@@ -1189,22 +1179,22 @@ TEST_F(IntervalTimerTest, overwriteIntervalTimer) {
     // store start time
     boost::posix_time::ptime start;
     start = boost::posix_time::microsec_clock::universal_time();
-    itimer.setupTimer(TimerCallBackCounter(this), 2);
-    itimer_overwriter.setupTimer(TimerCallBackOverwriter(this, itimer), 3);
+    itimer.setup(TimerCallBackCounter(this), 300);
+    itimer_overwriter.setup(TimerCallBackOverwriter(this, itimer), 400);
     io_service_.run();
     // reaches here after timer expired
     // if interval is updated, it takes
-    //   3 seconds for TimerCallBackOverwriter
-    //   + 1 second for TimerCallBack (stop)
-    //   = 4 seconds.
+    //   400 milliseconds for TimerCallBackOverwriter
+    //   + 100 milliseconds for TimerCallBack (stop)
+    //   = 500 milliseconds.
     // otherwise (test fails), it takes
-    //   3 seconds for TimerCallBackOverwriter
-    //   + 3 seconds for TimerCallBackOverwriter (stop)
-    //   = 6 seconds.
-    // delta: difference between elapsed time and 3 + 1 seconds
+    //   400 milliseconds for TimerCallBackOverwriter
+    //   + 400 milliseconds for TimerCallBackOverwriter (stop)
+    //   = 800 milliseconds.
+    // delta: difference between elapsed time and 400 + 100 milliseconds
     boost::posix_time::time_duration delta =
         (boost::posix_time::microsec_clock::universal_time() - start)
-         - boost::posix_time::seconds(3 + 1);
+         - boost::posix_time::millisec(400 + 100);
     if (delta.is_negative()) {
         delta.invert_sign();
     }




More information about the bind10-changes mailing list