diff options
author | bala <balanatarajan@users.noreply.github.com> | 2002-04-30 19:05:43 +0000 |
---|---|---|
committer | bala <balanatarajan@users.noreply.github.com> | 2002-04-30 19:05:43 +0000 |
commit | ce2a96a2d3c27ce939cfcdf0b7100b66b29ac6d2 (patch) | |
tree | d4b54dd9f18f5fccce0cc80c8a96368ccf9b38a5 /TAO | |
parent | a8e16148a1f420a27db493b15bc6427106577293 (diff) | |
download | ATCD-ce2a96a2d3c27ce939cfcdf0b7100b66b29ac6d2.tar.gz |
ChangeLogTag: Tue Apr 30 13:50:55 2002 Balachandran Natarajan <bala@cs.wustl.edu>
Diffstat (limited to 'TAO')
-rw-r--r-- | TAO/ChangeLogs/ChangeLog-02a | 45 | ||||
-rw-r--r-- | TAO/tao/IIOP_Connector.cpp | 17 | ||||
-rw-r--r-- | TAO/tao/Messaging/Connection_Timeout_Policy_i.cpp | 170 | ||||
-rw-r--r-- | TAO/tao/Messaging/Connection_Timeout_Policy_i.h | 101 | ||||
-rw-r--r-- | TAO/tao/Messaging/Makefile | 1 | ||||
-rw-r--r-- | TAO/tao/Messaging/Messaging.h | 2 | ||||
-rw-r--r-- | TAO/tao/Messaging/Messaging_ORBInitializer.cpp | 12 | ||||
-rw-r--r-- | TAO/tao/Messaging/Messaging_PolicyFactory.cpp | 10 | ||||
-rw-r--r-- | TAO/tao/Messaging/Messaging_Policy_i.cpp | 10 | ||||
-rw-r--r-- | TAO/tao/Messaging/Messaging_Policy_i.h | 34 | ||||
-rw-r--r-- | TAO/tao/Messaging/TAO_Messaging.dsp | 8 | ||||
-rw-r--r-- | TAO/tao/ORB_Core.cpp | 60 | ||||
-rw-r--r-- | TAO/tao/ORB_Core.h | 28 | ||||
-rw-r--r-- | TAO/tao/Stub.cpp | 48 | ||||
-rw-r--r-- | TAO/tao/Stub.h | 6 | ||||
-rw-r--r-- | TAO/tao/orbconf.h | 35 |
16 files changed, 543 insertions, 44 deletions
diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a index c2fd9e6e597..5f7c305897f 100644 --- a/TAO/ChangeLogs/ChangeLog-02a +++ b/TAO/ChangeLogs/ChangeLog-02a @@ -1,3 +1,48 @@ +Tue Apr 30 13:50:55 2002 Balachandran Natarajan <bala@cs.wustl.edu> + + * tao/IIOP_Connector.cpp: Checked to see if the connection timeout + policy is set. + + * tao/ORB_Core.cpp: + * tao/ORB_Core.h: Added new hook connection_timeout_hook () and + methods connection_timeout () and stubless_connection_timeout + (). They are used for setting the connection timeout hook and + for querying the timeout values on the ORB and thread levels. + + * tao/Stub.cpp: + * tao/Stub.h: Added a new method connection_timeout () that + queries the policy list at the object level. + + * tao/orbconf.h: + Removed TAO_HAS_MINIMUM_CONNECTION_CACHING_STRATEGY since it has + no meaning now. Added a new #define + TAO_HAS_CONNECTION_TIMEOUT_POLICY that can be configured into + the ORB. Added TAO_CACHED_POLICY_CONNECTION_TIMEOUT to the list + of cached policies in the ORB. + + * tao/Messaging/Connection_Timeout_Policy_i.cpp: + * tao/Messaging/Connection_Timeout_Policy_i.h: New files + containing the implementation of the new proprietary policy. + + * tao/Messaging/TAO_Messaging.dsp: + * tao/Messaging/Makefile: Added the new file. + + * tao/Messaging/Messaging.h: #included TAO_ExtC.h + + * tao/Messaging/Messaging_ORBInitializer.cpp: Initialized the hook + for the connection timeout. + + * tao/Messaging/Messaging_PolicyFactory.cpp: Added a call to + create the connection timeout policy. + + * tao/Messaging/Messaging_Policy_i.cpp: Moved the inline inclusion + to the global scope. The inline inclusion was within the #if + defined of RELATIVE_RT_TIMEOUT_POLICY and it doesnt sound + right. + + * tao/Messaging/Messaging_Policy_i.h: Doxygenized the + documentation of the classes. + Tue Apr 30 09:36:37 2002 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu> * TAO_IDL/driver/drv_preproc.cpp (DRV_cpp_init): Removed a stray diff --git a/TAO/tao/IIOP_Connector.cpp b/TAO/tao/IIOP_Connector.cpp index 2b420db2fdf..fa35897a546 100644 --- a/TAO/tao/IIOP_Connector.cpp +++ b/TAO/tao/IIOP_Connector.cpp @@ -161,9 +161,20 @@ TAO_IIOP_Connector::make_connection (TAO_GIOP_Invocation *invocation, // Get the max_wait_time - // @@todo: Right place for Jon Reis stuff!! - ACE_Time_Value *max_wait_time = - invocation->max_wait_time (); + ACE_Time_Value *max_wait_time = 0; + + ACE_Time_Value connection_timeout; + int timeout = 0; + + this->orb_core ()->connection_timeout (invocation->stub (), + timeout, + connection_timeout); + if (!timeout) + max_wait_time = + invocation->max_wait_time (); + else + max_wait_time = &connection_timeout; + // Get the right synch options ACE_Synch_Options synch_options; diff --git a/TAO/tao/Messaging/Connection_Timeout_Policy_i.cpp b/TAO/tao/Messaging/Connection_Timeout_Policy_i.cpp new file mode 100644 index 00000000000..fb3e2342e88 --- /dev/null +++ b/TAO/tao/Messaging/Connection_Timeout_Policy_i.cpp @@ -0,0 +1,170 @@ +#include "Connection_Timeout_Policy_i.h" +#include "tao/ORB_Core.h" +#include "tao/Stub.h" + +ACE_RCSID (Messaging, + Connection_Timeout_Policy_i, + "$Id$") + + +#if (TAO_HAS_CONNECTION_TIMEOUT_POLICY == 1) + +TAO_ConnectionTimeoutPolicy::TAO_ConnectionTimeoutPolicy ( + const TimeBase::TimeT& relative_expiry) + : relative_expiry_ (relative_expiry) +{ +} + +TAO_ConnectionTimeoutPolicy::TAO_ConnectionTimeoutPolicy ( + const TAO_ConnectionTimeoutPolicy &rhs) + : TAO::ConnectionTimeoutPolicy (), + TAO_Local_RefCounted_Object (), + relative_expiry_ (rhs.relative_expiry_) +{ +} + +TimeBase::TimeT +TAO_ConnectionTimeoutPolicy::relative_expiry ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return this->relative_expiry_; +} + +CORBA::PolicyType +TAO_ConnectionTimeoutPolicy::policy_type ( + ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return TAO::CONNECTION_TIMEOUT_POLICY_TYPE; +} + +void +TAO_ConnectionTimeoutPolicy::hook (TAO_ORB_Core *orb_core, + TAO_Stub *stub, + int &has_timeout, + ACE_Time_Value &time_value) +{ + CORBA::Policy_var policy = + (stub == 0 + ? orb_core->stubless_connection_timeout () + : stub->connection_timeout ()); + + if (CORBA::is_nil (policy.in ())) + { + has_timeout = 0; + return; + } + ACE_TRY_NEW_ENV + { + TAO::ConnectionTimeoutPolicy_var p = + TAO::ConnectionTimeoutPolicy::_narrow ( + policy.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + TimeBase::TimeT t = p->relative_expiry (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + TimeBase::TimeT seconds = t / 10000000u; + TimeBase::TimeT microseconds = (t % 10000000u) / 10; + time_value.set (ACE_U64_TO_U32 (seconds), + ACE_U64_TO_U32 (microseconds)); + + // Set the flag once all operations complete successfully + has_timeout = 1; + + if (TAO_debug_level > 0) + { + CORBA::ULong msecs = + ACE_static_cast (CORBA::ULong, microseconds / 1000); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) Timeout is <%u>\n"), + msecs)); + } + } + ACE_CATCHANY + { + // Ignore all exceptions... + } + ACE_ENDTRY; +} + +CORBA::Policy_ptr +TAO_ConnectionTimeoutPolicy::create (const CORBA::Any& val + ACE_ENV_ARG_DECL) +{ + // Future policy implementors: notice how the following code is + // exception safe! + + TimeBase::TimeT value; + if ((val >>= value) == 0) + ACE_THROW_RETURN (CORBA::PolicyError (CORBA::BAD_POLICY_TYPE), + CORBA::Policy::_nil ()); + + TAO_ConnectionTimeoutPolicy *tmp; + ACE_NEW_THROW_EX (tmp, + TAO_ConnectionTimeoutPolicy (value), + CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE, + CORBA::COMPLETED_NO)); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); + + return tmp; +} + +TAO_ConnectionTimeoutPolicy * +TAO_ConnectionTimeoutPolicy::clone (void) const +{ + TAO_ConnectionTimeoutPolicy *copy = 0; + ACE_NEW_RETURN (copy, + TAO_ConnectionTimeoutPolicy (*this), + 0); + return copy; +} + +CORBA::Policy_ptr +TAO_ConnectionTimeoutPolicy::copy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // Future policy implementors: notice how the following code is + // exception safe! + TAO_ConnectionTimeoutPolicy* tmp = 0; + ACE_NEW_THROW_EX (tmp, + TAO_ConnectionTimeoutPolicy (*this), + CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE, + CORBA::COMPLETED_NO)); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); + + return tmp; +} + +void +TAO_ConnectionTimeoutPolicy::destroy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +TAO_Cached_Policy_Type +TAO_ConnectionTimeoutPolicy::_tao_cached_type (void) const +{ + return TAO_CACHED_POLICY_CONNECTION_TIMEOUT; +} + +void +TAO_ConnectionTimeoutPolicy::set_time_value (ACE_Time_Value &time_value) +{ + TimeBase::TimeT t = this->relative_expiry_; + TimeBase::TimeT seconds = t / 10000000u; + TimeBase::TimeT microseconds = (t % 10000000u) / 10; + time_value.set (ACE_U64_TO_U32 (seconds), + ACE_U64_TO_U32 (microseconds)); + + if (TAO_debug_level > 0) + { + CORBA::ULong msecs = time_value.msec (); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) - Timeout is <%u>\n"), + msecs)); + } +} + +#endif /* TAO_HAS_RELATIVE_ROUNDTRIP_TIMEOUT_POLICY == 1 */ diff --git a/TAO/tao/Messaging/Connection_Timeout_Policy_i.h b/TAO/tao/Messaging/Connection_Timeout_Policy_i.h new file mode 100644 index 00000000000..b20e4842ece --- /dev/null +++ b/TAO/tao/Messaging/Connection_Timeout_Policy_i.h @@ -0,0 +1,101 @@ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file Connection_Timeout_Policy_i.h + * + * $Id$ + * + * @author Balachandran Natarajan (bala@cs.wustl.edu) + */ +//============================================================================= + + +#ifndef TAO_CONNECTION_TIMEOUT_POLICY_I_H +#define TAO_CONNECTION_TIMEOUT_POLICY_I_H +#include "ace/pre.h" + +#include "tao/orbconf.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "TAO_ExtC.h" +#include "tao/LocalObject.h" + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + + +#if (TAO_HAS_CONNECTION_TIMEOUT_POLICY == 1) + +/* + * @class TAO_ConnectionTimeoutPolicy + * + * @brief TAO::ConnectionTimeoutPolicy implementation + * + * This policy controls the connection timeout time while + * establishing connections. This policy is proprietary to TAO. + */ +class TAO_Messaging_Export TAO_ConnectionTimeoutPolicy + : public TAO::ConnectionTimeoutPolicy, + public TAO_Local_RefCounted_Object +{ + +public: + /// Constructor. + TAO_ConnectionTimeoutPolicy (const TimeBase::TimeT& relative_expiry); + + /// Copy constructor. + TAO_ConnectionTimeoutPolicy (const TAO_ConnectionTimeoutPolicy &rhs); + + /// Implement the timeout hook, this is set in the ORB_Core at + /// initialization time. + static void hook (TAO_ORB_Core *orb_core, + TAO_Stub *stub, + int &has_timeout, + ACE_Time_Value &time_value); + + /// Helper method for the implementation of + /// CORBA::ORB::create_policy. + static CORBA::Policy_ptr create (const CORBA::Any& val + ACE_ENV_ARG_DECL_WITH_DEFAULTS); + + /// Returns a copy of <this>. + virtual TAO_ConnectionTimeoutPolicy *clone (void) const; + + // = The TAO::ConnectionTinoutPolicy methods + virtual TimeBase::TimeT relative_expiry (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual CORBA::PolicyType policy_type (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual CORBA::Policy_ptr copy (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + /// Change the CORBA representation to the ACE representation. + void set_time_value (ACE_Time_Value &time_value); + + /// Return the cached policy type for this policy. + virtual TAO_Cached_Policy_Type _tao_cached_type (void) const; + +private: + /// The attribute + TimeBase::TimeT relative_expiry_; +}; + +#endif /* TAO_HAS_RELATIVE_ROUNDTRIP_TIMEOUT_POLICY == 1 */ + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#endif /*TAO_CONNECTION_TIMEOUT_POLICY_I_H*/ diff --git a/TAO/tao/Messaging/Makefile b/TAO/tao/Messaging/Makefile index 5182fc79289..03c220a207e 100644 --- a/TAO/tao/Messaging/Makefile +++ b/TAO/tao/Messaging/Makefile @@ -18,6 +18,7 @@ CPP_SRCS += \ Twoway_Asynch_Invocation \ Asynch_Reply_Dispatcher \ Asynch_Timeout_Handler \ + Connection_Timeout_Policy_i \ Messaging \ MessagingC \ MessagingS \ diff --git a/TAO/tao/Messaging/Messaging.h b/TAO/tao/Messaging/Messaging.h index 4994282ae7c..34cb02dfd45 100644 --- a/TAO/tao/Messaging/Messaging.h +++ b/TAO/tao/Messaging/Messaging.h @@ -44,8 +44,10 @@ TAO_Requires_Messaging_Initializer = TAO_Messaging_Initializer::init (); #include "MessagingC.h" #undef TAO_MESSAGING_SAFE_INCLUDE +#include "TAO_ExtC.h" #include "tao/TAOC.h" + // Typedef for the Reply Handler Skeleton. // This is handcrafted not generated by the IDL compiler. diff --git a/TAO/tao/Messaging/Messaging_ORBInitializer.cpp b/TAO/tao/Messaging/Messaging_ORBInitializer.cpp index 0bd34bdda96..b76dec9f8ca 100644 --- a/TAO/tao/Messaging/Messaging_ORBInitializer.cpp +++ b/TAO/tao/Messaging/Messaging_ORBInitializer.cpp @@ -3,6 +3,7 @@ #include "Messaging_ORBInitializer.h" #include "Messaging_Policy_i.h" +#include "Connection_Timeout_Policy_i.h" #include "Messaging_PolicyFactory.h" #include "tao/ORB_Core.h" @@ -24,6 +25,12 @@ TAO_Messaging_ORBInitializer::pre_init ( #if (TAO_HAS_SYNC_SCOPE_POLICY == 1) TAO_ORB_Core::set_sync_scope_hook (TAO_Sync_Scope_Policy::hook); #endif /* TAO_HAS_SYNC_SCOPE_POLICY == 1 */ + +#if (TAO_HAS_CONNECTION_TIMEOUT_POLICY == 1) + TAO_ORB_Core::connection_timeout_hook + (TAO_ConnectionTimeoutPolicy::hook); +#endif /* TAO_HAS_CONNECTION_TIMEOUT_POLICY == 1 */ + } void @@ -103,7 +110,10 @@ TAO_Messaging_ORBInitializer::register_policy_factories ( #if (TAO_HAS_MAX_HOPS_POLICY == 1) Messaging::MAX_HOPS_POLICY_TYPE, #endif /* TAO_HAS_MAX_HOPS_POLICY == 1 */ - Messaging::QUEUE_ORDER_POLICY_TYPE + Messaging::QUEUE_ORDER_POLICY_TYPE, +#if (TAO_HAS_CONNECTION_TIMEOUT_POLICY == 1) + TAO::CONNECTION_TIMEOUT_POLICY_TYPE +#endif /* TAO_HAS_CONNECTION_TIMEOUT_POLICY == 1 */ }; const CORBA::PolicyType *end = type + sizeof (type) / sizeof (type[0]); diff --git a/TAO/tao/Messaging/Messaging_PolicyFactory.cpp b/TAO/tao/Messaging/Messaging_PolicyFactory.cpp index 4ffdfedb4ee..30f7b71ed99 100644 --- a/TAO/tao/Messaging/Messaging_PolicyFactory.cpp +++ b/TAO/tao/Messaging/Messaging_PolicyFactory.cpp @@ -5,7 +5,7 @@ ACE_RCSID (tao, "$Id$") #include "Messaging_Policy_i.h" - +#include "Connection_Timeout_Policy_i.h" #include "tao/PolicyC.h" #include "tao/Buffering_Constraint_Policy.h" @@ -23,6 +23,12 @@ TAO_Messaging_PolicyFactory::create_policy ( ACE_ENV_ARG_PARAMETER); #endif /* TAO_HAS_RELATIVE_ROUNDTRIP_TIMEOUT_POLICY == 1 */ +#if (TAO_HAS_CONNECTION_TIMEOUT_POLICY == 1) + if (type == TAO::CONNECTION_TIMEOUT_POLICY_TYPE) + return TAO_ConnectionTimeoutPolicy::create (value + ACE_ENV_ARG_PARAMETER); +#endif /* TAO_HAS_RELATIVE_ROUNDTRIP_TIMEOUT_POLICY == 1 */ + #if (TAO_HAS_SYNC_SCOPE_POLICY == 1) if (type == Messaging::SYNC_SCOPE_POLICY_TYPE) return TAO_Sync_Scope_Policy::create (value @@ -73,5 +79,3 @@ TAO_Messaging_PolicyFactory::create_policy ( ACE_THROW_RETURN (CORBA::PolicyError (CORBA::BAD_POLICY_TYPE), CORBA::Policy::_nil ()); } - - diff --git a/TAO/tao/Messaging/Messaging_Policy_i.cpp b/TAO/tao/Messaging/Messaging_Policy_i.cpp index 06de6392af9..1e103072f6d 100644 --- a/TAO/tao/Messaging/Messaging_Policy_i.cpp +++ b/TAO/tao/Messaging/Messaging_Policy_i.cpp @@ -4,16 +4,16 @@ #include "tao/Stub.h" #include "tao/debug.h" -ACE_RCSID (TAO, +#if ! defined (__ACE_INLINE__) +#include "Messaging_Policy_i.i" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID (Messaging, Messaging_Policy_i, "$Id$") #if (TAO_HAS_RELATIVE_ROUNDTRIP_TIMEOUT_POLICY == 1) -#if ! defined (__ACE_INLINE__) -#include "tao/Messaging/Messaging_Policy_i.i" -#endif /* __ACE_INLINE__ */ - TAO_RelativeRoundtripTimeoutPolicy::TAO_RelativeRoundtripTimeoutPolicy ( const TimeBase::TimeT& relative_expiry) : relative_expiry_ (relative_expiry) diff --git a/TAO/tao/Messaging/Messaging_Policy_i.h b/TAO/tao/Messaging/Messaging_Policy_i.h index 8dba81af5b9..35ed356f7cc 100644 --- a/TAO/tao/Messaging/Messaging_Policy_i.h +++ b/TAO/tao/Messaging/Messaging_Policy_i.h @@ -27,17 +27,19 @@ #if (TAO_HAS_RELATIVE_ROUNDTRIP_TIMEOUT_POLICY == 1) +/* + * @class TAO_RelativeRoundtripTimeoutPolicy + * + * @brief Messaging::RelativeRoundtripTimeoutPolicy implementation + * + * This policy controls the total (round-trip) timeout time for a + * request. + */ class TAO_Messaging_Export TAO_RelativeRoundtripTimeoutPolicy : public Messaging::RelativeRoundtripTimeoutPolicy, public TAO_Local_RefCounted_Object { - // = TITLE - // Messaging::RelativeRoundtripTimeoutPolicy implementation - // - // = DESCRIPTION - // This policy controls the total (round-trip) timeout time for a - // request. - // + public: /// Constructor. TAO_RelativeRoundtripTimeoutPolicy (const TimeBase::TimeT& relative_expiry); @@ -90,17 +92,19 @@ private: #if (TAO_HAS_SYNC_SCOPE_POLICY == 1) +/* + * @class TAO_Sync_Scope_Policy + * + * @brief Messaging::SyncScopePolicy implementation. + * + * This policy controls the sync strategy used by the ORB to transport + * requests. + */ class TAO_Messaging_Export TAO_Sync_Scope_Policy : public Messaging::SyncScopePolicy, public TAO_Local_RefCounted_Object { - // = TITLE - // Messaging::SyncScopePolicy implementation. - // - // = DESCRIPTION - // This policy controls the sync strategy used by the ORB to - // transport requests. - // + public: /// Constructor. TAO_Sync_Scope_Policy (Messaging::SyncScope synchronization); @@ -150,7 +154,7 @@ private: #endif /* TAO_HAS_SYNC_SCOPE_POLICY == 1 */ #if defined (__ACE_INLINE__) -#include "tao/Messaging/Messaging_Policy_i.i" +#include "Messaging_Policy_i.i" #endif /* __ACE_INLINE__ */ #if defined(_MSC_VER) && (_MSC_VER >= 1200) diff --git a/TAO/tao/Messaging/TAO_Messaging.dsp b/TAO/tao/Messaging/TAO_Messaging.dsp index f6b0b388905..7b8be6419d3 100644 --- a/TAO/tao/Messaging/TAO_Messaging.dsp +++ b/TAO/tao/Messaging/TAO_Messaging.dsp @@ -164,6 +164,10 @@ SOURCE=.\Asynch_Timeout_Handler.cpp # End Source File
# Begin Source File
+SOURCE=.\Connection_Timeout_Policy_i.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\Messaging.cpp
# End Source File
# Begin Source File
@@ -208,6 +212,10 @@ SOURCE=.\Asynch_Timeout_Handler.h # End Source File
# Begin Source File
+SOURCE=.\Connection_Timeout_Policy_i.h
+# End Source File
+# Begin Source File
+
SOURCE=.\Messaging.h
# End Source File
# Begin Source File
diff --git a/TAO/tao/ORB_Core.cpp b/TAO/tao/ORB_Core.cpp index 3c6703144fc..c380d0ba644 100644 --- a/TAO/tao/ORB_Core.cpp +++ b/TAO/tao/ORB_Core.cpp @@ -74,6 +74,7 @@ TAO_default_environment () // **************************************************************** TAO_ORB_Core::Timeout_Hook TAO_ORB_Core::timeout_hook_ = 0; +TAO_ORB_Core::Timeout_Hook TAO_ORB_Core::connection_timeout_hook_ = 0; TAO_ORB_Core::Sync_Scope_Hook TAO_ORB_Core::sync_scope_hook_ = 0; ACE_CString TAO_ORB_Core::endpoint_selector_factory_name_ = @@ -2693,6 +2694,65 @@ TAO_ORB_Core::stubless_relative_roundtrip_timeout (void) } +void +TAO_ORB_Core::connection_timeout (TAO_Stub *stub, + int &has_timeout, + ACE_Time_Value &time_value) +{ + if (TAO_ORB_Core::connection_timeout_hook_ == 0) + { + has_timeout = 0; + return; + } + (*TAO_ORB_Core::connection_timeout_hook_) (this, stub, has_timeout, time_value); +} + +void +TAO_ORB_Core::connection_timeout_hook (Timeout_Hook hook) +{ + // Saving the hook pointer so that we can use it later when needed. + TAO_ORB_Core::connection_timeout_hook_ = hook; + + return; +} + +CORBA::Policy_ptr +TAO_ORB_Core::stubless_connection_timeout (void) +{ + CORBA::Policy_var result; + +#if (TAO_HAS_CORBA_MESSAGING == 1 \ + && TAO_HAS_CONNECTION_TIMEOUT_POLICY == 1) + + // No need to lock, the object is in TSS storage.... + TAO_Policy_Current &policy_current = + this->policy_current (); + result = policy_current.get_cached_policy ( + TAO_CACHED_POLICY_CONNECTION_TIMEOUT); + + // @@ Must lock, but is is harder to implement than just modifying + // this call: the ORB does take a lock to modify the policy + // manager + if (CORBA::is_nil (result.in ())) + { + TAO_Policy_Manager *policy_manager = + this->policy_manager (); + if (policy_manager != 0) + result = policy_manager->get_cached_policy ( + TAO_CACHED_POLICY_CONNECTION_TIMEOUT); + } + + if (CORBA::is_nil (result.in ())) + result = this->default_policies_->get_cached_policy ( + TAO_CACHED_POLICY_CONNECTION_TIMEOUT); + +#endif /* TAO_HAS_CORBA_MESSAGING == 1 + && TAO_HAS_CONNECTION_TIMEOUT_POLICY == 1 */ + + return result._retn (); +} + + #if (TAO_HAS_CORBA_MESSAGING == 1) CORBA::Policy_ptr diff --git a/TAO/tao/ORB_Core.h b/TAO/tao/ORB_Core.h index 4c48cf8766c..bd7aefd0e0e 100644 --- a/TAO/tao/ORB_Core.h +++ b/TAO/tao/ORB_Core.h @@ -557,14 +557,39 @@ public: static void set_timeout_hook (Timeout_Hook hook); + /// Access to the RoundtripTimeoutPolicy policy set on the thread or /// on the ORB. In this method, we do not consider the stub since /// we do not have access to it. CORBA::Policy_ptr stubless_relative_roundtrip_timeout (void); + /// Invoke the timeout hook if present. + /** + * The timeout hook is used to determine if the timeout policy is + * set and with what value. If the ORB is compiled without support + * for Messaging this feature does not take effect + * \param has_timeout returns 0 if there is no timeout policy set. + * \param time_value returns the timeout value in effect for the object, + * thread and current ORB. + */ + void connection_timeout (TAO_Stub *stub, + int &has_timeout, + ACE_Time_Value &time_value); + + /// Define the Timeout_Hook signature + static void connection_timeout_hook (Timeout_Hook hook); + + + /// Access to the connection timeout policy set on the thread or + /// on the ORB. In this method, we do not consider the stub since + /// we do not have access to it. + CORBA::Policy_ptr stubless_connection_timeout (void); + + void call_sync_scope_hook (TAO_Stub *stub, int &has_synchronization, Messaging::SyncScope &scope); + TAO_Sync_Strategy &get_sync_strategy (TAO_Stub *stub, Messaging::SyncScope &scope); typedef void (*Sync_Scope_Hook) (TAO_ORB_Core *, @@ -969,6 +994,9 @@ private: /// The hook to be set for the RelativeRoundtripTimeoutPolicy. static Timeout_Hook timeout_hook_; + /// The hook to be set for the ConnectionTimeoutPolicy + static Timeout_Hook connection_timeout_hook_; + protected: /// Synchronize internal state... diff --git a/TAO/tao/Stub.cpp b/TAO/tao/Stub.cpp index 0303f6e27ed..b20ea7aa514 100644 --- a/TAO/tao/Stub.cpp +++ b/TAO/tao/Stub.cpp @@ -716,6 +716,54 @@ TAO_Stub::sync_scope (void) #endif /* TAO_HAS_SYNC_SCOPE_POLICY == 1 */ + + +CORBA::Policy_ptr +TAO_Stub::connection_timeout (void) +{ + CORBA::Policy_var p; + +#if (TAO_HAS_CONNECTION_TIMEOUT_POLICY == 1) + + // No need to lock, the stub only changes its policies at + // construction time... + if (this->policies_ != 0) + p = this->policies_->get_cached_policy ( + TAO_CACHED_POLICY_CONNECTION_TIMEOUT); + + // No need to lock, the object is in TSS storage.... + if (CORBA::is_nil (p.in ())) + { + TAO_Policy_Current &policy_current = + this->orb_core_->policy_current (); + p = policy_current.get_cached_policy ( + TAO_CACHED_POLICY_CONNECTION_TIMEOUT); + } + + // @@ Must lock, but is is harder to implement than just modifying + // this call: the ORB does take a lock to modify the policy + // manager + if (CORBA::is_nil (p.in ())) + { + TAO_Policy_Manager *policy_manager = + this->orb_core_->policy_manager (); + if (policy_manager != 0) + p = policy_manager->get_cached_policy ( + TAO_CACHED_POLICY_CONNECTION_TIMEOUT); + } + + if (CORBA::is_nil (p.in ())) + p = this->orb_core_->get_default_policies ()->get_cached_policy ( + TAO_CACHED_POLICY_CONNECTION_TIMEOUT); + +#endif /* TAO_HAS_CONNECTION_TIMEOUT_POLICY == 1 */ + + return p._retn (); +} + + + + #if (TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1) CORBA::Policy_ptr diff --git a/TAO/tao/Stub.h b/TAO/tao/Stub.h index f68d227e0f5..aa11427cd91 100644 --- a/TAO/tao/Stub.h +++ b/TAO/tao/Stub.h @@ -140,6 +140,12 @@ public: #endif /* TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1 */ +#if (TAO_HAS_CONNECTION_TIMEOUT_POLICY == 1) + + CORBA::Policy_ptr connection_timeout (void); + +#endif /* TAO_HAS_CONNECTION_TIMEOUT_POLICY == 1 */ + /// Return the sync strategy to be used in by the transport. /// Selection will be based on the SyncScope policies. TAO_Sync_Strategy &sync_strategy (void); diff --git a/TAO/tao/orbconf.h b/TAO/tao/orbconf.h index db530e74dc6..6021ef12961 100644 --- a/TAO/tao/orbconf.h +++ b/TAO/tao/orbconf.h @@ -675,6 +675,19 @@ enum TAO_MCAST_SERVICEID TAO_DISABLE_CORBA_MESSAGING_POLICIES == 0 */ #endif /* !TAO_HAS_RELATIVE_ROUNDTRIP_TIMEOUT_POLICY */ +// Default CONNECTION_TIMEOUT_POLICY settings. This is a proprietary +// TAO policy. +#if !defined (TAO_HAS_CONNECTION_TIMEOUT_POLICY) +# if (TAO_HAS_CORBA_MESSAGING == 1) && \ + (TAO_DISABLE_CORBA_MESSAGING_POLICIES == 0) +# define TAO_HAS_CONNECTION_TIMEOUT_POLICY 1 +# else +# define TAO_HAS_CONNECTION_TIMEOUT_POLICY 0 +# endif /* TAO_HAS_CORBA_MESSAGING == 1 && + TAO_DISABLE_CORBA_MESSAGING_POLICIES == 0 */ +#endif /* !TAO_HAS_CONNECTION_TIMEOUT_POLICY */ + + // To explicitly disable ROUTING_POLICY support uncomment the following // #define TAO_HAS_ROUTING_POLICY 0 @@ -812,29 +825,13 @@ enum TAO_MCAST_SERVICEID # endif /* TAO_HAS_MINIMUM_CORBA */ #endif -// MINIMUM_CONNECTION_CACHING_STRATEGY support is disabled by default if TAO is not -// configured for minimum CORBA. If TAO is configured for minimum -// CORBA, then MINIMUM_CONNECTION_CACHING_STRATEGY will be enabled by default. -// To explicitly enable MINIMUM_CONNECTION_CACHING_STRATEGY support uncomment the following -// #define TAO_HAS_MINIMUM_CONNECTION_CACHING_STRATEGY 1 -// To explicitly disable MINIMUM_CONNECTION_CACHING_STRATEGY support uncomment the following -// #define TAO_HAS_MINIMUM_CONNECTION_CACHING_STRATEGY 0 - -// Default MINIMUM_CONNECTION_CACHING_STRATEGY settings -#if !defined (TAO_HAS_MINIMUM_CONNECTION_CACHING_STRATEGY) -# if (TAO_HAS_MINIMUM_CORBA == 1) -# define TAO_HAS_MINIMUM_CONNECTION_CACHING_STRATEGY 1 -# else -# define TAO_HAS_MINIMUM_CONNECTION_CACHING_STRATEGY 0 -# endif /* TAO_HAS_MINIMUM_CORBA */ -#endif /* !TAO_HAS_MINIMUM_CONNECTION_CACHING_STRATEGY */ - // Define the policy types as literals, so they can be used in switch // statements #define TAO_CLIENT_PRIORITY_POLICY_TYPE 0x54410000 #define TAO_BUFFERING_CONSTRAINT_POLICY_TYPE 0x54410001 #define TAO_CONNECTION_TIMEOUT_POLICY_TYPE 0x54410008 + // #define TAO_RT_PRIORITY_MODEL_POLICY_TYPE 0x54410002 // #define TAO_RT_THREADPOOL_POLICY_TYPE 0x54410003 // #define TAO_RT_PRIVATE_CONNECTION_POLICY_TYPE 0x54410006 @@ -885,6 +882,10 @@ enum TAO_Cached_Policy_Type TAO_CACHED_POLICY_BUFFERING_CONSTRAINT, #endif /* TAO_HAS_BUFFERING_CONSTRAINT_POLICY == 1 */ +#if (TAO_HAS_CONNECTION_TIMEOUT_POLICY == 1) + TAO_CACHED_POLICY_CONNECTION_TIMEOUT, +#endif /* TAO_HAS_CONNECTION_TIMEOUT_POLICY == 1 */ + TAO_CACHED_POLICY_BIDIRECTIONAL_GIOP, TAO_CACHED_POLICY_MAX_CACHED |