Re: [Boost-bugs] [Boost C++ Libraries] #3504: deadline_timer (based on UTC time) is not suitable for communication timeouts

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3504: deadline_timer (based on UTC time) is not suitable for communication timeouts
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-11-23 12:50:27


#3504: deadline_timer (based on UTC time) is not suitable for communication
timeouts
-------------------------------------------+--------------------------------
 Reporter: Bjarne Laursen <bla@…> | Owner: chris_kohlhoff
     Type: Feature Requests | Status: new
Milestone: Boost 1.41.0 | Component: asio
  Version: Boost 1.41.0 | Severity: Problem
 Keywords: |
-------------------------------------------+--------------------------------
Changes (by Pau Garcia i Quiles <pgquiles@…>):

 * cc: pgquiles@… (added)
  * version: Boost 1.38.0 => Boost 1.41.0

Comment:

 I can confirm Asio timers are broken if you set the date back/forward. The
 timer does not need to fire any fast, you can fire the timer just once a
 day and it will fail if you do this:

 1. Let's say the time now is 2009-11-23 13:45:20
 2. Start timer with deadline in 1 hour. Asio watches the system and will
 fire the timer at 2009-11-23 14:45:20.
 3. Set date back 1 day: 2009-11-22 13:45:20
 4. Timer never fires

 While Bjarne's solution is good, the #ifdef for Linux is not. It should
 not check for Linux but for platforms where clock_gettime is available,
 which is done with "#if defined(_POSIX_TIMERS) && ( _POSIX_TIMERS > 0 ) &&
 defined(_POSIX_MONOTONIC_CLOCK)".

 I've fixed Bjarne's code and uploaded the attachment.

 In addition to that, on Linux with glibc >= 2.11, linking with librt is
 required. Linux with glibc <= 2.9 does not need linking with librt but it
 does not do any harm, either. FreeBSD and Mac OS X do not need linking
 with librt.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3504#comment:1>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:01 UTC