diff options
author | bala <balanatarajan@users.noreply.github.com> | 2000-10-18 10:58:47 +0000 |
---|---|---|
committer | bala <balanatarajan@users.noreply.github.com> | 2000-10-18 10:58:47 +0000 |
commit | c17bf901bf10addff286b33398a24536442dad6f (patch) | |
tree | bf2b55b90b242e0011fd3876ef90716af2559899 | |
parent | d366675850fa5ebf2cac96e7edd8ac5812c7ea90 (diff) | |
download | ATCD-c17bf901bf10addff286b33398a24536442dad6f.tar.gz |
*** empty log message ***
-rw-r--r-- | TAO/tao/Connection_Handler.cpp | 175 | ||||
-rw-r--r-- | TAO/tao/Connection_Handler.h | 121 | ||||
-rw-r--r-- | TAO/tao/Connection_Handler.i | 21 | ||||
-rw-r--r-- | TAO/tao/Endpoint.h | 2 | ||||
-rw-r--r-- | TAO/tao/IIOP_Connect.cpp | 185 | ||||
-rw-r--r-- | TAO/tao/IIOP_Connect.h | 33 | ||||
-rw-r--r-- | TAO/tao/SHMIOP_Connect.cpp | 204 | ||||
-rw-r--r-- | TAO/tao/SHMIOP_Connect.h | 32 | ||||
-rw-r--r-- | TAO/tao/TAO.dsp | 27 |
9 files changed, 440 insertions, 360 deletions
diff --git a/TAO/tao/Connection_Handler.cpp b/TAO/tao/Connection_Handler.cpp new file mode 100644 index 00000000000..7aa55d352e1 --- /dev/null +++ b/TAO/tao/Connection_Handler.cpp @@ -0,0 +1,175 @@ +//$Id$ +#include "tao/Connection_Handler.h" +#include "tao/ORB_Core.h" +#include "tao/Server_Strategy_Factory.h" +#include "tao/debug.h" +#include "tao/Object.h" +#include "tao/Messaging_Policy_i.h" + +#if !defined (__ACE_INLINE__) +#include "tao/Connection_Handler.i" +#endif /* __ACE_INLINE__ */ + +TAO_Connection_Handler::TAO_Connection_Handler (TAO_ORB_Core *orb_core) + :orb_core_ (orb_core), + tss_resources_ (orb_core->get_tss_resources ()) +{ +} + + +TAO_Connection_Handler::~TAO_Connection_Handler (void) +{ +} + + +void +TAO_Connection_Handler::remove_handle (ACE_HANDLE handle) +{ + TAO_Server_Strategy_Factory *f = + this->orb_core_->server_factory (); + + if (f->activate_server_connections () == 0) + (void) this->orb_core_->remove_handle (handle); +} + + +int +TAO_Connection_Handler::set_socket_option (ACE_SOCK &sock, + int snd_size, + int rcv_size) +{ +#if !defined (ACE_LACKS_SOCKET_BUFSIZ) + + if (sock.set_option (SOL_SOCKET, + SO_SNDBUF, + (void *) &snd_size, + sizeof (snd_size)) == -1 + && errno != ENOTSUP) + return -1; + else if (sock.set_option (SOL_SOCKET, + SO_RCVBUF, + (void *) &rcv_size, + sizeof (int)) == -1 + && errno != ENOTSUP) + return -1; +#endif /* !ACE_LACKS_SOCKET_BUFSIZ */ + + (void) sock.enable (ACE_CLOEXEC); + // Set the close-on-exec flag for that file descriptor. If the + // operation fails we are out of luck (some platforms do not support + // it and return -1). + + return 0; +} + +int +TAO_Connection_Handler::svc_i (void) +{ + int result = 0; + + // Inheriting the ORB_Core tss stuff from the parent thread. + this->orb_core_->inherit_from_parent_thread (this->tss_resources_); + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) TAO_Connection_Handler::svc_i begin\n"))); + + // Here we simply synthesize the "typical" event loop one might find + // in a reactive handler, except that this can simply block waiting + // for input. + + ACE_Time_Value *max_wait_time = 0; + ACE_Time_Value timeout; + ACE_Time_Value current_timeout; + + if (this->orb_core_->thread_per_connection_timeout (timeout)) + { + current_timeout = timeout; + max_wait_time = ¤t_timeout; + } + + while (!this->orb_core_->has_shutdown () + && result >= 0) + { + result = this->handle_input_i (ACE_INVALID_HANDLE, max_wait_time); + + if (result == -1 && errno == ETIME) + { + // Ignore timeouts, they are only used to wake up and + // shutdown. + result = 0; + + // Reset errno to make sure we don't trip over an old value + // of errno in case it is not reset when the recv() call + // fails if the socket has been closed. + errno = 0; + } + + current_timeout = timeout; + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) TAO_Connection_Handler::svc_i - ") + ACE_TEXT ("loop <%d>\n"), current_timeout.msec ())); + } + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) TAO_Connection_Handler::svc_i end\n"))); + + return result; +} + +ACE_Time_Value * +TAO_Connection_Handler::handle_timeout_i (const ACE_Time_Value &, + const void *) +{ + // + // This method is called when buffering timer expires. + // + + ACE_Time_Value *max_wait_time = 0; + +#if (TAO_HAS_RELATIVE_ROUNDTRIP_TIMEOUT_POLICY == 1) + + TAO_RelativeRoundtripTimeoutPolicy *timeout_policy = + this->orb_core_->stubless_relative_roundtrip_timeout (); + + // Automatically release the policy + CORBA::Object_var auto_release = timeout_policy; + + ACE_Time_Value max_wait_time_value; + + // If max_wait_time is not zero then this is not the first attempt + // to send the request, the timeout value includes *all* those + // attempts. + if (timeout_policy != 0) + { + timeout_policy->set_time_value (max_wait_time_value); + max_wait_time = &max_wait_time_value; + } +#endif /* TAO_HAS_RELATIVE_ROUNDTRIP_TIMEOUT_POLICY == 1 */ + + return max_wait_time; +} + + +int +TAO_Connection_Handler::handle_cleanup_i (ACE_Reactor *reactor, + ACE_Event_Handler *event) +{ + // Deregister this handler with the ACE_Reactor. + if (reactor) + { + ACE_Reactor_Mask mask = + ACE_Event_Handler::ALL_EVENTS_MASK | ACE_Event_Handler::DONT_CALL; + + // Make sure there are no timers. + reactor->cancel_timer (event); + + // Remove self from reactor. + reactor->remove_handler (event, mask); + } + + return 0; +} diff --git a/TAO/tao/Connection_Handler.h b/TAO/tao/Connection_Handler.h new file mode 100644 index 00000000000..78d452a0e5e --- /dev/null +++ b/TAO/tao/Connection_Handler.h @@ -0,0 +1,121 @@ +/* -*- C++ -*- */ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// tao +// +// = FILENAME +// Connection_Handler.h +// +// = AUTHOR +// Bala Natarajan <bala@cs.wustl.edu> +// +// ============================================================================ + +#ifndef TAO_CONNECTION_HANDLER_H +#define TAO_CONNECTION_HANDLER_H +#include "ace/pre.h" + +#include "ace/SOCK.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +class TAO_ORB_Core; +class TAO_ORB_Core_TSS_Resources; +class ACE_Reactor; +class ACE_Event_Handler; + +class TAO_Connection_Handler +{ + // = TITLE + // TAO_Connection_Handler + // + // = DESCRIPTION + // This class is an abstraction for the connection handlers. The + // connections handler in every protocol can derive from this + // class as well as the ACE_Svc_Handler specialised for the + // right protocol. This way, most of the common code for the + // different protocls would be in this implementation. Further, + // this class wold be of immense use in storing the handlers in + // the Cache for TAO. This would help in purging entries which + // is generally accompanied by closing the open handles and + // deleting memory associated with the handlers. + + // Note: This class has NOT abstracted the GIOP specific + // details. It is just to be safe so that, we can reuse this + // class for any messaging protocol underneath. This way we need + // not touch the Cache setup even when using other protocols (I + // mean messaging). BUT, I doubt whether this abstraction will + // satisfy the needs of other messaging protocols. (will not?). + +public: + + TAO_Connection_Handler (void); + // Constructor + + TAO_Connection_Handler (TAO_ORB_Core *orb_core); + // Constructor + + virtual ~TAO_Connection_Handler (void); + // Destructor + +protected: + + void remove_handle (ACE_HANDLE handle); + // Remove the handle from the ORB Core's handle set so that it + // isn't included in the set that is passed to the reactor upon + // ORB destruction. + + TAO_ORB_Core *orb_core (void); + // Return our TAO_ORB_Core pointer + + TAO_ORB_Core_TSS_Resources* tss_resources (void); + // Return our TSS Resources pointer + + int set_socket_option (ACE_SOCK &sock, + int snd_size, + int rcv_size); + // Set options on the socket + + int svc_i (void); + // This method is invoked from the svc () method of the Svc_Handler + // Object. + + virtual int handle_input_i (ACE_HANDLE = ACE_INVALID_HANDLE, + ACE_Time_Value *max_wait_time = 0) = 0; + // Need to be implemented by the underlying protocol + + ACE_Time_Value *handle_timeout_i (const ACE_Time_Value &, + const void *); + // Implementation of the method handle_timout () which would be + // called when the buffering timer expires. + + int handle_cleanup_i (ACE_Reactor *reactor, + ACE_Event_Handler *handler); + // Implementation of the call handle_cleanup () in + // Service_Handler. + +private: + TAO_ORB_Core *orb_core_; + // Pointer to the TAO_ORB_Core + + TAO_ORB_Core_TSS_Resources *tss_resources_; + // Cached tss resources of the ORB that activated this object. +}; + +#if defined (__ACE_INLINE__) +#include "tao/Connection_Handler.i" +#endif /* __ACE_INLINE__ */ + +#endif /*TAO_CONNECTION_HANDLER_H*/ diff --git a/TAO/tao/Connection_Handler.i b/TAO/tao/Connection_Handler.i new file mode 100644 index 00000000000..7c3cf4ab5df --- /dev/null +++ b/TAO/tao/Connection_Handler.i @@ -0,0 +1,21 @@ +//* -*- C++ -*- */ +//$Id$ + +ACE_INLINE +TAO_Connection_Handler::TAO_Connection_Handler (void) + : orb_core_ (0), + tss_resources_ (0) +{ +} + +ACE_INLINE TAO_ORB_Core * +TAO_Connection_Handler::orb_core (void) +{ + return this->orb_core_; +} + +ACE_INLINE TAO_ORB_Core_TSS_Resources * +TAO_Connection_Handler::tss_resources (void) +{ + return this->tss_resources_; +} diff --git a/TAO/tao/Endpoint.h b/TAO/tao/Endpoint.h index 69069712c95..c6c575cf4fb 100644 --- a/TAO/tao/Endpoint.h +++ b/TAO/tao/Endpoint.h @@ -75,7 +75,7 @@ public: // This method is used when a connection has been reset, requiring // the hint to be cleaned up and reset to NULL. - virtual TAO_Endpoint *duplicate (void) = 0; + //virtual TAO_Endpoint *duplicate (void) = 0; // This method returns a copy of the corresponding endpoints by // allocation memory diff --git a/TAO/tao/IIOP_Connect.cpp b/TAO/tao/IIOP_Connect.cpp index 596d95c4df3..ec632e7e409 100644 --- a/TAO/tao/IIOP_Connect.cpp +++ b/TAO/tao/IIOP_Connect.cpp @@ -67,12 +67,10 @@ TAO_IIOP_Handler_Base::TAO_IIOP_Handler_Base (ACE_Thread_Manager *t) TAO_IIOP_Server_Connection_Handler::TAO_IIOP_Server_Connection_Handler (ACE_Thread_Manager *t) : TAO_IIOP_Handler_Base (t), + TAO_Connection_Handler (0), transport_ (this, 0), acceptor_factory_ (0), - orb_core_ (0), - tss_resources_ (0), refcount_ (1), - lite_flag_ (0), tcp_properties_ (0) { // This constructor should *never* get called, it is just here to @@ -80,23 +78,21 @@ TAO_IIOP_Server_Connection_Handler::TAO_IIOP_Server_Connection_Handler (ACE_Thre // Creation_Strategy requires a constructor with that signature, we // don't use that implementation, but some (most?) compilers // instantiate it anyway. - ACE_ASSERT (this->orb_core_ != 0); + ACE_ASSERT (this->orb_core () != 0); } TAO_IIOP_Server_Connection_Handler::TAO_IIOP_Server_Connection_Handler (TAO_ORB_Core *orb_core, CORBA::Boolean flag, void *arg) : TAO_IIOP_Handler_Base (orb_core), + TAO_Connection_Handler (orb_core), transport_ (this, orb_core), acceptor_factory_ (0), - orb_core_ (orb_core), - tss_resources_ (orb_core->get_tss_resources ()), refcount_ (1), - lite_flag_ (flag), tcp_properties_ (ACE_static_cast (TAO_IIOP_Handler_Base::TCP_Properties *, arg)) { - if (lite_flag_) + if (flag) { ACE_NEW (this->acceptor_factory_, TAO_GIOP_Message_Lite (orb_core)); @@ -116,21 +112,10 @@ TAO_IIOP_Server_Connection_Handler::~TAO_IIOP_Server_Connection_Handler (void) int TAO_IIOP_Server_Connection_Handler::open (void*) { -#if !defined (ACE_LACKS_SOCKET_BUFSIZ) - - if (this->peer ().set_option (SOL_SOCKET, - SO_SNDBUF, - (void *) &tcp_properties_->send_buffer_size, - sizeof (int)) == -1 - && errno != ENOTSUP) - return -1; - else if (this->peer ().set_option (SOL_SOCKET, - SO_RCVBUF, - (void *) &tcp_properties_->recv_buffer_size, - sizeof (int)) == -1 - && errno != ENOTSUP) + if (this->set_socket_option (this->peer (), + this->tcp_properties_->send_buffer_size, + this->tcp_properties_->recv_buffer_size) == -1) return -1; -#endif /* !ACE_LACKS_SOCKET_BUFSIZ */ #if !defined (ACE_LACKS_TCP_NODELAY) @@ -141,11 +126,6 @@ TAO_IIOP_Server_Connection_Handler::open (void*) return -1; #endif /* ! ACE_LACKS_TCP_NODELAY */ - (void) this->peer ().enable (ACE_CLOEXEC); - // Set the close-on-exec flag for that file descriptor. If the - // operation fails we are out of luck (some platforms do not support - // it and return -1). - // Called by the <Strategy_Acceptor> when the handler is // completely connected. ACE_INET_Addr addr; @@ -221,11 +201,7 @@ TAO_IIOP_Server_Connection_Handler::handle_close (ACE_HANDLE handle, // Remove the handle from the ORB Core's handle set so that it // isn't included in the set that is passed to the reactor upon // ORB destruction. - TAO_Server_Strategy_Factory *f = - this->orb_core_->server_factory (); - - if (f->activate_server_connections () == 0) - (void) this->orb_core_->remove_handle (handle); + this->remove_handle (handle); return TAO_SVC_HANDLER::handle_close (handle, rm); } @@ -239,58 +215,9 @@ TAO_IIOP_Server_Connection_Handler::svc (void) // This method is called when an instance is "activated", i.e., // turned into an active object. Presumably, activation spawns a // thread with this method as the "worker function". - int result = 0; - - // Inheriting the ORB_Core tss stuff from the parent thread. - this->orb_core_->inherit_from_parent_thread (this->tss_resources_); - - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO (%P|%t) IIOP_Server_Connection_Handler::svc begin\n"))); - - // Here we simply synthesize the "typical" event loop one might find - // in a reactive handler, except that this can simply block waiting - // for input. - - ACE_Time_Value *max_wait_time = 0; - ACE_Time_Value timeout; - ACE_Time_Value current_timeout; - if (this->orb_core_->thread_per_connection_timeout (timeout)) - { - current_timeout = timeout; - max_wait_time = ¤t_timeout; - } - while (!this->orb_core_->has_shutdown () - && result >= 0) - { - result = handle_input_i (ACE_INVALID_HANDLE, max_wait_time); - - if (result == -1 && errno == ETIME) - { - // Ignore timeouts, they are only used to wake up and - // shutdown. - result = 0; - - // Reset errno to make sure we don't trip over an old value - // of errno in case it is not reset when the recv() call - // fails if the socket has been closed. - errno = 0; - } - - current_timeout = timeout; - - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO (%P|%t) IIOP_Server_Connection_Handler::svc - ") - ACE_TEXT ("loop <%d>\n"), current_timeout.msec ())); - } - - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO (%P|%t) IIOP_Server_Connection_Handler::svc end\n"))); - - return result; + // Call the implementation here + return this->svc_i (); } int @@ -306,7 +233,7 @@ TAO_IIOP_Server_Connection_Handler::handle_input_i (ACE_HANDLE, this->refcount_++; int result = this->acceptor_factory_->handle_input (this->transport (), - this->orb_core_, + this->orb_core (), this->transport_.message_state_, max_wait_time); @@ -344,13 +271,13 @@ TAO_IIOP_Server_Connection_Handler::handle_input_i (ACE_HANDLE, // Steal the input CDR from the message state. TAO_InputCDR input_cdr (ACE_InputCDR::Transfer_Contents (ms.cdr), - this->orb_core_); + this->orb_core ()); // Reset the message state. this->transport_.message_state_.reset (0); result = this->acceptor_factory_->process_client_message (this->transport (), - this->orb_core_, + this->orb_core (), input_cdr, message_type); @@ -369,13 +296,12 @@ TAO_IIOP_Server_Connection_Handler::handle_input_i (ACE_HANDLE, TAO_IIOP_Client_Connection_Handler:: TAO_IIOP_Client_Connection_Handler (ACE_Thread_Manager* t) : TAO_IIOP_Handler_Base (t), + TAO_Connection_Handler (0), transport_ (this, 0), - orb_core_ (0), - lite_flag_ (0), tcp_properties_ (0) { // This constructor should *never* get called. See comments in .h - ACE_ASSERT (this->orb_core_ != 0); + ACE_ASSERT (this->orb_core () != 0); } TAO_IIOP_Client_Connection_Handler:: @@ -384,9 +310,8 @@ TAO_IIOP_Client_Connection_Handler (ACE_Thread_Manager *t, CORBA::Boolean flag, void *arg) : TAO_IIOP_Handler_Base (t), + TAO_Connection_Handler (orb_core), transport_ (this, orb_core), - orb_core_ (orb_core), - lite_flag_ (flag), tcp_properties_ (ACE_static_cast (TAO_IIOP_Handler_Base::TCP_Properties *, arg)) { @@ -411,21 +336,11 @@ TAO_IIOP_Client_Connection_Handler::~TAO_IIOP_Client_Connection_Handler (void) int TAO_IIOP_Client_Connection_Handler::open (void *) { -#if !defined (ACE_LACKS_SOCKET_BUFSIZ) - - if (this->peer ().set_option (SOL_SOCKET, - SO_SNDBUF, - (void *) &tcp_properties_->send_buffer_size, - sizeof (int)) == -1 - && errno != ENOTSUP) + if (this->set_socket_option (this->peer (), + tcp_properties_->send_buffer_size, + tcp_properties_->recv_buffer_size) + == -1) return -1; - else if (this->peer ().set_option (SOL_SOCKET, - SO_RCVBUF, - (void *) &tcp_properties_->recv_buffer_size, - sizeof (int)) == -1 - && errno != ENOTSUP) - return -1; -#endif /* ACE_LACKS_SOCKET_BUFSIZ */ #if !defined (ACE_LACKS_TCP_NODELAY) @@ -438,11 +353,6 @@ TAO_IIOP_Client_Connection_Handler::open (void *) -1); #endif /* ! ACE_LACKS_TCP_NODELAY */ - (void) this->peer ().enable (ACE_CLOEXEC); - // Set the close-on-exec flag for that file descriptor. If the - // operation fails we are out of luck (some platforms do not support - // it and return -1). - // Called by the <Strategy_Acceptor> when the handler is completely // connected. ACE_INET_Addr addr; @@ -484,39 +394,18 @@ TAO_IIOP_Client_Connection_Handler::handle_input (ACE_HANDLE) } int -TAO_IIOP_Client_Connection_Handler::handle_timeout (const ACE_Time_Value &, - const void *) +TAO_IIOP_Client_Connection_Handler::handle_input_i (ACE_HANDLE, + ACE_Time_Value *) { - // - // This method is called when buffering timer expires. - // - - ACE_Time_Value *max_wait_time = 0; - -#if (TAO_HAS_RELATIVE_ROUNDTRIP_TIMEOUT_POLICY == 1) - - TAO_RelativeRoundtripTimeoutPolicy *timeout_policy = - this->orb_core_->stubless_relative_roundtrip_timeout (); - - // Automatically release the policy - CORBA::Object_var auto_release = timeout_policy; - - ACE_Time_Value max_wait_time_value; - - // If max_wait_time is not zero then this is not the first attempt - // to send the request, the timeout value includes *all* those - // attempts. - if (timeout_policy != 0) - { - timeout_policy->set_time_value (max_wait_time_value); - max_wait_time = &max_wait_time_value; - } - - -#endif /* TAO_HAS_RELATIVE_ROUNDTRIP_TIMEOUT_POLICY == 1 */ + ACE_NOTSUP_RETURN (-1); +} +int +TAO_IIOP_Client_Connection_Handler::handle_timeout (const ACE_Time_Value &val, + const void *ptr) +{ // Cannot deal with errors, and therefore they are ignored. - this->transport ()->send_buffered_messages (max_wait_time); + this->transport ()->send_buffered_messages (this->handle_timeout_i (val, ptr)); return 0; } @@ -569,19 +458,9 @@ TAO_IIOP_Client_Connection_Handler::handle_close_i (ACE_HANDLE handle, int TAO_IIOP_Client_Connection_Handler::handle_cleanup (void) { - // Deregister this handler with the ACE_Reactor. - if (this->reactor ()) - { - ACE_Reactor_Mask mask = - ACE_Event_Handler::ALL_EVENTS_MASK | ACE_Event_Handler::DONT_CALL; - - // Make sure there are no timers. - this->reactor ()->cancel_timer (this); - - // Remove self from reactor. - this->reactor ()->remove_handler (this, mask); - } - + // Call the implementation. + this->handle_cleanup_i (this->reactor (), + this); this->peer ().close (); return 0; diff --git a/TAO/tao/IIOP_Connect.h b/TAO/tao/IIOP_Connect.h index c0ae4c6b135..0fdb72d35d7 100644 --- a/TAO/tao/IIOP_Connect.h +++ b/TAO/tao/IIOP_Connect.h @@ -31,12 +31,10 @@ #include "tao/corbafwd.h" #include "tao/Wait_Strategy.h" - +#include "tao/Connection_Handler.h" #include "tao/IIOP_Transport.h" // Forward Decls -class TAO_ORB_Core; -class TAO_ORB_Core_TSS_Resources; class Pluggable_Messaging; typedef ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> @@ -63,7 +61,8 @@ public: }; }; -class TAO_Export TAO_IIOP_Client_Connection_Handler : public TAO_IIOP_Handler_Base +class TAO_Export TAO_IIOP_Client_Connection_Handler: public TAO_IIOP_Handler_Base, + public TAO_Connection_Handler { // = TITLE // <Svc_Handler> used on the client side and returned by the @@ -96,6 +95,7 @@ public: virtual int handle_input (ACE_HANDLE = ACE_INVALID_HANDLE); // Called when a response from a twoway invocation is available. + virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg = 0); // Called when buffering timer expires. @@ -121,19 +121,21 @@ protected: TAO_IIOP_Client_Transport transport_; // Reference to the transport object, it is owned by this class. - TAO_ORB_Core *orb_core_; - // Cached ORB Core. - - CORBA::Boolean lite_flag_; - // Are we using GIOP lite? - TCP_Properties *tcp_properties_; // TCP configuration for this connection. + +private: + virtual int handle_input_i (ACE_HANDLE = ACE_INVALID_HANDLE, + ACE_Time_Value *max_wait_time = 0); + // Will not be called at all. As a matter of fact should not be + // called. This is just to override the pure virtual function in the + // TAO_Connection_Handler class }; // **************************************************************** -class TAO_Export TAO_IIOP_Server_Connection_Handler : public TAO_IIOP_Handler_Base +class TAO_Export TAO_IIOP_Server_Connection_Handler : public TAO_IIOP_Handler_Base, + public TAO_Connection_Handler { // = TITLE // Handles requests on a single connection in a server. @@ -197,21 +199,12 @@ protected: TAO_Pluggable_Messaging *acceptor_factory_; // Messaging acceptor factory - TAO_ORB_Core *orb_core_; - // Cached ORB Core. - - TAO_ORB_Core_TSS_Resources *tss_resources_; - // Cached tss resources of the ORB that activated this object. - u_long refcount_; // Reference count. It is used to count nested upcalls on this // svc_handler i.e., the connection can close during nested upcalls, // you should not delete the svc_handler until the stack unwinds // from the nested upcalls. - CORBA::Boolean lite_flag_; - // Should we use GIOP or GIOPlite - TCP_Properties *tcp_properties_; // TCP configuration for this connection. }; diff --git a/TAO/tao/SHMIOP_Connect.cpp b/TAO/tao/SHMIOP_Connect.cpp index d16c3c1b80e..cfe3cad0cc9 100644 --- a/TAO/tao/SHMIOP_Connect.cpp +++ b/TAO/tao/SHMIOP_Connect.cpp @@ -70,33 +70,29 @@ TAO_SHMIOP_Handler_Base::TAO_SHMIOP_Handler_Base (ACE_Thread_Manager *t) TAO_SHMIOP_Server_Connection_Handler::TAO_SHMIOP_Server_Connection_Handler (ACE_Thread_Manager *t) : TAO_SHMIOP_Handler_Base (t), + TAO_Connection_Handler (0), transport_ (this, 0), acceptor_factory_ (0), - orb_core_ (0), - tss_resources_ (0), refcount_ (1) - { // This constructor should *never* get called, it is just here to // make the compiler happy: the default implementation of the // Creation_Strategy requires a constructor with that signature, we // don't use that implementation, but some (most?) compilers // instantiate it anyway. - ACE_ASSERT (this->orb_core_ != 0); + ACE_ASSERT (this->orb_core () != 0); } TAO_SHMIOP_Server_Connection_Handler::TAO_SHMIOP_Server_Connection_Handler (TAO_ORB_Core *orb_core, - CORBA::Boolean flag, + CORBA::Boolean lite_flag, void *) : TAO_SHMIOP_Handler_Base (orb_core), + TAO_Connection_Handler (orb_core), transport_ (this, orb_core), acceptor_factory_ (0), - orb_core_ (orb_core), - tss_resources_ (orb_core->get_tss_resources ()), - refcount_ (1), - lite_flag_ (flag) + refcount_ (1) { - if (lite_flag_) + if (lite_flag) { ACE_NEW (this->acceptor_factory_, TAO_GIOP_Message_Lite (orb_core)); @@ -116,29 +112,15 @@ TAO_SHMIOP_Server_Connection_Handler::~TAO_SHMIOP_Server_Connection_Handler (voi int TAO_SHMIOP_Server_Connection_Handler::open (void*) { -#if !defined (ACE_LACKS_SOCKET_BUFSIZ) - int sndbufsize = - this->orb_core_->orb_params ()->sock_sndbuf_size (); - int rcvbufsize = - this->orb_core_->orb_params ()->sock_rcvbuf_size (); - - if (this->peer ().set_option (SOL_SOCKET, - SO_SNDBUF, - (void *) &sndbufsize, - sizeof (sndbufsize)) == -1 - && errno != ENOTSUP) - return -1; - else if (this->peer ().set_option (SOL_SOCKET, - SO_RCVBUF, - (void *) &rcvbufsize, - sizeof (rcvbufsize)) == -1 - && errno != ENOTSUP) + if (this->set_socket_option (this->peer (), + this->orb_core ()->orb_params ()->sock_sndbuf_size (), + this->orb_core ()->orb_params ()->sock_rcvbuf_size ()) + == -1) return -1; -#endif /* !ACE_LACKS_SOCKET_BUFSIZ */ #if defined (TCP_NODELAY) int nodelay = - this->orb_core_->orb_params ()->nodelay (); + this->orb_core ()->orb_params ()->nodelay (); if (this->peer ().set_option (ACE_IPPROTO_TCP, TCP_NODELAY, @@ -147,11 +129,6 @@ TAO_SHMIOP_Server_Connection_Handler::open (void*) return -1; #endif /* TCP_NODELAY */ - (void) this->peer ().enable (ACE_CLOEXEC); - // Set the close-on-exec flag for that file descriptor. If the - // operation fails we are out of luck (some platforms do not support - // it and return -1). - // Called by the <Strategy_Acceptor> when the handler is completely // connected. ACE_INET_Addr addr; @@ -222,11 +199,7 @@ TAO_SHMIOP_Server_Connection_Handler::handle_close (ACE_HANDLE handle, // Remove the handle from the ORB Core's handle set so that it // isn't included in the set that is passed to the reactor upon // ORB destruction. - TAO_Server_Strategy_Factory *f = - this->orb_core_->server_factory (); - - if (f->activate_server_connections () == 0) - (void) this->orb_core_->remove_handle (handle); + this->remove_handle (handle); this->peer().remove (); return TAO_SHMIOP_SVC_HANDLER::handle_close (handle, rm); @@ -243,56 +216,8 @@ TAO_SHMIOP_Server_Connection_Handler::svc (void) // thread with this method as the "worker function". int result = 0; - // Inheriting the ORB_Core tss stuff from the parent thread. - this->orb_core_->inherit_from_parent_thread (this->tss_resources_); - - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO (%P|%t) SHMIOP_Server_Connection_Handler::svc begin\n"))); - - // Here we simply synthesize the "typical" event loop one might find - // in a reactive handler, except that this can simply block waiting - // for input. - - ACE_Time_Value *max_wait_time = 0; - ACE_Time_Value timeout; - ACE_Time_Value current_timeout; - if (this->orb_core_->thread_per_connection_timeout (timeout)) - { - current_timeout = timeout; - max_wait_time = ¤t_timeout; - } - - while (!this->orb_core_->has_shutdown () - && result >= 0) - { - result = handle_input_i (ACE_INVALID_HANDLE, max_wait_time); - - if (result == -1 && errno == ETIME) - { - // Ignore timeouts, they are only used to wake up and - // shutdown. - result = 0; - - // Reset errno to make sure we don't trip over an old value - // of errno in case it is not reset when the recv() call - // fails if the socket has been closed. - errno = 0; - } - - current_timeout = timeout; - - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO (%P|%t) SHMIOP_Server_Connection_Handler::svc - ") - ACE_TEXT ("loop <%d>\n"), current_timeout.msec ())); - } - - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO (%P|%t) SHMIOP_Server_Connection_Handler::svc end\n"))); - - return result; + // Call the implementation here + return this->svc_i (); } int @@ -308,7 +233,7 @@ TAO_SHMIOP_Server_Connection_Handler::handle_input_i (ACE_HANDLE, this->refcount_++; int result = this->acceptor_factory_->handle_input (this->transport (), - this->orb_core_, + this->orb_core (), this->transport_.message_state_, max_wait_time); @@ -346,14 +271,14 @@ TAO_SHMIOP_Server_Connection_Handler::handle_input_i (ACE_HANDLE, // Steal the input CDR from the message state. TAO_InputCDR input_cdr (ACE_InputCDR::Transfer_Contents (ms.cdr), - this->orb_core_); + this->orb_core ()); // Reset the message state. this->transport_.message_state_.reset (0); result = this->acceptor_factory_->process_client_message (this->transport (), - this->orb_core_, + this->orb_core (), input_cdr, message_type); if (result != -1) @@ -372,13 +297,12 @@ TAO_SHMIOP_Server_Connection_Handler::handle_input_i (ACE_HANDLE, TAO_SHMIOP_Client_Connection_Handler:: TAO_SHMIOP_Client_Connection_Handler (ACE_Thread_Manager *t, TAO_ORB_Core* orb_core, - CORBA::Boolean flag) + CORBA::Boolean lite_flag) : TAO_SHMIOP_Handler_Base (t), - transport_ (this, orb_core), - orb_core_ (orb_core), - lite_flag_ (flag) + TAO_Connection_Handler (orb_core), + transport_ (this, orb_core) { - this->transport_.use_lite (lite_flag_); + this->transport_.use_lite (lite_flag); } TAO_SHMIOP_Client_Connection_Handler::~TAO_SHMIOP_Client_Connection_Handler (void) @@ -390,32 +314,15 @@ TAO_SHMIOP_Client_Connection_Handler::open (void *) { // @@ TODO: This flags should be set using the RT CORBA policies... - // Here is where we could enable all sorts of things such as - // nonblock I/O, sock buf sizes, TCP no-delay, etc. - -#if !defined (ACE_LACKS_SOCKET_BUFSIZ) - int sndbufsize = - this->orb_core_->orb_params ()->sock_sndbuf_size (); - int rcvbufsize = - this->orb_core_->orb_params ()->sock_rcvbuf_size (); - - if (this->peer ().set_option (SOL_SOCKET, - SO_SNDBUF, - ACE_reinterpret_cast (void *, &sndbufsize), - sizeof (sndbufsize)) == -1 - && errno != ENOTSUP) + if (this->set_socket_option (this->peer (), + this->orb_core ()->orb_params ()->sock_sndbuf_size (), + this->orb_core ()->orb_params ()->sock_rcvbuf_size ()) + == -1) return -1; - else if (this->peer ().set_option (SOL_SOCKET, - SO_RCVBUF, - ACE_reinterpret_cast (void *, &rcvbufsize), - sizeof (rcvbufsize)) == -1 - && errno != ENOTSUP) - return -1; -#endif /* ACE_LACKS_SOCKET_BUFSIZ */ #if defined (TCP_NODELAY) int nodelay = - this->orb_core_->orb_params ()->nodelay (); + this->orb_core ()->orb_params ()->nodelay (); if (this->peer ().set_option (ACE_IPPROTO_TCP, TCP_NODELAY, (void *) &nodelay, @@ -425,11 +332,6 @@ TAO_SHMIOP_Client_Connection_Handler::open (void *) -1); #endif /* TCP_NODELAY */ - (void) this->peer ().enable (ACE_CLOEXEC); - // Set the close-on-exec flag for that file descriptor. If the - // operation fails we are out of luck (some platforms do not support - // it and return -1). - // Called by the <Strategy_Acceptor> when the handler is completely // connected. ACE_INET_Addr addr; @@ -471,39 +373,19 @@ TAO_SHMIOP_Client_Connection_Handler::handle_input (ACE_HANDLE) } int -TAO_SHMIOP_Client_Connection_Handler::handle_timeout (const ACE_Time_Value &, - const void *) +TAO_SHMIOP_Client_Connection_Handler::handle_input_i (ACE_HANDLE, + ACE_Time_Value *) { - // - // This method is called when buffering timer expires. - // - - ACE_Time_Value *max_wait_time = 0; - -#if (TAO_HAS_RELATIVE_ROUNDTRIP_TIMEOUT_POLICY == 1) - - TAO_RelativeRoundtripTimeoutPolicy *timeout_policy = - this->orb_core_->stubless_relative_roundtrip_timeout (); - - // Automatically release the policy - CORBA::Object_var auto_release = timeout_policy; - - ACE_Time_Value max_wait_time_value; - - // If max_wait_time is not zero then this is not the first attempt - // to send the request, the timeout value includes *all* those - // attempts. - if (timeout_policy != 0) - { - timeout_policy->set_time_value (max_wait_time_value); - max_wait_time = &max_wait_time_value; - } - + ACE_NOTSUP_RETURN (-1); +} -#endif /* TAO_HAS_RELATIVE_ROUNDTRIP_TIMEOUT_POLICY == 1 */ +int +TAO_SHMIOP_Client_Connection_Handler::handle_timeout (const ACE_Time_Value &val, + const void *ptr) +{ // Cannot deal with errors, and therefore they are ignored. - this->transport ()->send_buffered_messages (max_wait_time); + this->transport ()->send_buffered_messages (this->handle_timeout_i (val, ptr)); return 0; } @@ -556,19 +438,9 @@ TAO_SHMIOP_Client_Connection_Handler::handle_close_i (ACE_HANDLE handle, int TAO_SHMIOP_Client_Connection_Handler::handle_cleanup (void) { - // Deregister this handler with the ACE_Reactor. - if (this->reactor ()) - { - ACE_Reactor_Mask mask = - ACE_Event_Handler::ALL_EVENTS_MASK | ACE_Event_Handler::DONT_CALL; - - // Make sure there are no timers. - this->reactor ()->cancel_timer (this); - - // Remove self from reactor. - this->reactor ()->remove_handler (this, mask); - } - + // Call the implementation. + this->handle_cleanup_i (this->reactor (), + this); this->peer ().close (); return 0; diff --git a/TAO/tao/SHMIOP_Connect.h b/TAO/tao/SHMIOP_Connect.h index a21f3a27217..77724009d89 100644 --- a/TAO/tao/SHMIOP_Connect.h +++ b/TAO/tao/SHMIOP_Connect.h @@ -34,12 +34,10 @@ #include "tao/corbafwd.h" #include "tao/Wait_Strategy.h" - +#include "tao/Connection_Handler.h" #include "tao/SHMIOP_Transport.h" -// Forward Decls -class TAO_ORB_Core; -class TAO_ORB_Core_TSS_Resources; + typedef ACE_Svc_Handler<ACE_MEM_STREAM, ACE_NULL_SYNCH> @@ -56,7 +54,8 @@ public: virtual TAO_Transport *transport (void) = 0; }; -class TAO_Export TAO_SHMIOP_Client_Connection_Handler : public TAO_SHMIOP_Handler_Base +class TAO_Export TAO_SHMIOP_Client_Connection_Handler : public TAO_SHMIOP_Handler_Base, + public TAO_Connection_Handler { // = TITLE // <Svc_Handler> used on the client side and returned by the @@ -103,16 +102,18 @@ protected: TAO_SHMIOP_Client_Transport transport_; // Reference to the transport object, it is owned by this class. - TAO_ORB_Core *orb_core_; - // Cached ORB Core. - - CORBA::Boolean lite_flag_; - // Are we using lite? +private: + virtual int handle_input_i (ACE_HANDLE = ACE_INVALID_HANDLE, + ACE_Time_Value *max_wait_time = 0); + // Will not be called at all. As a matter of fact should not be + // called. This is just to override the pure virtual function in the + // TAO_Connection_Handler class }; // **************************************************************** -class TAO_Export TAO_SHMIOP_Server_Connection_Handler : public TAO_SHMIOP_Handler_Base +class TAO_Export TAO_SHMIOP_Server_Connection_Handler : public TAO_SHMIOP_Handler_Base, + public TAO_Connection_Handler { // = TITLE // Handles requests on a single connection in a server. @@ -175,20 +176,11 @@ protected: TAO_Pluggable_Messaging *acceptor_factory_; // Messaging acceptor factory - TAO_ORB_Core *orb_core_; - // Cached ORB Core. - - TAO_ORB_Core_TSS_Resources *tss_resources_; - // Cached tss resources of the ORB that activated this object. - u_long refcount_; // Reference count. It is used to count nested upcalls on this // svc_handler i.e., the connection can close during nested upcalls, // you should not delete the svc_handler until the stack unwinds // from the nested upcalls. - - CORBA::Boolean lite_flag_; - // Should we use GIOP or GIOPlite }; #if defined (__ACE_INLINE__) diff --git a/TAO/tao/TAO.dsp b/TAO/tao/TAO.dsp index cf038c3eac9..0a31c990c1c 100644 --- a/TAO/tao/TAO.dsp +++ b/TAO/tao/TAO.dsp @@ -499,6 +499,25 @@ SOURCE=.\Client_Strategy_Factory.cpp # End Source File
# Begin Source File
+SOURCE=.\Connection_Handler.cpp
+
+!IF "$(CFG)" == "TAO DLL - Win32 Alpha Release"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 Alpha Debug"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 MFC Release"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 MFC Debug"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 Release"
+
+!ELSEIF "$(CFG)" == "TAO DLL - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
SOURCE=.\Connector_Registry.cpp
!IF "$(CFG)" == "TAO DLL - Win32 Alpha Release"
@@ -3466,6 +3485,10 @@ SOURCE=.\Client_Strategy_Factory.h # End Source File
# Begin Source File
+SOURCE=.\Connection_Handler.h
+# End Source File
+# Begin Source File
+
SOURCE=.\Connector_Registry.h
# End Source File
# Begin Source File
@@ -4138,6 +4161,10 @@ SOURCE=.\Client_Priority_Policy.i # End Source File
# Begin Source File
+SOURCE=.\Connection_Handler.i
+# End Source File
+# Begin Source File
+
SOURCE=.\Context.i
# End Source File
# Begin Source File
|