From 5528d6e4e21f2efb77c7ab40cfb23354d2acab02 Mon Sep 17 00:00:00 2001 From: bala Date: Wed, 12 Sep 2001 21:36:29 +0000 Subject: ChangeLogTag: Wed Sep 12 16:29:49 2001 Balachandran Natarajan --- TAO/ChangeLogs/ChangeLog-02a | 16 ++++++++++++++++ TAO/tao/LF_Event.cpp | 8 ++++++-- TAO/tao/LF_Event.h | 13 ++++++++++++- TAO/tao/LF_Event.inl | 16 ++++++++++++++++ TAO/tao/Leader_Follower.cpp | 6 ++++++ 5 files changed, 56 insertions(+), 3 deletions(-) diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a index ad3ce7d5d8c..80b5a25d920 100644 --- a/TAO/ChangeLogs/ChangeLog-02a +++ b/TAO/ChangeLogs/ChangeLog-02a @@ -1,3 +1,19 @@ +Wed Sep 12 16:29:49 2001 Balachandran Natarajan + + * tao/Leader_Follower.cpp (wait_for_event): If the follower times + out, we set the state in the LF_Event to indicate an error. + + * tao/LF_Event.h: + * tao/LF_Event.cpp: + * tao/LF_Event.inl: Added a new private method that allows setting + the state without holding the lock. Moreover, before we signal + the follower in state_changed () we check whether the LF_Event + has reached a final state or not. Further, we also check whether + we have a valid follower_ pointer before we signal the + follower. This fix should fix the problems MT_Timeout tests. The + problem was that the leader thread was processing the followers + reply when the follower timedout. + Wed Sep 12 12:33:15 2001 Jeff Parsons * tao/DynamicAny/DynAny_i.cpp: diff --git a/TAO/tao/LF_Event.cpp b/TAO/tao/LF_Event.cpp index 3b03c0b59ad..f58a7860fe6 100644 --- a/TAO/tao/LF_Event.cpp +++ b/TAO/tao/LF_Event.cpp @@ -35,9 +35,13 @@ TAO_LF_Event::state_changed (int new_state) ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, leader_follower.lock ()); - this->state_changed_i (new_state); + if (is_state_final ()== 0 && + this->follower_ != 0) + { + this->state_changed_i (new_state); - this->follower_->signal (); + this->follower_->signal (); + } } } diff --git a/TAO/tao/LF_Event.h b/TAO/tao/LF_Event.h index a71dfa7bb89..0fdfa8a0a78 100644 --- a/TAO/tao/LF_Event.h +++ b/TAO/tao/LF_Event.h @@ -22,7 +22,7 @@ class TAO_Transport; class TAO_LF_Follower; - +class TAO_Leader_Follower; /** * @class TAO_LF_Event * @@ -45,6 +45,9 @@ class TAO_LF_Follower; class TAO_Export TAO_LF_Event { public: + + friend class TAO_Leader_Follower; + /// Constructor TAO_LF_Event (void); @@ -108,6 +111,14 @@ protected: /// Validate the state change void state_changed_i (int new_state); +private: + + /// Check whether we have reached the final state.. + int is_state_final (void); + + /// Set the state. + void set_state (int new_state); + private: /// The current state int state_; diff --git a/TAO/tao/LF_Event.inl b/TAO/tao/LF_Event.inl index 67b7083ad36..2bdd079e8e7 100644 --- a/TAO/tao/LF_Event.inl +++ b/TAO/tao/LF_Event.inl @@ -9,6 +9,22 @@ TAO_LF_Event::bind (TAO_LF_Follower *follower) return 0; } +ACE_INLINE int +TAO_LF_Event::is_state_final (void) +{ + if (this->state_ == TAO_LF_Event::LFS_TIMEOUT || + this->state_ == TAO_LF_Event::LFS_FAILURE) + return 1; + + return 0; +} + +ACE_INLINE void +TAO_LF_Event::set_state (int new_state) +{ + this->state_ = new_state; +} + ACE_INLINE int TAO_LF_Event::unbind (void) { diff --git a/TAO/tao/Leader_Follower.cpp b/TAO/tao/Leader_Follower.cpp index ab245232d58..d3d2dcf4c12 100644 --- a/TAO/tao/Leader_Follower.cpp +++ b/TAO/tao/Leader_Follower.cpp @@ -271,6 +271,10 @@ TAO_Leader_Follower::wait_for_event (TAO_LF_Event *event, " [has timer, follower failed]\n", transport->id ())); + // We have timedout.. So set the state in the + // LF_Event about this.. We call the non-locking, + // no-signalling method on LF_Event.. + event->set_state (TAO_LF_Event::LFS_TIMEOUT); if (!event->successful ()) { // Remove follower can fail because either @@ -296,6 +300,8 @@ TAO_Leader_Follower::wait_for_event (TAO_LF_Event *event, " elect_new_leader failed\n")); } } + + return -1; } } -- cgit v1.2.1