From aa2907b32f9219b853b72f2a5bf21f52b3620c2b Mon Sep 17 00:00:00 2001 From: coryan Date: Tue, 8 Aug 2006 14:10:47 +0000 Subject: Tue Aug 8 14:00:06 UTC 2006 Carlos O'Ryan (merge 73857:73859) --- ACE/ChangeLog | 13 +++++++++++++ ACE/ace/Select_Reactor_T.cpp | 14 ++++++++++---- ACE/ace/TP_Reactor.cpp | 14 ++++++++++++-- 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 + + * 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 + + * 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 * 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::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 // state has changed as the result of an @@ -1358,11 +1365,10 @@ ACE_Select_Reactor_T::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 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; -- cgit v1.2.1