diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2001-07-27 18:05:31 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2001-07-27 18:05:31 +0000 |
commit | 5a44e20268d12ed5198a7eee1f131ed1aa4ed845 (patch) | |
tree | 924a58c5370d73b20f711ae7b6f6129b48227c92 | |
parent | fb780c33ca95a76aa5fd46e7da0f7125619996f9 (diff) | |
download | ATCD-5a44e20268d12ed5198a7eee1f131ed1aa4ed845.tar.gz |
ChangeLogTag:Fri Jul 27 10:59:50 2001 Carlos O'Ryan <coryan@uci.edu>
-rw-r--r-- | TAO/ChangeLogs/ChangeLog-02a | 36 | ||||
-rw-r--r-- | TAO/tao/Invocation.cpp | 4 | ||||
-rw-r--r-- | TAO/tao/LF_Event.cpp | 33 | ||||
-rw-r--r-- | TAO/tao/LF_Event.h | 3 | ||||
-rw-r--r-- | TAO/tao/LF_Event.inl | 9 | ||||
-rw-r--r-- | TAO/tao/LF_Event_Binder.cpp | 10 | ||||
-rw-r--r-- | TAO/tao/LF_Event_Binder.h | 51 | ||||
-rw-r--r-- | TAO/tao/LF_Event_Binder.inl | 16 | ||||
-rw-r--r-- | TAO/tao/Leader_Follower.cpp | 5 | ||||
-rw-r--r-- | TAO/tao/Makefile | 2 | ||||
-rw-r--r-- | TAO/tao/Makefile.bor | 1 | ||||
-rw-r--r-- | TAO/tao/Synch_Reply_Dispatcher.cpp | 7 | ||||
-rw-r--r-- | TAO/tao/Synch_Reply_Dispatcher.h | 6 | ||||
-rw-r--r-- | TAO/tao/TAO.dsp | 12 | ||||
-rw-r--r-- | TAO/tao/TAO_Static.dsp | 12 | ||||
-rw-r--r-- | TAO/tao/Wait_On_Reactor.cpp | 8 | ||||
-rw-r--r-- | TAO/tao/Wait_On_Read.cpp | 14 |
17 files changed, 198 insertions, 31 deletions
diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a index 275be37b3af..a68af7171ba 100644 --- a/TAO/ChangeLogs/ChangeLog-02a +++ b/TAO/ChangeLogs/ChangeLog-02a @@ -1,3 +1,39 @@ +Fri Jul 27 10:59:50 2001 Carlos O'Ryan <coryan@uci.edu> + + * tao/LF_Event.h: + * tao/LF_Event.inl: + Add new method to unbind a LF_Event and its Follower: + Reply_Dispatchers can be used multiple times to wait for several + replys, mostly when a LOCATION_FORWARD message is received. + + * tao/LF_Event.cpp: + Modify the state machine: the state can go back to ACTIVE from + CONNECTION_CLOSED or SUCCESSFUL. This represents the location + forward scenario described above. + + * tao/LF_Event_Binder.h: + * tao/LF_Event_Binder.inl: + * tao/LF_Event_Binder.cpp: + Helper class to automate the bind/unbind calls to a LF_Event. + + * tao/Leader_Follower.cpp: + Use LF_Event_Binder to handle the bind/unbind calls into the + LF_Event. + + * tao/Makefile: + * tao/Makefile.bor: + * tao/TAO.dsp: + * tao/TAO_Static.dsp: + Add new files to the projects and Makefiles. + + * tao/Invocation.cpp: + * tao/Wait_On_Read.cpp: + * tao/Wait_On_Reactor.cpp: + * tao/Synch_Reply_Dispatcher.h: + * tao/Synch_Reply_Dispatcher.cpp: + Remove the reply_received() flag from Synch_Reply_Dispatcher, + the LF_Event state is enough to know what happens. + Thu Jul 26 18:00:12 2001 Carlos O'Ryan <coryan@uci.edu> * tao/Strategies/advanced_resource.cpp: diff --git a/TAO/tao/Invocation.cpp b/TAO/tao/Invocation.cpp index 8b9fd565d49..590de76032d 100644 --- a/TAO/tao/Invocation.cpp +++ b/TAO/tao/Invocation.cpp @@ -804,7 +804,7 @@ TAO_GIOP_Twoway_Invocation::start (CORBA_Environment &ACE_TRY_ENV) TAO_GIOP_Invocation::start (ACE_TRY_ENV); ACE_CHECK; - this->rd_.reply_received () = 0; + this->rd_.state_changed (TAO_LF_Event::LFS_ACTIVE); } // Send request, block until any reply comes back, and unmarshal reply @@ -984,7 +984,7 @@ TAO_GIOP_Locate_Request_Invocation::start (CORBA_Environment &ACE_TRY_ENV) this->transport_->generate_locate_request (this->target_spec_, this->op_details_, this->out_stream_); - this->rd_.reply_received () = 0; + this->rd_.state_changed (TAO_LF_Event::LFS_ACTIVE); } // Send request, block until any reply comes back. diff --git a/TAO/tao/LF_Event.cpp b/TAO/tao/LF_Event.cpp index 0ac59b95ca9..c581aa73a55 100644 --- a/TAO/tao/LF_Event.cpp +++ b/TAO/tao/LF_Event.cpp @@ -51,15 +51,36 @@ TAO_LF_Event::state_changed_i (int new_state) if (this->state_ == TAO_LF_Event::LFS_IDLE) { // From the LFS_IDLE state we can only become active. - if (new_state == TAO_LF_Event::LFS_ACTIVE) + if (new_state == TAO_LF_Event::LFS_ACTIVE + || new_state == TAO_LF_Event::LFS_CONNECTION_CLOSED) this->state_ = new_state; return; } - // States other than LFS_ACTIVE are final - if (this->state_ != TAO_LF_Event::LFS_ACTIVE) - return; - - this->state_ = new_state; + else if (this->state_ == TAO_LF_Event::LFS_ACTIVE) + { + // From LFS_ACTIVE we can only move to a few states + if (new_state != TAO_LF_Event::LFS_IDLE + && new_state != TAO_LF_Event::LFS_CONNECTION_CLOSED) + { + this->state_ = new_state; + } + return; + } + else if (this->state_ == TAO_LF_Event::LFS_SUCCESS + || this->state_ == TAO_LF_Event::LFS_CONNECTION_CLOSED) + { + // From the two states above we can go back to ACTIVE, as when a + // request is restarted. + if (new_state == TAO_LF_Event::LFS_ACTIVE) + { + this->state_ = new_state; + } + return; + } + else /* if (this->state_ == TAO_LF_Event::LFS_TIMEOUT || FAILURE ) */ + { + // Other states are final... + } } int diff --git a/TAO/tao/LF_Event.h b/TAO/tao/LF_Event.h index 888e1240a16..57d860205f1 100644 --- a/TAO/tao/LF_Event.h +++ b/TAO/tao/LF_Event.h @@ -62,6 +62,9 @@ public: */ int bind (TAO_Follower *follower); + /// Unbind the follower + int unbind (void); + //@{ /** @name State management * diff --git a/TAO/tao/LF_Event.inl b/TAO/tao/LF_Event.inl index 200eff65967..96e9e118918 100644 --- a/TAO/tao/LF_Event.inl +++ b/TAO/tao/LF_Event.inl @@ -10,6 +10,15 @@ TAO_LF_Event::bind (TAO_Follower *follower) } ACE_INLINE int +TAO_LF_Event::unbind (void) +{ + if (this->follower_ == 0) + return -1; + this->follower_ = 0; + return 0; +} + +ACE_INLINE int TAO_LF_Event::keep_waiting (void) { return (this->successful () == 0) && (this->error_detected () == 0); diff --git a/TAO/tao/LF_Event_Binder.cpp b/TAO/tao/LF_Event_Binder.cpp new file mode 100644 index 00000000000..afa12f4a5b3 --- /dev/null +++ b/TAO/tao/LF_Event_Binder.cpp @@ -0,0 +1,10 @@ +// -*- C++ -*- +// $Id$ + +#include "tao/LF_Event_Binder.h" + +#if !defined (__ACE_INLINE__) +# include "tao/LF_Event_Binder.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(tao, LF_Event_Binder, "$Id$") diff --git a/TAO/tao/LF_Event_Binder.h b/TAO/tao/LF_Event_Binder.h new file mode 100644 index 00000000000..cb011d13614 --- /dev/null +++ b/TAO/tao/LF_Event_Binder.h @@ -0,0 +1,51 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file LF_Event_Binder.h + * + * $Id$ + * + * @author Carlos O'Ryan <coryan@uci.edu> + */ +//============================================================================= + +#ifndef TAO_LF_EVENT_BINDER_H +#define TAO_LF_EVENT_BINDER_H +#include "ace/pre.h" + +#include "tao/LF_Event.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +class TAO_Follower; + +/** + * @brief Implement an auto_ptr-like class for the TAO_Followers + * allocated via a TAO_Leader_Follower set. + * + * The Leader/Follower set is a factory for TAO_Follower objects + */ +class TAO_Export TAO_LF_Event_Binder +{ +public: + /// Constructor + TAO_LF_Event_Binder (TAO_LF_Event *event, + TAO_Follower *folloer); + + /// Destructor + ~TAO_LF_Event_Binder (void); + +private: + /// Keep a reference to the leader follower + TAO_LF_Event *event_; +}; + +#if defined (__ACE_INLINE__) +# include "tao/LF_Event_Binder.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_LF_EVENT_BINDER_H */ diff --git a/TAO/tao/LF_Event_Binder.inl b/TAO/tao/LF_Event_Binder.inl new file mode 100644 index 00000000000..d861a1f2789 --- /dev/null +++ b/TAO/tao/LF_Event_Binder.inl @@ -0,0 +1,16 @@ +// $Id$ + +ACE_INLINE +TAO_LF_Event_Binder::TAO_LF_Event_Binder (TAO_LF_Event *event, + TAO_Follower *follower) + : event_ (event) +{ + this->event_->bind (follower); +} + + +ACE_INLINE +TAO_LF_Event_Binder::~TAO_LF_Event_Binder (void) +{ + this->event_->unbind (); +} diff --git a/TAO/tao/Leader_Follower.cpp b/TAO/tao/Leader_Follower.cpp index 3ae55128b48..99de1573511 100644 --- a/TAO/tao/Leader_Follower.cpp +++ b/TAO/tao/Leader_Follower.cpp @@ -5,6 +5,7 @@ #include "tao/Follower.h" #include "tao/Follower_Auto_Ptr.h" #include "tao/LF_Event.h" +#include "tao/LF_Event_Binder.h" #include "tao/Transport.h" @@ -204,7 +205,7 @@ TAO_Leader_Follower::wait_for_event (TAO_LF_Event *event, // Bound the follower and the LF_Event, this is important to // get a signal when the event terminates - event->bind (follower.get ()); + TAO_LF_Event_Binder event_binder (event, follower.get ()); while (event->keep_waiting () && this->leader_available ()) @@ -323,7 +324,7 @@ TAO_Leader_Follower::wait_for_event (TAO_LF_Event *event, // FALLTHROUGH // We only get here if we woke up but the reply is not // complete yet, time to assume the leader role.... - // i.e. ACE_ASSERT (reply_received == 0); + // i.e. ACE_ASSERT (event->successful () == 0); } // = Leader Code. diff --git a/TAO/tao/Makefile b/TAO/tao/Makefile index 385949cdb28..1d932012658 100644 --- a/TAO/tao/Makefile +++ b/TAO/tao/Makefile @@ -49,6 +49,7 @@ PUB_HDRS = \ ORB_Table \ Follower \ LF_Event \ + LF_Event_Binder \ LF_Event_Loop_Thread_Helper \ LF_Strategy \ LF_Strategy_Complete \ @@ -196,6 +197,7 @@ ORB_CORE_FILES = \ Leader_Follower \ Leader_Follower_Flushing_Strategy \ LF_Event \ + LF_Event_Binder \ LF_Event_Loop_Thread_Helper \ LF_Strategy \ LF_Strategy_Complete \ diff --git a/TAO/tao/Makefile.bor b/TAO/tao/Makefile.bor index 71d1f8939c6..f82c3c3d648 100644 --- a/TAO/tao/Makefile.bor +++ b/TAO/tao/Makefile.bor @@ -111,6 +111,7 @@ OBJFILES = \ $(OBJDIR)\IOR_Parser.obj \ $(OBJDIR)\IORInfo.obj \ $(OBJDIR)\LF_Event.obj \ + $(OBJDIR)\LF_Event_Binder.obj \ $(OBJDIR)\LF_Event_Loop_Thread_Helper.obj \ $(OBJDIR)\LF_Strategy.obj \ $(OBJDIR)\LF_Strategy_Complete.obj \ diff --git a/TAO/tao/Synch_Reply_Dispatcher.cpp b/TAO/tao/Synch_Reply_Dispatcher.cpp index 752e7143295..2b58303a92f 100644 --- a/TAO/tao/Synch_Reply_Dispatcher.cpp +++ b/TAO/tao/Synch_Reply_Dispatcher.cpp @@ -14,7 +14,6 @@ TAO_Synch_Reply_Dispatcher::TAO_Synch_Reply_Dispatcher ( IOP::ServiceContextList &sc ) : reply_service_info_ (sc), - reply_received_ (0), orb_core_ (orb_core), db_ (sizeof buf_, ACE_Message_Block::MB_DATA, @@ -45,12 +44,6 @@ TAO_Synch_Reply_Dispatcher::reply_cdr (void) return this->reply_cdr_; } -int& -TAO_Synch_Reply_Dispatcher::reply_received (void) -{ - return this->reply_received_; -} - int TAO_Synch_Reply_Dispatcher::dispatch_reply ( TAO_Pluggable_Reply_Params ¶ms) diff --git a/TAO/tao/Synch_Reply_Dispatcher.h b/TAO/tao/Synch_Reply_Dispatcher.h index e8ca72afc64..536096b2041 100644 --- a/TAO/tao/Synch_Reply_Dispatcher.h +++ b/TAO/tao/Synch_Reply_Dispatcher.h @@ -51,9 +51,6 @@ public: /// Return the reply CDR. TAO_InputCDR &reply_cdr (void); - /// A flag to check if the reply - int &reply_received (void); - virtual int dispatch_reply (TAO_Pluggable_Reply_Params ¶ms); virtual void connection_closed (void); @@ -63,9 +60,6 @@ protected: IOP::ServiceContextList &reply_service_info_; private: - /// Flag that indicates the reply has been received. - int reply_received_; - /// Cache the ORB Core pointer. TAO_ORB_Core *orb_core_; diff --git a/TAO/tao/TAO.dsp b/TAO/tao/TAO.dsp index 63e23ad34fa..84610b60e0d 100644 --- a/TAO/tao/TAO.dsp +++ b/TAO/tao/TAO.dsp @@ -527,6 +527,10 @@ SOURCE=.\Leader_Follower_Flushing_Strategy.cpp # End Source File
# Begin Source File
+SOURCE=.\LF_Event_Binder.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\LF_Event_Loop_Thread_Helper.cpp
# End Source File
# Begin Source File
@@ -1307,6 +1311,14 @@ SOURCE=.\Leader_Follower_Flushing_Strategy.h # End Source File
# Begin Source File
+SOURCE=.\LF_Event_Binder.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\LF_Event_Binder.inl
+# End Source File
+# Begin Source File
+
SOURCE=.\LF_Event_Loop_Thread_Helper.h
# End Source File
# Begin Source File
diff --git a/TAO/tao/TAO_Static.dsp b/TAO/tao/TAO_Static.dsp index 4ace1c229eb..b800f50da05 100644 --- a/TAO/tao/TAO_Static.dsp +++ b/TAO/tao/TAO_Static.dsp @@ -471,6 +471,10 @@ SOURCE=.\LF_Event.h # End Source File
# Begin Source File
+SOURCE=.\LF_Event_Binder.h
+# End Source File
+# Begin Source File
+
SOURCE=.\LF_Event_Loop_Thread_Helper.h
# End Source File
# Begin Source File
@@ -1171,6 +1175,10 @@ SOURCE=.\LF_Event.inl # End Source File
# Begin Source File
+SOURCE=.\LF_Event_Binder.inl
+# End Source File
+# Begin Source File
+
SOURCE=.\LF_Event_Loop_Thread_Helper.inl
# End Source File
# Begin Source File
@@ -1823,6 +1831,10 @@ SOURCE=.\LF_Event.cpp # End Source File
# Begin Source File
+SOURCE=.\LF_Event_Binder.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\LF_Event_Loop_Thread_Helper.cpp
# End Source File
# Begin Source File
diff --git a/TAO/tao/Wait_On_Reactor.cpp b/TAO/tao/Wait_On_Reactor.cpp index ed5094c47f7..9abc0063b37 100644 --- a/TAO/tao/Wait_On_Reactor.cpp +++ b/TAO/tao/Wait_On_Reactor.cpp @@ -33,7 +33,7 @@ TAO_Wait_On_Reactor::wait (ACE_Time_Value *max_wait_time, // If we got our reply, no need to run the event loop any // further. - if (rd.reply_received ()) + if (!rd.keep_waiting ()) break; // Did we timeout? If so, stop running the loop. @@ -49,13 +49,13 @@ TAO_Wait_On_Reactor::wait (ACE_Time_Value *max_wait_time, // Otherwise, keep going... } - if (result == -1 || rd.reply_received () == -1) + if (result == -1 || rd.error_detected ()) return -1; // Return an error if there was a problem receiving the reply. if (max_wait_time != 0) { - if (rd.reply_received () != 1 && + if (rd.successful () && *max_wait_time == ACE_Time_Value::zero) { result = -1; @@ -65,7 +65,7 @@ TAO_Wait_On_Reactor::wait (ACE_Time_Value *max_wait_time, else { result = 0; - if (rd.reply_received () == -1) + if (rd.error_detected ()) result = -1; } diff --git a/TAO/tao/Wait_On_Read.cpp b/TAO/tao/Wait_On_Read.cpp index 149a75d17e7..6e82919b65b 100644 --- a/TAO/tao/Wait_On_Read.cpp +++ b/TAO/tao/Wait_On_Read.cpp @@ -23,7 +23,7 @@ int TAO_Wait_On_Read::wait (ACE_Time_Value * max_wait_time, TAO_Synch_Reply_Dispatcher &rd) { - rd.reply_received () = 0; + rd.state_changed (TAO_LF_Event::LFS_ACTIVE); // Do the same sort of looping that is done in other wait // strategies. @@ -38,7 +38,7 @@ TAO_Wait_On_Read::wait (ACE_Time_Value * max_wait_time, // If we got our reply, no need to run the loop any // further. - if (rd.reply_received ()) + if (!rd.keep_waiting ()) break; // @@ We are not checking for timeouts here... @@ -48,12 +48,18 @@ TAO_Wait_On_Read::wait (ACE_Time_Value * max_wait_time, break; } - if (rd.reply_received () == -1 || retval == -1) + if (rd.error_detected () == -1 || retval == -1) { this->transport_->close_connection (); } - return (rd.reply_received () == 1 ? 0 : rd.reply_received ()); + if (rd.successful ()) + return 0; + + if (rd.error_detected ()) + return -1; + + return 1; } // No-op. |