diff options
Diffstat (limited to 'TAO/tao')
35 files changed, 1814 insertions, 24 deletions
diff --git a/TAO/tao/ORB_Core.h b/TAO/tao/ORB_Core.h index 8bf85dcd2f7..15967c95d49 100644 --- a/TAO/tao/ORB_Core.h +++ b/TAO/tao/ORB_Core.h @@ -1409,9 +1409,6 @@ public: private: - /// The singleton instance. -// static TAO_ORB_Core_Static_Resources* instance_; - /// Mostly unused variable whose sole purpose is to enforce /// the instantiation of a TAO_ORB_Core_Static_Resources instance /// at initialization time. diff --git a/TAO/tao/Profile_Transport_Resolver.cpp b/TAO/tao/Profile_Transport_Resolver.cpp index c8f6a31b4d5..f3beae91869 100644 --- a/TAO/tao/Profile_Transport_Resolver.cpp +++ b/TAO/tao/Profile_Transport_Resolver.cpp @@ -39,7 +39,7 @@ namespace TAO this->profile_->_decr_refcnt (); } - if (this->transport_) + if (this->transport_.get ()) { if (this->is_released_ == false) { @@ -93,7 +93,7 @@ namespace TAO ACE_ENV_ARG_PARAMETER); ACE_CHECK; - if (this->transport_ == 0) + if (this->transport_.get () == 0) { ACE_THROW (CORBA::INTERNAL ()); } @@ -187,20 +187,20 @@ namespace TAO ACE_ASSERT(con != 0); if (parallel) { - this->transport_ = con->parallel_connect (this, desc, timeout - ACE_ENV_ARG_PARAMETER); + this->transport_.set (con->parallel_connect (this, desc, timeout + ACE_ENV_ARG_PARAMETER)); } else { - this->transport_ = con->connect (this, desc, timeout - ACE_ENV_ARG_PARAMETER); + this->transport_.set (con->connect (this, desc, timeout + ACE_ENV_ARG_PARAMETER)); } ACE_CHECK_RETURN (false); // A timeout error occurred. // If the user has set a roundtrip timeout policy, throw a timeout // exception. Otherwise, just fall through and return false to // look at the next endpoint. - if (this->transport_ == 0 && + if (this->transport_.get () == 0 && has_con_timeout == false && errno == ETIME) { @@ -211,7 +211,7 @@ namespace TAO CORBA::COMPLETED_NO), false); } - else if (this->transport_ == 0) + else if (this->transport_.get () == 0) { return false; } @@ -272,7 +272,12 @@ namespace TAO // the cache increments the reference count on the transport if the // find is successful. Find_transport uses negative logic in its return, // 0 for success - return (cache.find_transport(desc,this->transport_) == 0); + TAO_Transport* tmp = this->transport_.get (); + if (cache.find_transport(desc, tmp) != 0) + return -1; + + this->transport_.set (tmp); + return 0; } diff --git a/TAO/tao/Profile_Transport_Resolver.h b/TAO/tao/Profile_Transport_Resolver.h index 34cef016395..2816f63dc2c 100644 --- a/TAO/tao/Profile_Transport_Resolver.h +++ b/TAO/tao/Profile_Transport_Resolver.h @@ -24,6 +24,7 @@ #include "ace/CORBA_macros.h" #include "tao/SystemException.h" +#include "tao/Transport_Selection_Guard.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL class ACE_Time_Value; @@ -178,7 +179,10 @@ namespace TAO TAO_Stub *stub_; /// The transport selected for this invocation. - TAO_Transport *transport_; + + /// Using the wrapper guard ensures it is available for use with + /// the Transport Current interfaces. + TAO::Transport_Selection_Guard transport_; /// The profile that has been selected for this invocation. TAO_Profile *profile_; diff --git a/TAO/tao/Profile_Transport_Resolver.inl b/TAO/tao/Profile_Transport_Resolver.inl index 3617d71e3da..07e89301fa5 100644 --- a/TAO/tao/Profile_Transport_Resolver.inl +++ b/TAO/tao/Profile_Transport_Resolver.inl @@ -43,7 +43,7 @@ namespace TAO ACE_INLINE TAO_Transport * Profile_Transport_Resolver::transport (void) const { - return this->transport_; + return this->transport_.get (); } ACE_INLINE bool diff --git a/TAO/tao/TAO_Server_Request.cpp b/TAO/tao/TAO_Server_Request.cpp index 5a2cebeee48..18666d56946 100644 --- a/TAO/tao/TAO_Server_Request.cpp +++ b/TAO/tao/TAO_Server_Request.cpp @@ -82,6 +82,7 @@ TAO_ServerRequest::TAO_ServerRequest (TAO_Pluggable_Messaging *mesg_base, , caught_exception_ (0) , reply_status_ (-1) #endif /* TAO_HAS_INTERCEPTORS == 1 */ + , transport_selection_guard_ (transport) { ACE_FUNCTION_TIMEPROBE (TAO_SERVER_REQUEST_START); // No-op. @@ -126,6 +127,7 @@ TAO_ServerRequest::TAO_ServerRequest (TAO_Pluggable_Messaging *mesg_base, , caught_exception_ (0) , reply_status_ (-1) #endif /* TAO_HAS_INTERCEPTORS == 1 */ + , transport_selection_guard_ (transport) { this->profile_.object_key (object_key); parse_error = 0; @@ -163,6 +165,7 @@ TAO_ServerRequest::TAO_ServerRequest (TAO_ORB_Core * orb_core, , caught_exception_ (0) , reply_status_ (-1) #endif /* TAO_HAS_INTERCEPTORS == 1 */ + , transport_selection_guard_ (0) { // Have to use a const_cast<>. *sigh* this->profile_.object_key ( diff --git a/TAO/tao/TAO_Server_Request.h b/TAO/tao/TAO_Server_Request.h index 7cd383f5dd5..8034d920b28 100644 --- a/TAO/tao/TAO_Server_Request.h +++ b/TAO/tao/TAO_Server_Request.h @@ -29,6 +29,7 @@ #include "tao/Tagged_Profile.h" #include "tao/Service_Context.h" #include "tao/Object.h" +#include "tao/Transport_Selection_Guard.h" #if TAO_HAS_INTERCEPTORS == 1 @@ -375,6 +376,10 @@ private: /// Reply status for the current request. PortableInterceptor::ReplyStatus reply_status_; #endif /* TAO_HAS_INTERCEPTORS == 1 */ + + /// An RAII (resource acquisition is initialization) class instance + /// for interfacing with TSS storage for the "current" transport. + TAO::Transport_Selection_Guard transport_selection_guard_; }; TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/TAO_Server_Request.inl b/TAO/tao/TAO_Server_Request.inl index 48bc3d00d82..45c05553533 100644 --- a/TAO/tao/TAO_Server_Request.inl +++ b/TAO/tao/TAO_Server_Request.inl @@ -35,6 +35,7 @@ TAO_ServerRequest::TAO_ServerRequest (void) , caught_exception_ (0) , reply_status_ (-1) #endif /* TAO_HAS_INTERCEPTORS == 1 */ + , transport_selection_guard_ (0) { } diff --git a/TAO/tao/TSS_Resources.cpp b/TAO/tao/TSS_Resources.cpp index 73ec7175070..55bcde08649 100644 --- a/TAO/tao/TSS_Resources.cpp +++ b/TAO/tao/TSS_Resources.cpp @@ -23,7 +23,9 @@ TAO_TSS_Resources::TAO_TSS_Resources (void) #endif /* TAO_HAS_CORBA_MESSAGING == 1 */ , gui_resource_factory_ (0) - +#if (TAO_HAS_TRANSPORT_CURRENT == 1) + , tsg_ (0) +#endif /* TAO_HAS_TRANSPORT_CURRENT */ { } diff --git a/TAO/tao/TSS_Resources.h b/TAO/tao/TSS_Resources.h index 0891f1e43da..3212040ead3 100644 --- a/TAO/tao/TSS_Resources.h +++ b/TAO/tao/TSS_Resources.h @@ -33,6 +33,7 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL namespace TAO { class GUIResource_Factory; + class Transport_Selection_Guard; } /** * @class TAO_TSS_Resources @@ -105,6 +106,17 @@ public: * are operational only in within the context of GUI event loops. */ TAO::GUIResource_Factory * gui_resource_factory_; + +#if TAO_HAS_TRANSPORT_CURRENT == 1 + + /// A TSS for a pointer to the current transport guard (see + /// below). The guard keeps track of the Transport, if any that has + /// been selected for use by the current thread, in the context of + /// an upcall or client-side interceptor. + + TAO::Transport_Selection_Guard* tsg_; + +#endif /* TAO_HAS_TRANSPORT_CURRENT == 1 */ }; TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/Transport.cpp b/TAO/tao/Transport.cpp index 82bf0f3cdab..83f2a3f114d 100644 --- a/TAO/tao/Transport.cpp +++ b/TAO/tao/Transport.cpp @@ -160,6 +160,13 @@ TAO_Transport::TAO_Transport (CORBA::ULong tag, // Create TMS now. this->tms_ = cf->create_transport_mux_strategy (this); +#if TAO_HAS_TRANSPORT_CURRENT == 1 + // Allocate stats + ACE_NEW_THROW_EX (this->stats_, + TAO::Transport::Stats, + CORBA::NO_MEMORY ()); +#endif /* TAO_HAS_TRANSPORT_CURRENT == 1 */ + /* * Hook to add code that initializes components that * belong to the concrete protocol implementation. @@ -1209,21 +1216,33 @@ TAO_Transport::send_message_shared_i (TAO_Stub *stub, const ACE_Message_Block *message_block, ACE_Time_Value *max_wait_time) { + int ret = 0; + size_t message_length = message_block->length (); + switch (message_semantics) { case TAO_Transport::TAO_TWOWAY_REQUEST: - return this->send_synchronous_message_i (message_block, - max_wait_time); + ret = this->send_synchronous_message_i (message_block, + max_wait_time); + break; + case TAO_Transport::TAO_REPLY: - return this->send_reply_message_i (message_block, - max_wait_time); + ret = this->send_reply_message_i (message_block, + max_wait_time); + break; + case TAO_Transport::TAO_ONEWAY_REQUEST: - return this->send_asynchronous_message_i (stub, - message_block, - max_wait_time); + ret = this->send_asynchronous_message_i (stub, + message_block, + max_wait_time); + break; } - return -1; + // "Count" the message, only if no error was encountered. + if (ret != -1 && this->stats_ != 0) + this->stats_->messages_sent (message_length); + + return ret; } int @@ -2193,7 +2212,9 @@ TAO_Transport::process_parsed_messages (TAO_Queued_Data *qd, // Get the <message_type> that we have received const TAO_Pluggable_Message_Type t = qd->msg_type_; - // int result = 0; + // Update stats, if any + if (this->stats_ != 0) + this->stats_->messages_received (qd->msg_block_->length ()); if (t == TAO_PLUGGABLE_MESSAGE_CLOSECONNECTION) { diff --git a/TAO/tao/Transport.h b/TAO/tao/Transport.h index 1f2efb4ddd7..ad9a8a25155 100644 --- a/TAO/tao/Transport.h +++ b/TAO/tao/Transport.h @@ -28,6 +28,7 @@ #include "tao/Incoming_Message_Queue.h" #include "tao/Incoming_Message_Stack.h" #include "ace/Time_Value.h" +#include "ace/Basic_Stats.h" struct iovec; @@ -60,6 +61,13 @@ namespace TAO TAO_SERVER_ROLE = 1, TAO_CLIENT_ROLE = 2 }; + + namespace Transport + { + /// Transport-level statistics. Initially introduced to support + /// the "Transport Current" functionality. + class Stats; + } } /* @@ -770,6 +778,9 @@ public: /// connection is closed. void send_connection_closed_notifications (void); + /// Transport statistics + TAO::Transport::Stats* stats (void) const; + private: /// Helper method that returns the Transport Cache Manager. @@ -1065,6 +1076,9 @@ private: TAO_MMAP_Allocator * const mmap_allocator_; #endif /* TAO_HAS_SENDFILE==1 */ + /// Statistics + TAO::Transport::Stats* stats_; + /* * specialization hook to add class members from concrete * transport class onto the base transport class. Please @@ -1080,6 +1094,61 @@ private: //@@ TAO_TRANSPORT_SPL_EXTERN_ADD_HOOK +namespace TAO +{ + namespace Transport + { + /* + * @class Stats + * + * @brief Used to collect stats on a transport. + * + * The base class in (potentialy) extensible hierarchy used to + * specialize the information available for a specific protocol. + * + * This class is necessary for the implementation of the Transport + * Current feature. + * + * <B>See Also:</B> + * + * https://svn.dre.vanderbilt.edu/viewvc/Middleware/trunk/TAO/docs/transport_current/index.html?revision=HEAD + * + */ + class TAO_Export Stats + { + public: + Stats (); + + void messages_sent (size_t message_length); + CORBA::LongLong messages_sent (void) const; + CORBA::LongLong bytes_sent (void) const; + + void messages_received (size_t message_length); + CORBA::LongLong messages_received (void) const; + CORBA::LongLong bytes_received (void) const; + + void opened_since (const ACE_Time_Value& tv); + const ACE_Time_Value& opened_since (void) const; + + private: + // @NOTE: I could have used bytes_rcvd_.samples_count() instead, + // however there was a suspicion that 32 bits would be + // insufficient. + CORBA::LongLong messages_rcvd_; + + // @NOTE: I could have used bytes_sent_.samples_count() instead, + // however there was a suspicion that 32 bits would be + // insufficient. + CORBA::LongLong messages_sent_; + + ACE_Basic_Stats bytes_rcvd_; + ACE_Basic_Stats bytes_sent_; + + ACE_Time_Value opened_since_; + }; + } +} + TAO_END_VERSIONED_NAMESPACE_DECL #if defined (__ACE_INLINE__) diff --git a/TAO/tao/Transport.inl b/TAO/tao/Transport.inl index ef9faafb1ac..e53d2848830 100644 --- a/TAO/tao/Transport.inl +++ b/TAO/tao/Transport.inl @@ -189,4 +189,71 @@ TAO_Transport::sent_byte_count (void) const return this->sent_byte_count_; } +ACE_INLINE TAO::Transport::Stats* +TAO_Transport::stats (void) const +{ + return this->stats_; +} + +ACE_INLINE +TAO::Transport::Stats::Stats () + : messages_rcvd_ (0) + , messages_sent_ (0) + , bytes_rcvd_() + , bytes_sent_ () + , opened_since_ () +{ +} + +ACE_INLINE void +TAO::Transport::Stats::messages_sent (size_t message_length) +{ + this->messages_sent_++; + this->bytes_sent_.sample (message_length); +} + +ACE_INLINE CORBA::LongLong +TAO::Transport::Stats::messages_sent (void) const +{ + return this->messages_sent_; +} + +ACE_INLINE CORBA::LongLong +TAO::Transport::Stats::bytes_sent (void) const +{ + return this->bytes_sent_.sum_; +} + +ACE_INLINE void +TAO::Transport::Stats::messages_received (size_t message_length) +{ + this->messages_rcvd_++; + this->bytes_rcvd_.sample (message_length); +} + +ACE_INLINE CORBA::LongLong +TAO::Transport::Stats::messages_received (void) const +{ + return this->messages_rcvd_; +} + +ACE_INLINE CORBA::LongLong +TAO::Transport::Stats::bytes_received (void) const +{ + return this->bytes_rcvd_.sum_; +} + +ACE_INLINE void +TAO::Transport::Stats::opened_since (const ACE_Time_Value& tv) +{ + this->opened_since_ = tv; +} + +ACE_INLINE const ACE_Time_Value& +TAO::Transport::Stats::opened_since (void) const +{ + return this->opened_since_; +} + + TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/TransportCurrent/Current_Impl.cpp b/TAO/tao/TransportCurrent/Current_Impl.cpp new file mode 100644 index 00000000000..1965dd5bea2 --- /dev/null +++ b/TAO/tao/TransportCurrent/Current_Impl.cpp @@ -0,0 +1,106 @@ +// $Id:$ + +#include "tao/Transport.h" +#include "tao/Transport_Selection_Guard.h" + +#include "tao/TransportCurrent/Current_Loader.h" +#include "tao/TransportCurrent/Current_Impl.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace Transport + { + + /// ctor + Current_Impl::Current_Impl (TAO_ORB_Core* core, size_t tss_slot_id) + : core_ (core) + , tss_slot_id_ (tss_slot_id) + { + } + + /// dtor + Current_Impl::~Current_Impl (void) + { + } + + /// Obtains the current transport. Throws a NoContext exception + /// if, there was no "current" transport selected on the current + /// thread. + const TAO_Transport* + Current_Impl::transport (ACE_ENV_SINGLE_ARG_DECL) const + ACE_THROW_SPEC ((NoContext)) + { + Transport_Selection_Guard* topguard = + Transport_Selection_Guard::current (this->core_, this->tss_slot_id_); + + if (topguard == 0) + ACE_THROW (NoContext()); + ACE_CHECK; + + return topguard->get (); + } + + /// Obtains the current transport's stats + const TAO::Transport::Stats* + Current_Impl::transport_stats (ACE_ENV_SINGLE_ARG_DECL) const + ACE_THROW_SPEC ((NoContext)) + { + static const TAO::Transport::Stats dummy; + + const TAO_Transport* t = + this->transport (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + return (t==0 || t->stats () == 0) ? &dummy : t->stats (); + } + + CORBA::Long Current_Impl::id (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)) + { + const TAO_Transport* t = + this->transport (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + return (t==0) ? 0 : t->id (); + } + + CounterT Current_Impl::bytes_sent (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)) + { + return transport_stats ()->bytes_sent (); + } + + CounterT Current_Impl::bytes_received (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)) + { + return transport_stats ()->bytes_received (); + } + + CounterT Current_Impl::messages_sent (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)) + { + return transport_stats ()->messages_sent (); + } + + CounterT Current_Impl::messages_received (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)) + { + return transport_stats ()->messages_received (); + } + + TimeBase::TimeT Current_Impl::open_since (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)) + { + TimeBase::TimeT msecs = 0; + transport_stats ()->opened_since ().msec (msecs); + return msecs; + } + + }; + +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + diff --git a/TAO/tao/TransportCurrent/Current_Impl.h b/TAO/tao/TransportCurrent/Current_Impl.h new file mode 100644 index 00000000000..02e7df88e11 --- /dev/null +++ b/TAO/tao/TransportCurrent/Current_Impl.h @@ -0,0 +1,123 @@ +// $Id$ + +#ifndef CURRENT_IMPL_H +#define CURRENT_IMPL_H + +#include /**/ "ace/pre.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/TransportCurrent/TCC.h" +#include "tao/LocalObject.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +class TAO_Transport; + +namespace TAO +{ + namespace Transport + { + + // Forward decl + class Stats; + + /** + * @class Current_impl + * + * @brief Implementation of the TAO::Transport::Current + * interface. + * + * Current_Impl is useful for obtaining information about the + * Transport, associated with the calling thread. + */ + class TAO_Transport_Current_Export Current_Impl + : public virtual Current + , public virtual TAO_Local_RefCounted_Object + { + public: + + /// Constructor. + Current_Impl (TAO_ORB_Core* core, size_t tss_slot_id); + + /** + * These are methods exposed by the + * PortableInterceptor::Current interface. + */ + //@{ + virtual CORBA::Long id (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + + virtual CounterT bytes_sent (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + + virtual CounterT bytes_received (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + + virtual CounterT messages_sent (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + + virtual CounterT messages_received (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + + virtual ::TimeBase::TimeT open_since (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + //@} + + protected: + + /** + * Some helper methods + */ + //@{ + /// A (strategy) method used to obtain the transport ptr + const TAO_Transport* transport (ACE_ENV_SINGLE_ARG_DECL) const + ACE_THROW_SPEC ((NoContext)); + + /// A Stats instance. If protocol is unavailable (0) or the + /// TAO_HAS_TRANSPORT_CURRENT macro is defined as anything but + /// 1, a single static instance will be used. + const TAO::Transport::Stats* transport_stats (ACE_ENV_SINGLE_ARG_DECL) const + ACE_THROW_SPEC ((NoContext)); + //@} + + /// Destructor is protected to enforce the fact this class is + /// reference counted, and should not be destroyed using + /// delete() by anything other than the reference counting + /// mechanism. + virtual ~Current_Impl (void); + + private: + + /// Prevent copying through the copy constructor and the + /// assignment operator. + //@{ + Current_Impl (const Current_Impl &); + void operator= (const Current_Impl &); + //@} + + private: + + // The ORB (core) that owes us. + TAO_ORB_Core* core_; + + // The ORB's TSS slot id for the Transport ptr + size_t tss_slot_id_; + + }; + + }; + +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + +/* #if defined (__ACE_INLINE__) */ +/* # include "Current_Impl.inl" */ +/* #endif /\* __ACE_INLINE__ *\/ */ + +#include /**/ "ace/post.h" + +#endif /* CURRENT_IMPL_H */ diff --git a/TAO/tao/TransportCurrent/Current_Loader.cpp b/TAO/tao/TransportCurrent/Current_Loader.cpp new file mode 100644 index 00000000000..04210f9ba21 --- /dev/null +++ b/TAO/tao/TransportCurrent/Current_Loader.cpp @@ -0,0 +1,155 @@ +/* -*- C++ -*- */ + +// ================================================================= +/** + * @file Current_Loader.cpp + * + * $Id$ + * + * @author Iliyan Jeliazkov <iliyan@ociweb.com> + * + */ +// ================================================================= + + +#include "ace/Service_Config.h" + +#include "tao/ORB_Constants.h" +#include "tao/ORBInitializer_Registry.h" + +#include "tao/PI/PI.h" + +#include "tao/TransportCurrent/Current_ORBInitializer.h" +#include "tao/TransportCurrent/Current_Loader.h" +#include "tao/TransportCurrent/Current_Impl.h" + +ACE_RCSID (Transport_Current, + Current_Loader, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace Transport + { + + /// A helper method for obtaining access to the the Transport + /// Factory Manager instance. + + Current_Loader* + Current_Loader::instance (void) + { + Current_Loader *cl = + ACE_Dynamic_Service <Current_Loader>::instance (ACE_TEXT ("TAO_Transport_Current_Loader")); + + if (cl == 0) +#if defined (TAO_AS_STATIC_LIBS) + { + if (TAO_debug_level > 0) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("(%P|%t) Unable to obtain Current::Loader instance: %m\n")), + 0); + return 0; + } +#else + { + // In case we build shared, try to load the appropriate library. + ACE_Service_Config::process_directive + (ACE_DYNAMIC_SERVICE_DIRECTIVE("TAO_Transport_Current_Loader", + "TAO_TC", + "_make_TAO_Transport_Current_Loader", + "")); + cl = ACE_Dynamic_Service<Current_Loader>::instance (ACE_TEXT ("TAO_Transport_Current_Loader")); + } +#endif /* TAO_AS_STATIC_LIBS */ + + if (cl != 0) + return cl; + + if (TAO_debug_level > 0) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("(%P|%t) Unable to obtain Current::Loader instance: %m\n")), + 0); + return 0; + } + + + /// dtor + + Current_Loader::~Current_Loader (void) + { + } + + + + /// Initializes object when dynamic linking occurs. + + int + Current_Loader::init (int, ACE_TCHAR *[]) + { + PortableInterceptor::ORBInitializer_ptr tmp = 0; + ACE_NEW_THROW_EX (tmp, + Current_ORBInitializer<Current_Impl> + (ACE_TEXT ("TAO::Transport::Current")), + CORBA::NO_MEMORY + (CORBA::SystemException::_tao_minor_code (TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_TRY_CHECK; + + PortableInterceptor::ORBInitializer_var initializer (tmp); + + PortableInterceptor::register_orb_initializer (initializer.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + return 0; + } + + } /* namespace Transport */ + +} /* namespace TAO */ + +TAO_END_VERSIONED_NAMESPACE_DECL + + + + + +#if defined (TAO_AS_STATIC_LIBS) + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +ACE_STATIC_SVC_REQUIRE (TAO_Transport_Current_Loader); + +namespace TAO +{ + namespace Transport + { + int current_static_initializer (void) + { + ACE_STATIC_SVC_REGISTER (TAO_Transport_Current_Loader); + return 0; + } + + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* defined (TAO_AS_STATIC_LIBS) */ + + + + +ACE_STATIC_SVC_DEFINE (TAO_Transport_Current_Loader, + ACE_TEXT ("TAO_Transport_Current_Loader"), + ACE_SVC_OBJ_T, + &ACE_SVC_NAME (TAO_Transport_Current_Loader), + ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, + 0) + +ACE_FACTORY_NAMESPACE_DEFINE (TAO_Transport_Current, + TAO_Transport_Current_Loader, + TAO::Transport::Current_Loader) diff --git a/TAO/tao/TransportCurrent/Current_Loader.h b/TAO/tao/TransportCurrent/Current_Loader.h new file mode 100644 index 00000000000..bab40b4f003 --- /dev/null +++ b/TAO/tao/TransportCurrent/Current_Loader.h @@ -0,0 +1,91 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Current_Loader.h + * + * $Id$ + * + * @author Iliyan Jeliazkov <iliyan@ociweb.com> + */ +//============================================================================= + + +#ifndef TAO_TRANSPORT_CURRENT_LOADER_H +#define TAO_TRANSPORT_CURRENT_LOADER_H + +#include /**/ "ace/pre.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Service_Object.h" +#include "tao/Versioned_Namespace.h" +#include "tao/TransportCurrent/Transport_Current_Export.h" + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + class ORBInitializer_Registry_Adapter; + + namespace Transport + { + + class TAO_Transport_Current_Export Current_Loader + : public ACE_Service_Object + { + public: + + /// A helper method for obtaining access to the the Transport + /// Factory Manager instance. + static Current_Loader* instance (void); + + public: + + /// Initializes object when dynamic linking occurs. + virtual int init (int argc, ACE_TCHAR *argv[]); + + protected: + + // Protected destructor to enforce reference counting discipline + virtual ~Current_Loader (void); + + ORBInitializer_Registry_Adapter* orbinitializer_registry (void); + + private: + + /// A cache for the registry pointer + ORBInitializer_Registry_Adapter* oir_; + }; + + }; +}; + + +#if defined (TAO_AS_STATIC_LIBS) +namespace TAO +{ + namespace Transport + { + int current_static_initializer (void); + }; +}; + + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* defined (TAO_AS_STATIC_LIBS) */ + + +ACE_STATIC_SVC_DECLARE_EXPORT (TAO_Transport_Current, + TAO_Transport_Current_Loader) + +ACE_FACTORY_DECLARE (TAO_Transport_Current, + TAO_Transport_Current_Loader) + +#include /**/ "ace/post.h" + +#endif /* TAO_TRANSPORT_CURRENT_LOADER_H */ diff --git a/TAO/tao/TransportCurrent/Current_ORBInitializer.cpp b/TAO/tao/TransportCurrent/Current_ORBInitializer.cpp new file mode 100644 index 00000000000..63c0b0e7c01 --- /dev/null +++ b/TAO/tao/TransportCurrent/Current_ORBInitializer.cpp @@ -0,0 +1,51 @@ +// $Id:$ + +#ifndef CURRENT_ORBINITIALIZER_CPP +#define CURRENT_ORBINITIALIZER_CPP + +#include "tao/ORB_Constants.h" +#include "tao/TransportCurrent/Current_ORBInitializer.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace Transport + { + + template <typename Impl> + Current_ORBInitializer<Impl>::Current_ORBInitializer(const ACE_TCHAR* id) + : Current_ORBInitializer_Base (id) + { + } + + + template <typename Impl> + TAO::Transport::Current_ptr + Current_ORBInitializer<Impl>::make_current_instance (TAO_ORB_Core* core, + size_t tss_slot_id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) + { + // Create the Current + Current_ptr tmp = 0; + ACE_NEW_THROW_EX (tmp, + Impl (core, tss_slot_id), + CORBA::NO_MEMORY + (CORBA::SystemException::_tao_minor_code (TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_CHECK; + + return tmp; + } + + } + +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* CURRENT_ORBINITIALIZER_CPP */ diff --git a/TAO/tao/TransportCurrent/Current_ORBInitializer.h b/TAO/tao/TransportCurrent/Current_ORBInitializer.h new file mode 100644 index 00000000000..8d477c76f46 --- /dev/null +++ b/TAO/tao/TransportCurrent/Current_ORBInitializer.h @@ -0,0 +1,65 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Current_ORBInitializer.h + * + * $Id$ + * + * @author Iliyan Jeliazkov <iliyan@ociweb.com> + */ +//============================================================================= + + +#ifndef CURRENT_ORBINITIALIZER_H +#define CURRENT_ORBINITIALIZER_H + +#include /**/ "ace/pre.h" + +#include "tao/TransportCurrent/Current_ORBInitializer_Base.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace Transport + { + + template <typename Impl> + class TAO_Transport_Current_Export Current_ORBInitializer + //class Current_ORBInitializer + : public Current_ORBInitializer_Base + { + public: + Current_ORBInitializer (const ACE_TCHAR* id); + + + protected: + virtual TAO::Transport::Current_ptr + make_current_instance (TAO_ORB_Core* c, + size_t s + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + }; + + }; +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "tao/TransportCurrent/Current_ORBInitializer.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("tao/TransportCurrent/Current_ORBInitializer.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + + +#include /**/ "ace/post.h" + +#endif /* CURRENT_ORBINITIALIZER_H */ diff --git a/TAO/tao/TransportCurrent/Current_ORBInitializer_Base.cpp b/TAO/tao/TransportCurrent/Current_ORBInitializer_Base.cpp new file mode 100644 index 00000000000..084d6cf6c10 --- /dev/null +++ b/TAO/tao/TransportCurrent/Current_ORBInitializer_Base.cpp @@ -0,0 +1,75 @@ +// $Id$ + +#include "tao/PI/ORBInitInfo.h" +#include "tao/TransportCurrent/Current_ORBInitializer_Base.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace Transport + { + + Current_ORBInitializer_Base::Current_ORBInitializer_Base(const ACE_TCHAR* id) + : id_ (id) + { + } + + Current_ORBInitializer_Base::~Current_ORBInitializer_Base(void) + { + } + + + + void + Current_ORBInitializer_Base::pre_init (PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL_NOT_USED ) + ACE_THROW_SPEC( (CORBA::SystemException) ) + { + // Narrow to a TAO_ORBInitInfo object to get access to the + // allocate_tss_slot_id() TAO extension. + TAO_ORBInitInfo_var tao_info = + TAO_ORBInitInfo::_narrow (info + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (tao_info.in ())) + { + if (TAO_debug_level > 0) + ACE_ERROR ((LM_ERROR, + "TAO (%P|%t) TAO::Transport::ORBInitializer::pre_init - " + "Panic: unable to narrow the ORBInitInfo_ptr\n")); + + ACE_THROW (CORBA::INTERNAL ()); + } + + // Reserve a TSS slot in the ORB core internal TSS resources for the + // thread-specific portion of the Current object. + size_t tss_slot = tao_info->allocate_tss_slot_id (0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Create the Current + Current_var current (this->make_current_instance (tao_info->orb_core (), + tss_slot + ACE_ENV_ARG_PARAMETER)); + + info->register_initial_reference (ACE_TEXT_ALWAYS_CHAR (this->id_.fast_rep ()), + current.in ()); + + } + + void + Current_ORBInitializer_Base::post_init (PortableInterceptor::ORBInitInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED ) + ACE_THROW_SPEC( (CORBA::SystemException) ) + { + } + + } + +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" diff --git a/TAO/tao/TransportCurrent/Current_ORBInitializer_Base.h b/TAO/tao/TransportCurrent/Current_ORBInitializer_Base.h new file mode 100644 index 00000000000..77799dca1f4 --- /dev/null +++ b/TAO/tao/TransportCurrent/Current_ORBInitializer_Base.h @@ -0,0 +1,69 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file Current_ORBInitializer_Base.h + * + * $Id$ + * + * @author Iliyan Jeliazkov <iliyan@ociweb.com> + */ +//============================================================================= + + +#ifndef CURRENT_ORBINITIALIZER_BASE_H +#define CURRENT_ORBINITIALIZER_BASE_H + +#include /**/ "ace/pre.h" + +#include "ace/SString.h" +#include "tao/PI/PI.h" + +#include "tao/TransportCurrent/Transport_Current_Export.h" +#include "tao/TransportCurrent/TCC.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace Transport + { + + class TAO_Transport_Current_Export Current_ORBInitializer_Base : + public PortableInterceptor::ORBInitializer + { + public: + Current_ORBInitializer_Base (const ACE_TCHAR* id); + virtual ~Current_ORBInitializer_Base (void); + + virtual void pre_init (PortableInterceptor::ORBInitInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED ) + ACE_THROW_SPEC( (CORBA::SystemException) ); + + virtual void post_init (PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL_NOT_USED ) + ACE_THROW_SPEC( (CORBA::SystemException) ); + + protected: + virtual TAO::Transport::Current_ptr + make_current_instance (TAO_ORB_Core* core, + size_t tss_slot_id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) = 0; + + protected: + const ACE_TString id_; + }; + + }; +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* CURRENT_ORBINITIALIZER_BASE_H */ diff --git a/TAO/tao/TransportCurrent/IIOP_Current_Impl.cpp b/TAO/tao/TransportCurrent/IIOP_Current_Impl.cpp new file mode 100644 index 00000000000..649cb6258ed --- /dev/null +++ b/TAO/tao/TransportCurrent/IIOP_Current_Impl.cpp @@ -0,0 +1,124 @@ +// $Id$ + +#include "ace/INET_Addr.h" +#include "tao/IIOP_Connection_Handler.h" +#include "tao/IIOP_Transport.h" +#include "tao/Transport_Selection_Guard.h" + +#include "IIOP_Current_Impl.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace Transport + { + + + /// Obtains the IIOP_Connection_Handler associated with the + /// Transport. Will throw NO_IMPLEMENT if the (selected) transport + /// () == 0, or if transport->connection_handler () == 0. Will + /// throw NoContext, if no transport has been selected yet. + + TAO_IIOP_Connection_Handler* + IIOP_Current_Impl::handler (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)) + { + const TAO_Transport* t = this->transport (); + if (t == 0) + ACE_THROW_RETURN (::CORBA::NO_IMPLEMENT (), 0); + + TAO_Connection_Handler *ch = const_cast<TAO_Transport*>(t)->connection_handler (); + if (ch == 0) + ACE_THROW_RETURN (::CORBA::NO_IMPLEMENT (), 0); + + return static_cast <TAO_IIOP_Connection_Handler*> (ch); + } + + + /// Ctor + + IIOP_Current_Impl::IIOP_Current_Impl (TAO_ORB_Core* core, size_t tss_slot_id) + : Current_Impl (core, tss_slot_id) + { + } + + + /// Dtor + + IIOP_Current_Impl::~IIOP_Current_Impl (void) + { + } + + CORBA::Long + IIOP_Current_Impl::id (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)) + { + return this->handler ()->get_handle (); + } + + ::SSLIOP::Current_ptr + IIOP_Current_Impl::ssliop_current (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)) + { + ACE_THROW_RETURN (::CORBA::NO_IMPLEMENT (), 0); + } + + + CORBA::Long + IIOP_Current_Impl::remote_port (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)) + { + TAO_IIOP_Connection_Handler *iiopch = + this->handler (); + + ACE_INET_Addr a; + iiopch->peer ().get_remote_addr (a); + + return a.get_port_number (); + } + + char* + IIOP_Current_Impl::remote_host (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)) + { + TAO_IIOP_Connection_Handler *iiopch = + this->handler (); + + ACE_INET_Addr a; + iiopch->peer ().get_remote_addr (a); + + return CORBA::string_dup (a.get_host_addr ()); + } + + CORBA::Long + IIOP_Current_Impl::local_port (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)) + { + TAO_IIOP_Connection_Handler *iiopch = + this->handler (); + + ACE_INET_Addr a; + iiopch->peer ().get_local_addr (a); + + return a.get_port_number (); + } + + char* + IIOP_Current_Impl::local_host (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)) + { + TAO_IIOP_Connection_Handler *iiopch = + this->handler (); + + ACE_INET_Addr a; + iiopch->peer ().get_local_addr (a); + + return CORBA::string_dup (a.get_host_addr ()); + } + + } +} + + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/TransportCurrent/IIOP_Current_Impl.h b/TAO/tao/TransportCurrent/IIOP_Current_Impl.h new file mode 100644 index 00000000000..9ede80bec9a --- /dev/null +++ b/TAO/tao/TransportCurrent/IIOP_Current_Impl.h @@ -0,0 +1,108 @@ +/** + * @file IIOP_Current_Impl.h + * + * @brief Provide implementation for the IIOPTraits interface + * + * $Id$ + * + * @author Iliyan Jeliazkov <iliyan@ociweb.com> + */ + +#ifndef IIOP_CURRENT_IMPL_H +#define IIOP_CURRENT_IMPL_H + +#include /**/ "ace/pre.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/TransportCurrent/TC_IIOPC.h" +#include "tao/TransportCurrent/Current_Impl.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +class TAO_Transport; +class TAO_IIOP_Connection_Handler; + +namespace TAO +{ + namespace Transport + { + + /** + * @class IIOP_Current_Impl + * + * @brief Implementation of the TAO::Transport::IIOPCurrent + * interface. + * + * IIOP_Current_Impl is useful for obtaining information about the + * IIOP Transport, associated with the calling thread. + */ + class TAO_Transport_Current_Export IIOP_Current_Impl + : public virtual IIOP::Current + , public virtual Current_Impl + { + public: + + /// Constructor. + IIOP_Current_Impl (TAO_ORB_Core* core, size_t tss_slot_id); + + //@{ + virtual ::CORBA::Long id (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + + virtual ::SSLIOP::Current_ptr ssliop_current (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + + virtual ::CORBA::Long remote_port (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + + virtual char* remote_host (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + + virtual ::CORBA::Long local_port (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + + virtual char* local_host (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + //@} + + + protected: + + /// Destructor + /** + * Protected destructor to enforce the fact this class is reference + * counted, and should not be destroyed using delete() by anything + * other than the reference counting mechanism. + */ + virtual ~IIOP_Current_Impl (void); + + private: + + /// Returns the IIOP connection handler associated with the + /// Transport. Will throw NO_IMPLEMENT if the (selected) transport + /// () == 0, or if transport->connection_handler () == 0. Will + /// throw NoContext, if no transport has been selected yet. + TAO_IIOP_Connection_Handler* handler (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)); + + private: + + /// Prevent copying through the copy constructor and + /// assignment operator. + //@{ + IIOP_Current_Impl (const IIOP_Current_Impl &); + void operator= (const IIOP_Current_Impl &); + //@} + + }; + }; +}; + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* IIOP_CURRENT_IMPL_H */ diff --git a/TAO/tao/TransportCurrent/IIOP_Current_Loader.cpp b/TAO/tao/TransportCurrent/IIOP_Current_Loader.cpp new file mode 100644 index 00000000000..b17da2f1a57 --- /dev/null +++ b/TAO/tao/TransportCurrent/IIOP_Current_Loader.cpp @@ -0,0 +1,95 @@ +/* -*- C++ -*- */ + +// ================================================================= +/** + * @file IIOP_Current_Loader.cpp + * + * $Id$ + * + * @author Iliyan Jeliazkov <iliyan@ociweb.com> + * + */ +// ================================================================= + + +#include "ace/Service_Config.h" + +#include "tao/ORBInitializer_Registry.h" +#include "tao/ORB_Constants.h" + +#include "tao/PI/PI.h" + +#include "tao/TransportCurrent/Current_ORBInitializer.h" +#include "tao/TransportCurrent/IIOP_Current_Loader.h" +#include "tao/TransportCurrent/IIOP_Current_Impl.h" + +ACE_RCSID (Transport_Current, + IIOP_Current_Loader, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + namespace Transport + { + namespace IIOP + { + /// Initializes object when dynamic linking occurs. + int + Current_Loader::init (int, ACE_TCHAR *[]) + { + PortableInterceptor::ORBInitializer_ptr tmp = 0; + ACE_NEW_THROW_EX (tmp, + Current_ORBInitializer<IIOP_Current_Impl> (ACE_TEXT ("TAO::Transport::IIOP::Current")), + CORBA::NO_MEMORY (CORBA::SystemException::_tao_minor_code (TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + ACE_TRY_CHECK; + + PortableInterceptor::ORBInitializer_var initializer (tmp); + + PortableInterceptor::register_orb_initializer (initializer.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + return 0; + } + } + + } +} + + +#if defined (TAO_AS_STATIC_LIBS) +ACE_STATIC_SVC_REQUIRE (TAO_Transport_IIOP_Current_Loader); + +namespace TAO +{ + namespace Transport + { + namespace IIOP + { + int current_static_initializer (void) + { + ACE_STATIC_SVC_REGISTER (TAO_Transport_IIOP_Current_Loader); + return 0; + } + } + } +} +#endif /* defined (TAO_AS_STATIC_LIBS) */ + + +TAO_END_VERSIONED_NAMESPACE_DECL + +ACE_STATIC_SVC_DEFINE (TAO_Transport_IIOP_Current_Loader, + ACE_TEXT ("TAO_Transport_IIOP_Current_Loader"), + ACE_SVC_OBJ_T, + &ACE_SVC_NAME (TAO_Transport_IIOP_Current_Loader), + ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, + 0) + +ACE_FACTORY_NAMESPACE_DEFINE (TAO_Transport_Current, + TAO_Transport_IIOP_Current_Loader, + TAO::Transport::IIOP::Current_Loader) diff --git a/TAO/tao/TransportCurrent/IIOP_Current_Loader.h b/TAO/tao/TransportCurrent/IIOP_Current_Loader.h new file mode 100644 index 00000000000..7f49533fa03 --- /dev/null +++ b/TAO/tao/TransportCurrent/IIOP_Current_Loader.h @@ -0,0 +1,68 @@ +/* -*- C++ -*- */ + +//============================================================================= +/** + * @file IIOP_Current_Loader.h + * + * $Id$ + * + * @author Iliyan Jeliazkov <iliyan@ociweb.com> + */ +//============================================================================= + +#ifndef TAO_TRANSPORT_IIOP_TRAITS_LOADER_H +#define TAO_TRANSPORT_IIOP_TRAITS_LOADER_H + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/TransportCurrent/Current_Loader.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + + namespace Transport + { + + namespace IIOP + { + class TAO_Transport_Current_Export Current_Loader + : public TAO::Transport::Current_Loader + { + public: + /// Initializes object when dynamic linking occurs. + virtual int init (int argc, ACE_TCHAR *argv[]); + }; + } + } +} + + + +#if defined (TAO_AS_STATIC_LIBS) +namespace TAO +{ + namespace Transport + { + namespace IIOP + { + int current_static_initializer (void); + } + } +} + +#endif /* defined (TAO_AS_STATIC_LIBS) */ + + +TAO_END_VERSIONED_NAMESPACE_DECL + +ACE_STATIC_SVC_DECLARE_EXPORT (TAO_Transport_Current, + TAO_Transport_IIOP_Current_Loader) + +ACE_FACTORY_DECLARE (TAO_Transport_Current, + TAO_Transport_IIOP_Current_Loader) + +#endif /* TAO_TRANSPORT_IIOP_TRAITS_LOADER_H */ diff --git a/TAO/tao/TransportCurrent/IIOP_Transport_Current.h b/TAO/tao/TransportCurrent/IIOP_Transport_Current.h new file mode 100644 index 00000000000..9a59cc00f27 --- /dev/null +++ b/TAO/tao/TransportCurrent/IIOP_Transport_Current.h @@ -0,0 +1,17 @@ +// -*- C++ -*- +// $Id$ + + +#include "tao/TransportCurrent/TCC.h" +#include "tao/TransportCurrent/TC_IIOPC.h" +#include "tao/TransportCurrent/IIOP_Current_Loader.h" + +#if defined (TAO_AS_STATIC_LIBS) + +// Only do this for static builds. It causes a circular dependency for +// dynamic builds. +static int tao_iiop_transport_current_initializer_called = + TAO::Transport::IIOP::current_static_initializer (); + +#endif /* TAO_AS_STATIC_LIBS */ + diff --git a/TAO/tao/TransportCurrent/TC.idl b/TAO/tao/TransportCurrent/TC.idl new file mode 100644 index 00000000000..6f6b5684790 --- /dev/null +++ b/TAO/tao/TransportCurrent/TC.idl @@ -0,0 +1,57 @@ +/** + * @file TC.idl + * + * @brief Defines the TAO::Transport::Current interface + * + * $Id$ + * + * @author Iliyan Jeliazkov <iliyan@ociweb.com> + */ + +#ifndef TAO_TRANSPORT_CURRENT_IDL +#define TAO_TRANSPORT_CURRENT_IDL + +#include <IOP.pidl> +#include <TimeBase.pidl> + +module TAO +{ + /// A type used to represent counters + typedef unsigned long long CounterT; + + module Transport + { + /// Used to signal that a call was made within improper invocation + /// context. Also, this exception is thrown if no Transport has + /// been selected for the current thread, for example in a + /// collocated invocation. + + exception NoContext + { + }; + + // The primary interface, providing access to Transport + // information, available to the current thread. + + local interface Current + { + /// Transport ID, unique within the process. + readonly attribute long id raises (NoContext); + + /// Bytes sent/received through the transport. + readonly attribute CounterT bytes_sent raises (NoContext); + readonly attribute CounterT bytes_received raises (NoContext); + + /// Messages (requests and replies) sent/received using the current + /// protocol. + readonly attribute CounterT messages_sent raises (NoContext); + readonly attribute CounterT messages_received raises (NoContext); + + /// The absolute time (miliseconds) since the transport has been + /// open. + readonly attribute TimeBase::TimeT open_since raises (NoContext); + }; + }; +}; + +#endif /* TAO_TRANSPORT_CURRENT_IDL */ diff --git a/TAO/tao/TransportCurrent/TC.mpc b/TAO/tao/TransportCurrent/TC.mpc new file mode 100644 index 00000000000..95a392e060b --- /dev/null +++ b/TAO/tao/TransportCurrent/TC.mpc @@ -0,0 +1,33 @@ +//$Id:$ + +project(*) : taolib_with_idl, tao_versioning_idl_defaults, core, interceptors, pi { + + sharedname = TAO_TC + dynamicflags = TAO_TRANSPORT_CURRENT_BUILD_DLL + + Source_Files { + Current_Impl.cpp + Current_Loader.cpp + Current_ORBInitializer_Base.cpp + } + + Header_Files { + Current_Impl.h + Current_Loader.h + Current_ORBInitializer.h + Current_ORBInitializer_Base.h + Transport_Current.h + } + + Template_Files { + Current_ORBInitializer.cpp + } + + idlflags += -Wb,export_include=tao/TransportCurrent/Transport_Current_Export.h + idlflags += -Wb,export_macro=TAO_Transport_Current_Export + + IDL_Files { + TC.idl + } +} + diff --git a/TAO/tao/TransportCurrent/TC_IIOP.idl b/TAO/tao/TransportCurrent/TC_IIOP.idl new file mode 100644 index 00000000000..17c87602d0a --- /dev/null +++ b/TAO/tao/TransportCurrent/TC_IIOP.idl @@ -0,0 +1,56 @@ +/** + * @file TC_IIOP.idl + * + * @brief Defines the TAO::Transport::IIOP::Current interface + * + * $Id:$ + * + * @author Iliyan Jeliazkov <iliyan@ociweb.com> + */ + +#ifndef TAO_TRANSPORT_IIOP_CURRENT_IDL +#define TAO_TRANSPORT_IIOP_CURRENT_IDL + +#include "TC.idl" + +/// Provide a forward reference for the SSLIOP::Current +module SSLIOP +{ + interface Current; +}; + + +module TAO +{ + module Transport + { + module IIOP + { + // The primary interface, providing access to IIOP-specific + // transport information, if it is indeed an IIOP (-like) transport + // that has been selected. + + local interface Current : TAO::Transport::Current + { + /// Remote host + readonly attribute string remote_host raises (NoContext); + + /// Remote port Using long (signed) type to better accomodate + /// the Java mapping, which has no support for unsigned values + readonly attribute long remote_port raises (NoContext); + + /// Local host + readonly attribute string local_host raises (NoContext); + + /// Local port + readonly attribute long local_port raises (NoContext); + + /// If this is a "secure" transport, this method will give you + /// the corresponding SSLIOP::Current + readonly attribute ::SSLIOP::Current ssliop_current raises (NoContext); + }; + }; + }; +}; + +#endif /* TAO_TRANSPORT_IIOP_CURRENT_IDL */ diff --git a/TAO/tao/TransportCurrent/TC_IIOP.mpc b/TAO/tao/TransportCurrent/TC_IIOP.mpc new file mode 100644 index 00000000000..1f28ceb549a --- /dev/null +++ b/TAO/tao/TransportCurrent/TC_IIOP.mpc @@ -0,0 +1,27 @@ +//$Id:$ + +project(*) : taolib_with_idl, tao_versioning_idl_defaults, core, interceptors, pi, tc { + + sharedname = TAO_TC_IIOP + + dynamicflags = TAO_TRANSPORT_CURRENT_BUILD_DLL + libs += TAO_TC + + Source_Files { + IIOP_Current_Impl.cpp + IIOP_Current_Loader.cpp + } + + Header_Files { + IIOP_Current_Impl.h + IIOP_Current_Loader.h + IIOP_Transport_Current.h + } + + idlflags += -Wb,export_include=tao/TransportCurrent/Transport_Current_Export.h + idlflags += -Wb,export_macro=TAO_Transport_Current_Export + + IDL_Files { + TC_IIOP.idl + } +} diff --git a/TAO/tao/TransportCurrent/Transport_Current.h b/TAO/tao/TransportCurrent/Transport_Current.h new file mode 100644 index 00000000000..2d776e8d6b6 --- /dev/null +++ b/TAO/tao/TransportCurrent/Transport_Current.h @@ -0,0 +1,16 @@ +// -*- C++ -*- +// $Id$ + + +#include "tao/TransportCurrent/TCC.h" +#include "tao/TransportCurrent/Current_Loader.h" + +#if defined (TAO_AS_STATIC_LIBS) + +// Only do this for static builds. It causes a circular dependency for +// dynamic builds. +static int tao_transport_current_initializer_called = + TAO::Transport::current_static_initializer (); + +#endif /* TAO_AS_STATIC_LIBS */ + diff --git a/TAO/tao/TransportCurrent/Transport_Current_Export.h b/TAO/tao/TransportCurrent/Transport_Current_Export.h new file mode 100644 index 00000000000..ce01b4dc2f1 --- /dev/null +++ b/TAO/tao/TransportCurrent/Transport_Current_Export.h @@ -0,0 +1,54 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl -d TAO_Transport_Current +// ------------------------------ +#ifndef TAO_TRANSPORT_CURRENT_EXPORT_H +#define TAO_TRANSPORT_CURRENT_EXPORT_H + +#include "ace/config-all.h" + +#if !defined (TAO_TRANSPORT_CURRENT_HAS_DLL) +# define TAO_TRANSPORT_CURRENT_HAS_DLL 1 +#endif /* ! TAO_TRANSPORT_CURRENT_HAS_DLL */ + +#if defined (TAO_TRANSPORT_CURRENT_HAS_DLL) && (TAO_TRANSPORT_CURRENT_HAS_DLL == 1) +# if defined (TAO_TRANSPORT_CURRENT_BUILD_DLL) +# define TAO_Transport_Current_Export ACE_Proper_Export_Flag +# define TAO_TRANSPORT_CURRENT_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define TAO_TRANSPORT_CURRENT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* TAO_TRANSPORT_CURRENT_BUILD_DLL */ +# define TAO_Transport_Current_Export ACE_Proper_Import_Flag +# define TAO_TRANSPORT_CURRENT_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define TAO_TRANSPORT_CURRENT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* TAO_TRANSPORT_CURRENT_BUILD_DLL */ +#else /* TAO_TRANSPORT_CURRENT_HAS_DLL == 1 */ +# define TAO_Transport_Current_Export +# define TAO_TRANSPORT_CURRENT_SINGLETON_DECLARATION(T) +# define TAO_TRANSPORT_CURRENT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* TAO_TRANSPORT_CURRENT_HAS_DLL == 1 */ + +// Set TAO_TRANSPORT_CURRENT_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (TAO_TRANSPORT_CURRENT_NTRACE) +# if (ACE_NTRACE == 1) +# define TAO_TRANSPORT_CURRENT_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define TAO_TRANSPORT_CURRENT_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !TAO_TRANSPORT_CURRENT_NTRACE */ + +#if (TAO_TRANSPORT_CURRENT_NTRACE == 1) +# define TAO_TRANSPORT_CURRENT_TRACE(X) +#else /* (TAO_TRANSPORT_CURRENT_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define TAO_TRANSPORT_CURRENT_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (TAO_TRANSPORT_CURRENT_NTRACE == 1) */ + +#endif /* TAO_TRANSPORT_CURRENT_EXPORT_H */ + +// End of auto generated file. diff --git a/TAO/tao/Transport_Selection_Guard.cpp b/TAO/tao/Transport_Selection_Guard.cpp new file mode 100644 index 00000000000..bd1164131df --- /dev/null +++ b/TAO/tao/Transport_Selection_Guard.cpp @@ -0,0 +1,81 @@ +// $Id$ + +#include "tao/Transport_Selection_Guard.h" +#include "tao/TSS_Resources.h" + +ACE_RCSID (tao, + Transport_Selection_Guard.cpp, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + + Transport_Selection_Guard* + Transport_Selection_Guard::current (TAO_ORB_Core* core, size_t tss_slot_id) + { + // @NOTE: (Iliyan) Started making this method aware of the core + // and the tss slot that correspond to the "current" transport, + // influenced by a general design preference to keep things + // local. The idea was to make the current TSG part of the TSS + // storage for a specific ORB Core, as opposed to using the global + // TSS Resources. However, it really doesn't offer any benefit to + // store a Transport pointer locally, for each ORB. There is + // always only one current Transport per thread. Period. The + // number of ORB Core instances in existence does not change that + // fact, so keeping a separate pointer would have been an + // over-kill. + ACE_UNUSED_ARG (core); + ACE_UNUSED_ARG (tss_slot_id); + +#if TAO_HAS_TRANSPORT_CURRENT == 1 + + return TAO_TSS_Resources::instance ()->tsg_; + +#else /* TAO_HAS_TRANSPORT_CURRENT != 1 */ + + return 0; + +#endif /* TAO_HAS_TRANSPORT_CURRENT == 1 */ + }; + + + + /// Ctor + Transport_Selection_Guard::Transport_Selection_Guard (TAO_Transport* t) + : +#if TAO_HAS_TRANSPORT_CURRENT == 1 + + prev_ (TAO_TSS_Resources::instance ()->tsg_) + , + +#endif /* TAO_HAS_TRANSPORT_CURRENT == 1 */ + curr_ (t) + { +#if TAO_HAS_TRANSPORT_CURRENT == 1 + + TAO_TSS_Resources::instance ()->tsg_ = this; + +#endif /* TAO_HAS_TRANSPORT_CURRENT == 1 */ + + }; + + + + /// Dtor + Transport_Selection_Guard::~Transport_Selection_Guard (void) + { + +#if TAO_HAS_TRANSPORT_CURRENT == 1 + + TAO_TSS_Resources::instance ()->tsg_ = prev_; + this->prev_ = 0; + +#endif /* TAO_HAS_TRANSPORT_CURRENT == 1 */ + this->curr_ = 0; + }; + +} /* namespace TAO */ + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/Transport_Selection_Guard.h b/TAO/tao/Transport_Selection_Guard.h new file mode 100644 index 00000000000..96f3deac271 --- /dev/null +++ b/TAO/tao/Transport_Selection_Guard.h @@ -0,0 +1,125 @@ +// -*- C++ -*- + +// =================================================================== +/** + * @file Transport_Selection_Guard.h + * + * $Id$ + * + * @author Iliyan Jeliazkov <iliyan@ociweb.com> + */ +// =================================================================== + +#ifndef TAO_TRANSPORT_SELECTION_GUARD_H +#define TAO_TRANSPORT_SELECTION_GUARD_H + +#include /**/ "ace/pre.h" + +#include "tao/TAO_Export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/Environment.h" + +/* #include "tao/Policy_Current_Impl.h" */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +// Forward declarations +class TAO_Transport; + +namespace TAO +{ + /** + * @class Transport_Selection_Guard + * + * @brief Used by the Transport Current feature to keep track of + * which Transport is currently active. + * + * Whenever a Transport is selected: during an upcall, or prior to a + * client invocation an instance of this class is created [on the + * stack, or as a member of another class] to keep track of the said + * Transport. The class implements the RAII idiom, which makes it + * possible to build a stack of these instances as the thread is + * doing nested upcalls or client invocations. + * + * It utilizes TAO_TSS_Resources::tsg_ member pointer to keep track + * of stack-linked Transport_Selection_Guard instances. + * + * If the Transport Current feature is disabled most methods are + * no-ops and add no overhead on the critical path. + * + * <B>See Also:</B> + * + * https://svn.dre.vanderbilt.edu/viewvc/Middleware/trunk/TAO/docs/transport_current/index.html?revision=HEAD + * + */ + class TAO_Export Transport_Selection_Guard + { + public: + + static Transport_Selection_Guard* current (TAO_ORB_Core* core, + size_t tss_slot_id); + + public: + + /// Ctor + Transport_Selection_Guard (TAO_Transport* t); + + /// Dtor + ~Transport_Selection_Guard (void); + + /// getter + TAO_Transport* operator-> (void) const + { + return this->get (); + }; + + /// getter + TAO_Transport& operator* (void) const + { + return *this->get (); + }; + + /// Getter + TAO_Transport* get (void) const + { + return this->curr_; + }; + + /// Setter + Transport_Selection_Guard& set (TAO_Transport* t) + { + this->curr_ = t; + return *this; + }; + + private: + ACE_UNIMPLEMENTED_FUNC (Transport_Selection_Guard (const Transport_Selection_Guard&)) + ACE_UNIMPLEMENTED_FUNC (Transport_Selection_Guard& operator=(const Transport_Selection_Guard&)) + +#if TAO_HAS_TRANSPORT_CURRENT == 1 + + /// This is pointing to the guard that was active prior to + /// instantiating us. + + Transport_Selection_Guard* prev_; + +#endif /* TAO_HAS_TRANSPORT_CURRENT == 1 */ + + /// The "real" Transport, i.e. the one selected at present + TAO_Transport* curr_; + }; + +} /* namespace TAO */ + + + + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* TAO_TRANSPORT_SELECTION_GUARD_H */ diff --git a/TAO/tao/orbconf.h b/TAO/tao/orbconf.h index 541e08b56fd..69404326b05 100644 --- a/TAO/tao/orbconf.h +++ b/TAO/tao/orbconf.h @@ -839,6 +839,12 @@ enum TAO_Policy_Scope # define TAO_USE_OUTPUT_CDR_MMAP_MEMORY_POOL 0 #endif /* TAO_USE_LOCAL_MEMORY_POOL */ +// Enable TransportCurrent by default +#if !defined (TAO_HAS_TRANSPORT_CURRENT) +# define TAO_HAS_TRANSPORT_CURRENT 1 +# else +# define TAO_HAS_TRANSPORT_CURRENT 0 +#endif /* ! TAO_HAS_TRANSPORT_CURRENT */ TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/tao.mpc b/TAO/tao/tao.mpc index e504d5b7490..ac16584db90 100644 --- a/TAO/tao/tao.mpc +++ b/TAO/tao/tao.mpc @@ -222,6 +222,7 @@ project(TAO) : acelib, core, tao_output, taodefaults, pidl, extra_core, tao_vers Transport_Descriptor_Interface.cpp Transport_Mux_Strategy.cpp Transport_Queueing_Strategies.cpp + Transport_Selection_Guard.cpp Transport_Timer.cpp TSS_Resources.cpp TypeCodeFactory_Adapter.cpp @@ -529,6 +530,7 @@ project(TAO) : acelib, core, tao_output, taodefaults, pidl, extra_core, tao_vers Transport.h Transport_Mux_Strategy.h Transport_Queueing_Strategies.h + Transport_Selection_Guard.h Transport_Timer.h TSS_Resources.h TypeCodeFactory_Adapter.h |