Boost logo

Boost-Commit :

From: chris_at_[hidden]
Date: 2008-04-20 21:27:49


Author: chris_kohlhoff
Date: 2008-04-20 21:27:48 EDT (Sun, 20 Apr 2008)
New Revision: 44663
URL: http://svn.boost.org/trac/boost/changeset/44663

Log:
Ensure that timer dispatching responsibility is correctly relinquished when
processing leftover interrupts from a previous run invocation.

Text files modified:
   trunk/boost/asio/detail/win_iocp_io_service.hpp | 14 ++++++++------
   1 files changed, 8 insertions(+), 6 deletions(-)

Modified: trunk/boost/asio/detail/win_iocp_io_service.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_io_service.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_io_service.hpp 2008-04-20 21:27:48 EDT (Sun, 20 Apr 2008)
@@ -505,16 +505,18 @@
       }
       else
       {
+ // Relinquish responsibility for dispatching timers. If the io_service
+ // is not being stopped then the thread will get an opportunity to
+ // reacquire timer responsibility on the next loop iteration.
+ if (dispatching_timers)
+ {
+ ::InterlockedCompareExchange(&timer_thread_, 0, this_thread_id);
+ }
+
         // The stopped_ flag is always checked to ensure that any leftover
         // interrupts from a previous run invocation are ignored.
         if (::InterlockedExchangeAdd(&stopped_, 0) != 0)
         {
- // Relinquish responsibility for dispatching timers.
- if (dispatching_timers)
- {
- ::InterlockedCompareExchange(&timer_thread_, 0, this_thread_id);
- }
-
           // Wake up next thread that is blocked on GetQueuedCompletionStatus.
           if (!::PostQueuedCompletionStatus(iocp_.handle, 0, 0, 0))
           {


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk