summaryrefslogtreecommitdiff
path: root/TAO/tao/Messaging
diff options
context:
space:
mode:
authorbala <balanatarajan@users.noreply.github.com>2002-04-30 19:05:43 +0000
committerbala <balanatarajan@users.noreply.github.com>2002-04-30 19:05:43 +0000
commitce2a96a2d3c27ce939cfcdf0b7100b66b29ac6d2 (patch)
treed4b54dd9f18f5fccce0cc80c8a96368ccf9b38a5 /TAO/tao/Messaging
parenta8e16148a1f420a27db493b15bc6427106577293 (diff)
downloadATCD-ce2a96a2d3c27ce939cfcdf0b7100b66b29ac6d2.tar.gz
ChangeLogTag: Tue Apr 30 13:50:55 2002 Balachandran Natarajan <bala@cs.wustl.edu>
Diffstat (limited to 'TAO/tao/Messaging')
-rw-r--r--TAO/tao/Messaging/Connection_Timeout_Policy_i.cpp170
-rw-r--r--TAO/tao/Messaging/Connection_Timeout_Policy_i.h101
-rw-r--r--TAO/tao/Messaging/Makefile1
-rw-r--r--TAO/tao/Messaging/Messaging.h2
-rw-r--r--TAO/tao/Messaging/Messaging_ORBInitializer.cpp12
-rw-r--r--TAO/tao/Messaging/Messaging_PolicyFactory.cpp10
-rw-r--r--TAO/tao/Messaging/Messaging_Policy_i.cpp10
-rw-r--r--TAO/tao/Messaging/Messaging_Policy_i.h34
-rw-r--r--TAO/tao/Messaging/TAO_Messaging.dsp8
9 files changed, 324 insertions, 24 deletions
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