[Boost-bugs] [Boost C++ Libraries] #3835: timer handlers are called incorrectly in reverse expiry order

Subject: [Boost-bugs] [Boost C++ Libraries] #3835: timer handlers are called incorrectly in reverse expiry order
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-01-11 13:37:17


#3835: timer handlers are called incorrectly in reverse expiry order
-----------------------------------------------+----------------------------
 Reporter: Norbert Bérci <bercin@…> | Owner: chris_kohlhoff
     Type: Bugs | Status: new
Milestone: Boost 1.42.0 | Component: asio
  Version: Boost 1.41.0 | Severity: Problem
 Keywords: |
-----------------------------------------------+----------------------------
 When timer_queue::dispatch_timers() expires more than one timer (for
 example after a long running handler), it places the timers into
 timer_queue::complete_timers_ in reverse order of their expiration time
 (i.e. after dispatch_timers() run, the first timer in complete_timers_ is
 the last expired timer). When timer_queue::complete_timers() is called
 later, the timers' handlers are called in the order of complete_timers_,
 i.e. the first called handler will be the last expired timer's handler.

 I consider it a bug, since the call order of the timers' handlers is
 dependent on whether there are several expired timers or not. I think the
 handlers should be called in the order of their timers' expiry,
 independently of any other handler's execution time.

 My solution (in the attached patch) is to make complete_timers_ a doubly
 linked list (fill in its prev_ member both in dispatch_timers() and
 dispatch_cancellations()), and in complete_timers() call handlers starting
 from the end of complete_timers_ and progressing backwards.

 Attached a bug test program and the patch against timer_queue.hpp in trunk
 (r58703).

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3835>
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:02 UTC