summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2006-08-08 14:10:47 +0000
committercoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2006-08-08 14:10:47 +0000
commitaa2907b32f9219b853b72f2a5bf21f52b3620c2b (patch)
treead38f66e69c242ecb6b3f4fc6bf2d05dc8090dce
parent6f0941f3ee0b5182361d100f35375582608055c6 (diff)
downloadATCD-aa2907b32f9219b853b72f2a5bf21f52b3620c2b.tar.gz
Tue Aug 8 14:00:06 UTC 2006 Carlos O'Ryan <coryan@atdesk.com> (merge 73857:73859)
-rw-r--r--ACE/ChangeLog13
-rw-r--r--ACE/ace/Select_Reactor_T.cpp14
-rw-r--r--ACE/ace/TP_Reactor.cpp14
3 files changed, 35 insertions, 6 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog
index 704d849f022..15c0c146294 100644
--- a/ACE/ChangeLog
+++ b/ACE/ChangeLog
@@ -1,3 +1,16 @@
+Tue Aug 8 14:00:06 UTC 2006 Carlos O'Ryan <coryan@atdesk.com>
+
+ * Merged in all the changes from the fix_bug_2540 branch, that is,
+ from revision 73857 to revision 73859.
+
+ 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."
+
Tue Aug 8 14:05:00 UTC 2006 Simon Massey <sma@prismtech.com>
* bin/MakeProjectCreator/config/ace_mfc.mpb
diff --git a/ACE/ace/Select_Reactor_T.cpp b/ACE/ace/Select_Reactor_T.cpp
index 6619459c449..bf0bdbc36cb 100644
--- a/ACE/ace/Select_Reactor_T.cpp
+++ b/ACE/ace/Select_Reactor_T.cpp
@@ -1284,6 +1284,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
@@ -1358,11 +1365,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/ace/TP_Reactor.cpp b/ACE/ace/TP_Reactor.cpp
index 1207cd7c93b..6773bf72ada 100644
--- a/ACE/ace/TP_Reactor.cpp
+++ b/ACE/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;