summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2006-08-03 21:50:06 +0000
committercoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2006-08-03 21:50:06 +0000
commit613ffa69f8d9a21d66da4fc7f60d5949dcf2cfc3 (patch)
treed54c299db3eedf1df8dc86e0d6b3a8d579daaf79
parent395e4d9477b999ac897ca5626fa9871ad8897374 (diff)
downloadATCD-fix_bug_2540.tar.gz
Thu Aug 3 21:49:27 UTC 2006 Carlos O'Ryan <coryan@atdesk.com>fix_bug_2540
-rw-r--r--ChangeLog8
-rw-r--r--ace/Select_Reactor_T.cpp14
-rw-r--r--ace/TP_Reactor.cpp14
3 files changed, 30 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 436605b25ba..b361d555dad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Thu Aug 3 21:49:27 UTC 2006 Carlos O'Ryan <coryan@atdesk.com>
+
+ * ace/TP_Reactor.cpp:
+ * ace/Select_Reactor_T.cpp:
+ Avoid the problems described in bug 2540 by detecting the
+ infinite loop and recomputing the number of active handlers.
+ Thanks to Jody Hagins for correcting my original "fix."
+
Thu Aug 3 10:39:12 UTC 2006 Johnny Willemsen <jwillemsen@remedy.nl>
* ace/Connector.h:
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);
diff --git a/ace/TP_Reactor.cpp b/ace/TP_Reactor.cpp
index 1207cd7c93b..6773bf72ada 100644
--- a/ace/TP_Reactor.cpp
+++ b/ace/TP_Reactor.cpp
@@ -255,6 +255,10 @@ ACE_TP_Reactor::dispatch_i (ACE_Time_Value *max_wait_time,
int event_count =
this->get_event_for_dispatching (max_wait_time);
+ // We use this count to detect potential infinite loops as described
+ // in bug 2540.
+ int initial_event_count = event_count;
+
int result = 0;
// Note: We are passing the <event_count> around, to have record of
@@ -310,8 +314,14 @@ ACE_TP_Reactor::dispatch_i (ACE_Time_Value *max_wait_time,
if (event_count > 0)
{
// Handle socket events
- return this->handle_socket_events (event_count,
- guard);
+ result = this->handle_socket_events (event_count,
+ guard);
+ }
+
+ if (event_count != 0
+ && event_count == initial_event_count)
+ {
+ this->state_changed_ = true;
}
return 0;