summaryrefslogtreecommitdiff
path: root/ace/Select_Reactor_T.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ace/Select_Reactor_T.cpp')
-rw-r--r--ace/Select_Reactor_T.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/ace/Select_Reactor_T.cpp b/ace/Select_Reactor_T.cpp
index 1dd2fc26b2a..50c9eec5dc1 100644
--- a/ace/Select_Reactor_T.cpp
+++ b/ace/Select_Reactor_T.cpp
@@ -1286,6 +1286,13 @@ ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::dispatch
do
{
+ // We expect that the loop will decrease the number of active
+ // handles in each iteration. If it does not, then something is
+ // inconsistent in the state of the Reactor and we should avoid
+ // the loop. Please read the comments on bug 2540 for more
+ // details.
+ int initial_handle_count = active_handle_count;
+
// Note that we keep track of changes to our state. If any of
// the dispatch_*() methods below return -1 it means that the
// <wait_set_> state has changed as the result of an
@@ -1360,11 +1367,10 @@ ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::dispatch
// if state changed, we need to re-eval active_handle_count,
// so we will not end with an endless loop
- if (this->state_changed_)
+ if (initial_handle_count == active_handle_count
+ || this->state_changed_)
{
- active_handle_count = this->dispatch_set_.rd_mask_.num_set ()
- + this->dispatch_set_.wr_mask_.num_set ()
- + this->dispatch_set_.ex_mask_.num_set ();
+ active_handle_count = this->any_ready (dispatch_set);
}
}
while (active_handle_count > 0);