diff options
author | Phil Mesnier <mesnier_p@ociweb.com> | 2006-11-03 00:31:54 +0000 |
---|---|---|
committer | Phil Mesnier <mesnier_p@ociweb.com> | 2006-11-03 00:31:54 +0000 |
commit | 6a926a343333467c20af867b300b9891e84695e2 (patch) | |
tree | 5048d9d618c23e345265326f4c07c0067ec17eef | |
parent | efd14fdeef1052adf83ffbc846783bab14209b00 (diff) | |
download | ATCD-6a926a343333467c20af867b300b9891e84695e2.tar.gz |
Fri Nov 3 00:22:27 UTC 2006 Phil Mesnier <mesnier_p@ociweb.com>
-rw-r--r-- | TAO/ChangeLog | 24 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/HTIOP/HTIOP_Connection_Handler.cpp | 3 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.cpp | 3 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp | 23 | ||||
-rw-r--r-- | TAO/tao/Connection_Handler.cpp | 23 | ||||
-rw-r--r-- | TAO/tao/Connection_Handler.h | 23 | ||||
-rw-r--r-- | TAO/tao/Connection_Handler.inl | 21 | ||||
-rw-r--r-- | TAO/tao/IIOP_Connection_Handler.cpp | 27 | ||||
-rw-r--r-- | TAO/tao/IIOP_Connection_Handler.h | 12 | ||||
-rw-r--r-- | TAO/tao/IIOP_Connector.cpp | 21 | ||||
-rw-r--r-- | TAO/tao/Strategies/SCIOP_Connection_Handler.cpp | 3 | ||||
-rw-r--r-- | TAO/tao/Strategies/SCIOP_Connector.cpp | 17 | ||||
-rw-r--r-- | TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp | 3 | ||||
-rw-r--r-- | TAO/tao/Strategies/SHMIOP_Connector.cpp | 24 | ||||
-rw-r--r-- | TAO/tao/Strategies/UIOP_Connection_Handler.cpp | 3 | ||||
-rw-r--r-- | TAO/tao/Strategies/UIOP_Connector.cpp | 16 |
16 files changed, 185 insertions, 61 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 7c413037a3b..76ab080dbea 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,27 @@ +Fri Nov 3 00:22:27 UTC 2006 Phil Mesnier <mesnier_p@ociweb.com> + + * orbsvcs/orbsvcs/HTIOP/HTIOP_Connection_Handler.cpp: + + * orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.cpp: + * orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp: + + * tao/Connection_Handler.h: + * tao/Connection_Handler.inl: + * tao/Connection_Handler.cpp: + * tao/IIOP_Connection_Handler.h: + * tao/IIOP_Connection_Handler.cpp: + * tao/IIOP_Connector.cpp: + + * tao/Strategies/SCIOP_Connection_Handler.cpp: + * tao/Strategies/SCIOP_Connector.cpp: + * tao/Strategies/SHMIOP_Connection_Handler.cpp: + * tao/Strategies/SHMIOP_Connector.cpp: + * tao/Strategies/UIOP_Connection_Handler.cpp: + * tao/Strategies/UIOP_Connector.cpp: + + Propagating the changes applied just to IIOP for bug 2654 to the + other DOC managed ESIOPs. + Thu Nov 2 23:23:16 UTC 2006 Ossama Othman <ossama_othman at symantec.com> * tao/ORB_Core.cpp (orbinitializer_registry_i): diff --git a/TAO/orbsvcs/orbsvcs/HTIOP/HTIOP_Connection_Handler.cpp b/TAO/orbsvcs/orbsvcs/HTIOP/HTIOP_Connection_Handler.cpp index 94eb2b878b7..5a749e78051 100644 --- a/TAO/orbsvcs/orbsvcs/HTIOP/HTIOP_Connection_Handler.cpp +++ b/TAO/orbsvcs/orbsvcs/HTIOP/HTIOP_Connection_Handler.cpp @@ -76,6 +76,9 @@ TAO::HTIOP::Connection_Handler::open_handler (void *v) int TAO::HTIOP::Connection_Handler::open (void*) { + if (this->shared_open() == -1) + return -1; + if (this->transport ()->wait_strategy ()->non_blocking ()) { if (this->peer ().enable (ACE_NONBLOCK) == -1) diff --git a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.cpp b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.cpp index 8dd22d19cc0..8ddb0ade83d 100644 --- a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.cpp +++ b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.cpp @@ -82,6 +82,9 @@ TAO::SSLIOP::Connection_Handler::open_handler (void *v) int TAO::SSLIOP::Connection_Handler::open (void *) { + if (this->shared_open() == -1) + return -1; + TAO_IIOP_Protocol_Properties protocol_properties; // Initialize values from ORB params. diff --git a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp index 32174c6b252..0b99b5e4a03 100644 --- a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp +++ b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp @@ -635,9 +635,9 @@ TAO::SSLIOP::Connector::ssliop_connect ( this->active_connect_strategy_->synch_options (max_wait_time, synch_options); - // The code used to set the timeout to zero, with the intent of + // The code used to set the timeout to zero, with the intent of // polling the reactor for connection completion. However, the side-effect - // was to cause the connection to timeout immediately. + // was to cause the connection to timeout immediately. // We obtain the transport in the <svc_handler> variable. As we // know now that the connection is not available in Cache we can @@ -705,9 +705,16 @@ TAO::SSLIOP::Connector::ssliop_connect ( return 0; } - if (transport->connection_handler ()->keep_waiting ()) + // fix for bug 2654 + if (svc_handler->keep_waiting ()) { - svc_handler->add_reference (); + svc_handler->connection_pending (); + } + + // fix for bug 2654 + if (svc_handler->error_detected ()) + { + svc_handler->cancel_pending_connection (); } // At this point, the connection has be successfully connected. @@ -741,6 +748,14 @@ TAO::SSLIOP::Connector::ssliop_connect ( return 0; } + // fix for bug 2654 + if (svc_handler->error_detected ()) + { + svc_handler->cancel_pending_connection (); + transport->purge_entry(); + return 0; + } + if (transport->is_connected () && transport->wait_strategy ()->register_handler () != 0) { diff --git a/TAO/tao/Connection_Handler.cpp b/TAO/tao/Connection_Handler.cpp index 7c04f4b7329..70b23c82fa9 100644 --- a/TAO/tao/Connection_Handler.cpp +++ b/TAO/tao/Connection_Handler.cpp @@ -24,8 +24,9 @@ ACE_RCSID (tao, TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Connection_Handler::TAO_Connection_Handler (TAO_ORB_Core *orb_core) - : orb_core_ (orb_core) - , transport_ (0) + : orb_core_ (orb_core), + transport_ (0), + connection_pending_ (false) { // @@todo: We need to have a distinct option/ method in the resource // factory for this and TAO_Transport. @@ -46,6 +47,18 @@ TAO_Connection_Handler::~TAO_Connection_Handler (void) //@@ CONNECTION_HANDLER_DESTRUCTOR_ADD_HOOK } +int +TAO_Connection_Handler::shared_open (void) +{ + // This reference counting is related to asynch connections. It + // should probably be managed by the ACE_Strategy_Connector, since + // that's really the reference being managed here. also, whether + // open ultimately succeeds or fails, the connection attempted is + // ending, so the reference must be removed in any case. + this->cancel_pending_connection(); + + return 0; +} int TAO_Connection_Handler::set_socket_option (ACE_SOCK &sock, @@ -417,6 +430,12 @@ TAO_Connection_Handler::close_handler (void) this->orb_core_->leader_follower ()); this->transport ()->purge_entry(); this->transport ()->remove_reference (); + + // @@ I think that if the connection_pending state is true + // when close_handler is calld, we should probably release + // another reference so that the connector doesn't have to + // worry about it. + return 0; } diff --git a/TAO/tao/Connection_Handler.h b/TAO/tao/Connection_Handler.h index 0299a98ca2e..6cc2a558dac 100644 --- a/TAO/tao/Connection_Handler.h +++ b/TAO/tao/Connection_Handler.h @@ -23,6 +23,7 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "tao/Basic_Types.h" +#include "ace/Event_Handler.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL class ACE_SOCK; @@ -112,6 +113,19 @@ public: /// this handler virtual int close_handler (void); + /// When waiting for an asynchronous connection to complete an + /// additional reference must be maintained, related to bugzilla + /// #2417. However once the connection is successfully established, + /// this reference must be removed. Using connection_pending allows + /// the connection handler to know that it is opening as a result of + /// a delayed asynch connection rather than an immediate synch + /// connection, which has no additional reference needs. + void connection_pending (void); + + /// A pending connection may be canceled due to an error detected + /// while the initiating thread is still in the Connector. + void cancel_pending_connection (void); + /// Set the Diff-Serv codepoint on outgoing packets. Only has /// effect for remote protocols (e.g., IIOP); no effect for local /// protocols (UIOP). Default implementation is for local @@ -133,6 +147,11 @@ protected: /// Return our TAO_ORB_Core pointer TAO_ORB_Core *orb_core (void); + /// A common function called at the start of any protocol-specific + /// open. Returns -1 on a failure (although no failure mode is + /// currently defined). + int shared_open (void); + /// Set options on the socket int set_socket_option (ACE_SOCK &sock, int snd_size, @@ -179,7 +198,6 @@ protected: virtual void pos_io_hook (int & return_value); //@} - private: /// Pointer to the TAO_ORB_Core TAO_ORB_Core * const orb_core_; @@ -191,6 +209,9 @@ private: /// count / pending upcalls lock because they interleave. ACE_Lock * lock_; + /// Stores the connection pending state + bool connection_pending_; + /* * Hook to add instance members from derived class * onto base Connection_Handler class. Any further diff --git a/TAO/tao/Connection_Handler.inl b/TAO/tao/Connection_Handler.inl index 48e1b0b1b41..7aedc01c8c1 100644 --- a/TAO/tao/Connection_Handler.inl +++ b/TAO/tao/Connection_Handler.inl @@ -41,6 +41,27 @@ TAO_Connection_Handler::is_connecting (void) const return this->state_ == TAO_LF_Event::LFS_CONNECTION_WAIT; } + +ACE_INLINE void +TAO_Connection_Handler::connection_pending (void) +{ + if (!this->connection_pending_) + { + this->connection_pending_ = true; + this->transport()->add_reference(); + } +} + +ACE_INLINE void +TAO_Connection_Handler::cancel_pending_connection (void) +{ + if (this->connection_pending_) + { + this->connection_pending_ = false; + this->transport()->remove_reference(); + } +} + //@@ CONNECTION_HANDLER_SPL_METHODS_ADD_HOOK TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/IIOP_Connection_Handler.cpp b/TAO/tao/IIOP_Connection_Handler.cpp index 447c3d511ee..3f62e43d82e 100644 --- a/TAO/tao/IIOP_Connection_Handler.cpp +++ b/TAO/tao/IIOP_Connection_Handler.cpp @@ -24,8 +24,7 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_IIOP_Connection_Handler::TAO_IIOP_Connection_Handler (ACE_Thread_Manager *t) : TAO_IIOP_SVC_HANDLER (t, 0 , 0), TAO_Connection_Handler (0), - dscp_codepoint_ (IPDSFIELD_DSCP_DEFAULT << 2), - connection_pending_ (false) + dscp_codepoint_ (IPDSFIELD_DSCP_DEFAULT << 2) { // This constructor should *never* get called, it is just here to // make the compiler happy: the default implementation of the @@ -41,8 +40,7 @@ TAO_IIOP_Connection_Handler::TAO_IIOP_Connection_Handler ( CORBA::Boolean flag) : TAO_IIOP_SVC_HANDLER (orb_core->thr_mgr (), 0, 0), TAO_Connection_Handler (orb_core), - dscp_codepoint_ (IPDSFIELD_DSCP_DEFAULT << 2), - connection_pending_ (false) + dscp_codepoint_ (IPDSFIELD_DSCP_DEFAULT << 2) { TAO_IIOP_Transport* specific_transport = 0; ACE_NEW (specific_transport, @@ -55,8 +53,7 @@ TAO_IIOP_Connection_Handler::TAO_IIOP_Connection_Handler ( TAO_IIOP_Connection_Handler::TAO_IIOP_Connection_Handler (TAO_ORB_Core *orb_core) : TAO_IIOP_SVC_HANDLER (orb_core->thr_mgr (), 0, 0), TAO_Connection_Handler (orb_core), - dscp_codepoint_ (IPDSFIELD_DSCP_DEFAULT << 2), - connection_pending_ (false) + dscp_codepoint_ (IPDSFIELD_DSCP_DEFAULT << 2) { } @@ -91,6 +88,9 @@ TAO_IIOP_Connection_Handler::open_handler (void *v) int TAO_IIOP_Connection_Handler::open (void*) { + if (this->shared_open() == -1) + return -1; + TAO_IIOP_Protocol_Properties protocol_properties; // Initialize values from ORB params. @@ -264,27 +264,12 @@ TAO_IIOP_Connection_Handler::open (void*) // compilers if (!this->transport ()->post_open ((size_t) this->get_handle ())) return -1; - if (this->connection_pending_) - { - this->connection_pending_ = false; - this->remove_reference(); - } this->state_changed (TAO_LF_Event::LFS_SUCCESS, this->orb_core ()->leader_follower ()); return 0; } -void -TAO_IIOP_Connection_Handler::connection_pending (void) -{ - if (!this->connection_pending_) - { - this->connection_pending_ = true; - this->add_reference(); - } -} - int TAO_IIOP_Connection_Handler::resume_handler (void) { diff --git a/TAO/tao/IIOP_Connection_Handler.h b/TAO/tao/IIOP_Connection_Handler.h index a1405bf541d..d00a736d5a4 100644 --- a/TAO/tao/IIOP_Connection_Handler.h +++ b/TAO/tao/IIOP_Connection_Handler.h @@ -112,15 +112,6 @@ public: /// hang around. void abort (void); - /// When waiting for an asynchronous connection to complete an - /// additional reference must be maintained, related to bugzilla - /// #2417. However once the connection is successfully established, - /// this reference must be removed. Using connection_pending allows - /// the connection handler to know that it is opening as a result of - /// a delayed asynch connection rather than an immediate synch - /// connection, which has no additional reference needs. - void connection_pending (void); - protected: /// Constructor that could be used by the derived classes. @@ -144,9 +135,6 @@ private: /// Stores the type of service value. int dscp_codepoint_; - - /// Stores the connection pending state - bool connection_pending_; }; TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/IIOP_Connector.cpp b/TAO/tao/IIOP_Connector.cpp index 79f8ed6cc1b..3d509136a89 100644 --- a/TAO/tao/IIOP_Connector.cpp +++ b/TAO/tao/IIOP_Connector.cpp @@ -457,7 +457,7 @@ TAO_IIOP_Connector::complete_connection (int result, // connected or not connected, but we have a connection. TAO_IIOP_Connection_Handler *svc_handler = 0; TAO_IIOP_Endpoint *iiop_endpoint = 0; - bool set_connection_pending = false; + if (transport != 0) { if (count == 1) @@ -503,10 +503,9 @@ TAO_IIOP_Connector::complete_connection (int result, return 0; } - if (transport->connection_handler()->keep_waiting()) + if (svc_handler->keep_waiting()) { svc_handler->connection_pending(); - set_connection_pending = true; } #if defined (INDUCE_BUG_2654_B) @@ -525,11 +524,8 @@ TAO_IIOP_Connector::complete_connection (int result, if (TAO_debug_level > 0) ACE_DEBUG((LM_DEBUG, ACE_TEXT("TAO (%P|%t) - IIOP_Connector::make_connection, ") - ACE_TEXT("transport in error before cache! ") - ACE_TEXT("conn_pend = %d\n"), - set_connection_pending)); - if (set_connection_pending) - svc_handler->remove_reference (); + ACE_TEXT("transport in error before cache! \n"))); + transport->connection_handler()->cancel_pending_connection(); return 0; } @@ -584,16 +580,13 @@ TAO_IIOP_Connector::complete_connection (int result, // before caching, the connection really failed, thus an invalid // connection is put into the cache. Thus we do one last status // check before handing the connection back to the caller. - if (transport->connection_handler()->error_detected()) + if (svc_handler->error_detected()) { if (TAO_debug_level > 0) ACE_DEBUG((LM_DEBUG, ACE_TEXT("TAO (%P|%t) - IIOP_Connector::make_connection, ") - ACE_TEXT("transport in error after cache! ") - ACE_TEXT("conn_pend = %d\n"), - set_connection_pending)); - if (set_connection_pending) - svc_handler->remove_reference (); + ACE_TEXT("transport in error after cache! \n"))); + svc_handler->cancel_pending_connection(); transport->purge_entry(); return 0; } diff --git a/TAO/tao/Strategies/SCIOP_Connection_Handler.cpp b/TAO/tao/Strategies/SCIOP_Connection_Handler.cpp index 040052ea256..72d72832118 100644 --- a/TAO/tao/Strategies/SCIOP_Connection_Handler.cpp +++ b/TAO/tao/Strategies/SCIOP_Connection_Handler.cpp @@ -94,6 +94,9 @@ TAO_SCIOP_Connection_Handler::open_handler (void *v) int TAO_SCIOP_Connection_Handler::open (void*) { + if (this->shared_open() == -1) + return -1; + TAO_SCIOP_Protocol_Properties protocol_properties; // Initialize values from ORB params. diff --git a/TAO/tao/Strategies/SCIOP_Connector.cpp b/TAO/tao/Strategies/SCIOP_Connector.cpp index d5facd3b3de..c045c772059 100644 --- a/TAO/tao/Strategies/SCIOP_Connector.cpp +++ b/TAO/tao/Strategies/SCIOP_Connector.cpp @@ -263,9 +263,15 @@ TAO_SCIOP_Connector::make_connection_i (TAO::Profile_Transport_Resolver *r, return 0; } - if (transport->connection_handler ()->keep_waiting ()) + if (svc_handler->keep_waiting ()) { - svc_handler->add_reference (); + svc_handler->connection_pending (); + } + + if (svc_handler->error_detected ()) + { + svc_handler->cancel_pending_connection (); + return 0; } // At this point, the connection has be successfully connected. @@ -299,6 +305,13 @@ TAO_SCIOP_Connector::make_connection_i (TAO::Profile_Transport_Resolver *r, return 0; } + if (svc_handler->error_detected ()) + { + svc_handler->cancel_pending_connection (); + transport->purge_entry(); + return 0; + } + if (transport->is_connected () && transport->wait_strategy ()->register_handler () != 0) { diff --git a/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp b/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp index cb922a25c8d..272ebbeab56 100644 --- a/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp +++ b/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp @@ -78,6 +78,9 @@ TAO_SHMIOP_Connection_Handler::open_handler (void *v) int TAO_SHMIOP_Connection_Handler::open (void*) { + if (this->shared_open() == -1) + return -1; + TAO_SHMIOP_Protocol_Properties protocol_properties; // Initialize values from ORB params. diff --git a/TAO/tao/Strategies/SHMIOP_Connector.cpp b/TAO/tao/Strategies/SHMIOP_Connector.cpp index adba9338dc1..3c872aad5e0 100644 --- a/TAO/tao/Strategies/SHMIOP_Connector.cpp +++ b/TAO/tao/Strategies/SHMIOP_Connector.cpp @@ -190,12 +190,23 @@ TAO_SHMIOP_Connector::make_connection (TAO::Profile_Transport_Resolver *, return 0; } + if (svc_handler->keep_waiting ()) + { + svc_handler->connection_pending (); + } + + if (svc_handler->error_detected ()) + { + svc_handler->cancel_pending_connection (); + } + // At this point, the connection has be successfully connected. // #REFCOUNT# is one. if (TAO_debug_level > 2) ACE_DEBUG ((LM_DEBUG, "TAO (%P|%t) - SHMIOP_Connector::make_connection, " - "new connection to <%s:%d> on Transport[%d]\n", + "new %s connection to <%s:%d> on Transport[%d]\n", + transport->is_connected() ? "connected" : "not connected", ACE_TEXT_CHAR_TO_TCHAR (shmiop_endpoint->host ()), shmiop_endpoint->port (), svc_handler->peer ().get_handle ())); @@ -217,13 +228,20 @@ TAO_SHMIOP_Connector::make_connection (TAO::Profile_Transport_Resolver *, if (TAO_debug_level > 0) { ACE_ERROR ((LM_ERROR, - "TAO (%P|%t) - SHMIOP_Connector::make_connection, " - "could not add the new connection to cache\n")); + ACE_TEXT("TAO (%P|%t) - SHMIOP_Connector::make_connection, ") + ACE_TEXT("could not add the new connection to cache\n"))); } return 0; } + if (svc_handler->error_detected ()) + { + svc_handler->cancel_pending_connection (); + transport->purge_entry(); + return 0; + } + if (transport->is_connected () && transport->wait_strategy ()->register_handler () != 0) { diff --git a/TAO/tao/Strategies/UIOP_Connection_Handler.cpp b/TAO/tao/Strategies/UIOP_Connection_Handler.cpp index 0c2b9354005..66ad7e60780 100644 --- a/TAO/tao/Strategies/UIOP_Connection_Handler.cpp +++ b/TAO/tao/Strategies/UIOP_Connection_Handler.cpp @@ -77,6 +77,9 @@ TAO_UIOP_Connection_Handler::open_handler (void *v) int TAO_UIOP_Connection_Handler::open (void*) { + if (this->shared_open() == -1) + return -1; + TAO_UIOP_Protocol_Properties protocol_properties; // Initialize values from ORB params. diff --git a/TAO/tao/Strategies/UIOP_Connector.cpp b/TAO/tao/Strategies/UIOP_Connector.cpp index 26fdd07992a..6a3630adae1 100644 --- a/TAO/tao/Strategies/UIOP_Connector.cpp +++ b/TAO/tao/Strategies/UIOP_Connector.cpp @@ -243,9 +243,14 @@ TAO_UIOP_Connector::make_connection (TAO::Profile_Transport_Resolver *r, return 0; } - if (transport->connection_handler ()->keep_waiting ()) + if (svc_handler->keep_waiting ()) { - svc_handler->add_reference (); + svc_handler->connection_pending (); + } + + if (svc_handler->error_detected ()) + { + svc_handler->cancel_pending_connection (); } // At this point, the connection has be successfully created @@ -278,6 +283,13 @@ TAO_UIOP_Connector::make_connection (TAO::Profile_Transport_Resolver *r, return 0; } + if (svc_handler->error_detected ()) + { + svc_handler->cancel_pending_connection (); + transport->purge_entry(); + return 0; + } + if (transport->is_connected () && transport->wait_strategy ()->register_handler () != 0) { |