summaryrefslogtreecommitdiff
path: root/TAO/tao
diff options
context:
space:
mode:
authorirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-07-07 23:58:34 +0000
committerirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-07-07 23:58:34 +0000
commitf17aa1c26ea86d00ec1cf57cbccdaea829ba0220 (patch)
tree8aaf3418082d4c3b107e2f01eedf0d55095c7ec7 /TAO/tao
parentc5795bf619c5cd394920f8a03d475b60df8d8516 (diff)
downloadATCD-f17aa1c26ea86d00ec1cf57cbccdaea829ba0220.tar.gz
ChangeLogTag: Mon Jul 07 18:00:38 2003 Irfan Pyarali <irfan@oomworks.com>
Diffstat (limited to 'TAO/tao')
-rw-r--r--TAO/tao/Acceptor_Impl.cpp81
-rw-r--r--TAO/tao/Asynch_Reply_Dispatcher_Base.cpp2
-rw-r--r--TAO/tao/Asynch_Reply_Dispatcher_Base.i6
-rw-r--r--TAO/tao/Cache_Entries.cpp15
-rw-r--r--TAO/tao/Connect_Strategy.cpp23
-rw-r--r--TAO/tao/Connect_Strategy.h10
-rw-r--r--TAO/tao/Connection_Handler.cpp412
-rw-r--r--TAO/tao/Connection_Handler.h41
-rw-r--r--TAO/tao/Connection_Handler.inl15
-rw-r--r--TAO/tao/Connector_Impl.cpp9
-rw-r--r--TAO/tao/IIOP_Connection_Handler.cpp60
-rw-r--r--TAO/tao/IIOP_Connection_Handler.h8
-rw-r--r--TAO/tao/IIOP_Connector.cpp321
-rw-r--r--TAO/tao/IIOP_Transport.cpp116
-rw-r--r--TAO/tao/IIOP_Transport.h15
-rw-r--r--TAO/tao/Invocation.cpp13
-rw-r--r--TAO/tao/LF_CH_Event.cpp14
-rw-r--r--TAO/tao/LF_CH_Event.h22
-rw-r--r--TAO/tao/LF_Connect_Strategy.cpp5
-rw-r--r--TAO/tao/LF_Event.h3
-rw-r--r--TAO/tao/Makefile.bor1
-rw-r--r--TAO/tao/Makefile.tao293
-rw-r--r--TAO/tao/Notify_Handler.cpp116
-rw-r--r--TAO/tao/Notify_Handler.h99
-rw-r--r--TAO/tao/PortableServer/AMH_Response_Handler.cpp23
-rw-r--r--TAO/tao/Strategies/DIOP_Acceptor.cpp15
-rw-r--r--TAO/tao/Strategies/DIOP_Connection_Handler.cpp85
-rw-r--r--TAO/tao/Strategies/DIOP_Connection_Handler.h6
-rw-r--r--TAO/tao/Strategies/DIOP_Connector.cpp24
-rw-r--r--TAO/tao/Strategies/DIOP_Transport.cpp199
-rw-r--r--TAO/tao/Strategies/DIOP_Transport.h21
-rw-r--r--TAO/tao/Strategies/SCIOP_Connection_Handler.cpp51
-rw-r--r--TAO/tao/Strategies/SCIOP_Connection_Handler.h11
-rw-r--r--TAO/tao/Strategies/SCIOP_Connector.cpp281
-rw-r--r--TAO/tao/Strategies/SCIOP_Transport.cpp110
-rw-r--r--TAO/tao/Strategies/SCIOP_Transport.h22
-rw-r--r--TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp51
-rw-r--r--TAO/tao/Strategies/SHMIOP_Connection_Handler.h6
-rw-r--r--TAO/tao/Strategies/SHMIOP_Connector.cpp116
-rw-r--r--TAO/tao/Strategies/SHMIOP_Transport.cpp54
-rw-r--r--TAO/tao/Strategies/SHMIOP_Transport.h15
-rw-r--r--TAO/tao/Strategies/UIOP_Connection_Handler.cpp57
-rw-r--r--TAO/tao/Strategies/UIOP_Connection_Handler.h6
-rw-r--r--TAO/tao/Strategies/UIOP_Connector.cpp173
-rw-r--r--TAO/tao/Strategies/UIOP_Transport.cpp55
-rw-r--r--TAO/tao/Strategies/UIOP_Transport.h15
-rw-r--r--TAO/tao/TAO.dsp8
-rw-r--r--TAO/tao/TAO_Static.dsp8
-rw-r--r--TAO/tao/Thread_Lane_Resources.cpp55
-rw-r--r--TAO/tao/Thread_Per_Connection_Handler.cpp6
-rw-r--r--TAO/tao/Transport.cpp417
-rw-r--r--TAO/tao/Transport.h187
-rw-r--r--TAO/tao/Transport.inl25
-rw-r--r--TAO/tao/Transport_Cache_Manager.cpp38
-rw-r--r--TAO/tao/Transport_Cache_Manager.h22
-rw-r--r--TAO/tao/Transport_Cache_Manager.inl5
-rw-r--r--TAO/tao/Wait_On_Read.cpp6
-rw-r--r--TAO/tao/tao.mpc1
58 files changed, 1330 insertions, 2544 deletions
diff --git a/TAO/tao/Acceptor_Impl.cpp b/TAO/tao/Acceptor_Impl.cpp
index d290d2f4157..dfd5849f1b0 100644
--- a/TAO/tao/Acceptor_Impl.cpp
+++ b/TAO/tao/Acceptor_Impl.cpp
@@ -87,6 +87,9 @@ template <class SVC_HANDLER> int
TAO_Concurrency_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *sh,
void *arg)
{
+ // Here the service handler has been created and the new connection
+ // has been accepted. #REFCOUNT# is one at this point.
+
if (this->ACE_Concurrency_Strategy<SVC_HANDLER>::activate_svc_handler (sh,
arg) == -1)
return -1;
@@ -94,31 +97,93 @@ TAO_Concurrency_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *sh,
// The service handler has been activated. Now cache the handler.
if (sh->add_transport_to_cache () == -1)
{
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("(%P|%t) Could not add the handler to Cache \n")));
+ // Adding to the cache fails, close the handler.
+ sh->close ();
+
+ // #REFCOUNT# is zero at this point.
+
+ if (TAO_debug_level > 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) Could not add the handler to Cache \n")));
+ }
+
+ return -1;
}
+ // Registration with cache is successful, #REFCOUNT# is two at this
+ // point.
+
TAO_Server_Strategy_Factory *f =
this->orb_core_->server_factory ();
- // thread-per-connection concurrency model
+ int result = 0;
+ // Do we need to create threads?
if (f->activate_server_connections ())
{
+ // Thread-per-connection concurrency model
TAO_Thread_Per_Connection_Handler *tpch = 0;
ACE_NEW_RETURN (tpch,
TAO_Thread_Per_Connection_Handler (sh),
-1);
- return tpch->activate (f->server_connection_thread_flags (),
- f->server_connection_thread_count ());
+ result = tpch->activate (f->server_connection_thread_flags (),
+ f->server_connection_thread_count ());
+ }
+ else
+ {
+ // Otherwise, it is the reactive concurrency model. We may want
+ // to register ourselves with the reactor. Call the register
+ // handler on the transport.
+ result =
+ sh->transport ()->register_handler ();
}
+ if (result != -1)
+ {
+ // Activation/registration successful: the handler has been
+ // registered with either the Reactor or the
+ // Thread-per-Connection_Handler, and the Transport Cache.
+ // #REFCOUNT# is three at this point.
+
+ // We can let go of our reference.
+ sh->transport ()->remove_reference ();
+ }
+ else
+ {
+ // Activation/registration failure. #REFCOUNT# is two at this
+ // point.
+
+ // Remove from cache.
+ sh->transport ()->purge_entry ();
+
+ // #REFCOUNT# is one at this point.
+
+ // Close handler.
+ sh->close ();
+
+ // #REFCOUNT# is zero at this point.
+
+ if (TAO_debug_level > 0)
+ {
+ const char *error = 0;
+ if (f->activate_server_connections ())
+ error = "could not activate new connection";
+ else
+ error = "could not register new connection in the reactor";
+
+ ACE_ERROR ((LM_ERROR,
+ "TAO (%P|%t) - Concurrency_Strategy::activate_svc_handler, "
+ "%s\n", error));
+ }
+
+ return -1;
+ }
- // reactive concurrency model. We may want to register ourselves
- // with the reactor. Call the register handler on the transport.
- return sh->transport ()->register_handler ();
+ // Success: #REFCOUNT# is two at this point.
+ return result;
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/TAO/tao/Asynch_Reply_Dispatcher_Base.cpp b/TAO/tao/Asynch_Reply_Dispatcher_Base.cpp
index 21439f66a2a..47b6934cf0c 100644
--- a/TAO/tao/Asynch_Reply_Dispatcher_Base.cpp
+++ b/TAO/tao/Asynch_Reply_Dispatcher_Base.cpp
@@ -39,7 +39,7 @@ TAO_Asynch_Reply_Dispatcher_Base::~TAO_Asynch_Reply_Dispatcher_Base (void)
if (this->transport_ != 0)
{
this->transport_->idle_after_reply ();
- TAO_Transport::release (this->transport_);
+ this->transport_->remove_reference ();
}
}
diff --git a/TAO/tao/Asynch_Reply_Dispatcher_Base.i b/TAO/tao/Asynch_Reply_Dispatcher_Base.i
index 2de4ec8c3ea..232f938f7ff 100644
--- a/TAO/tao/Asynch_Reply_Dispatcher_Base.i
+++ b/TAO/tao/Asynch_Reply_Dispatcher_Base.i
@@ -4,9 +4,11 @@ ACE_INLINE void
TAO_Asynch_Reply_Dispatcher_Base::transport (TAO_Transport *t)
{
if (this->transport_ != 0) {
- TAO_Transport::release (this->transport_);
+ this->transport_->remove_reference ();
}
- this->transport_ = TAO_Transport::_duplicate (t);
+
+ this->transport_ = t;
+ this->transport_->add_reference ();
}
diff --git a/TAO/tao/Cache_Entries.cpp b/TAO/tao/Cache_Entries.cpp
index df610a378f6..4e3ed2de940 100644
--- a/TAO/tao/Cache_Entries.cpp
+++ b/TAO/tao/Cache_Entries.cpp
@@ -11,14 +11,16 @@
ACE_RCSID(tao, Cache_Entries, "$Id$")
TAO_Cache_IntId::TAO_Cache_IntId (TAO_Transport *transport)
- : transport_ (TAO_Transport::_duplicate (transport)),
+ : transport_ (transport),
recycle_state_ (ACE_RECYCLABLE_UNKNOWN)
{
+ transport->add_reference ();
}
TAO_Cache_IntId::~TAO_Cache_IntId (void)
{
- TAO_Transport::release (this->transport_);
+ if (this->transport_)
+ this->transport_->remove_reference ();
}
TAO_Cache_IntId&
@@ -28,9 +30,12 @@ TAO_Cache_IntId::operator= (const TAO_Cache_IntId &rhs)
{
this->recycle_state_ = rhs.recycle_state_;
- TAO_Transport* old_transport = this->transport_;
- this->transport_ = TAO_Transport::_duplicate (rhs.transport_);
- TAO_Transport::release (old_transport);
+ TAO_Transport *old_transport = this->transport_;
+ this->transport_ = rhs.transport_;
+ if (this->transport_)
+ this->transport_->add_reference ();
+ if (old_transport)
+ old_transport->remove_reference ();
}
return *this;
diff --git a/TAO/tao/Connect_Strategy.cpp b/TAO/tao/Connect_Strategy.cpp
index f0cd072677f..8baa2aba950 100644
--- a/TAO/tao/Connect_Strategy.cpp
+++ b/TAO/tao/Connect_Strategy.cpp
@@ -15,26 +15,3 @@ TAO_Connect_Strategy::TAO_Connect_Strategy (TAO_ORB_Core *orb_core)
TAO_Connect_Strategy::~TAO_Connect_Strategy (void)
{
}
-
-int
-TAO_Connect_Strategy::post_failed_connect (TAO_Connection_Handler *ch,
- int is_finalized)
-{
- int ref = 0;
- if (!is_finalized)
- {
- // We need to do this here else we will leak memory. We cannot call
- // close_connection () for the following reasons
- // . the event_handlers get_handle () will return an
- // ACE_INVALID_HANDLE as things havent been shutdown
- // properly.
- // . We cannot relax the conditions since the conditions are right
- // for other natural cases ie. LF
- // Under these odd circumstances we need to take care of things
- // ourseleves
- ch->transport (0);
- ref = ch->decr_refcount ();
- }
-
- return ref;
-}
diff --git a/TAO/tao/Connect_Strategy.h b/TAO/tao/Connect_Strategy.h
index 3c57d269105..304f6f50201 100644
--- a/TAO/tao/Connect_Strategy.h
+++ b/TAO/tao/Connect_Strategy.h
@@ -66,16 +66,6 @@ public:
virtual int wait (TAO_Connection_Handler *ch,
ACE_Time_Value *val) = 0;
- /// Cleanup in case of failed connect.
- /*
- * Do any left over memory management or related things after
- * the connect failed. The argument @c is_successful indicates
- * whether the connection handler had undergone a sucessful state
- * completion or not.
- */
- virtual int post_failed_connect (TAO_Connection_Handler *ch,
- int is_finalized = 1);
-
protected:
/// Cached copy of the ORB core pointer
TAO_ORB_Core *orb_core_;
diff --git a/TAO/tao/Connection_Handler.cpp b/TAO/tao/Connection_Handler.cpp
index b70d618860b..35b48c1f9d1 100644
--- a/TAO/tao/Connection_Handler.cpp
+++ b/TAO/tao/Connection_Handler.cpp
@@ -24,14 +24,10 @@ TAO_Connection_Handler::TAO_Connection_Handler (TAO_ORB_Core *orb_core)
: orb_core_ (orb_core)
, transport_ (0)
, tss_resources_ (orb_core->get_tss_resources ())
- , reference_count_ (1)
{
// @@todo: We need to have a distinct option/ method in the resource
// factory for this and TAO_Transport.
- this->refcount_lock_ =
- this->orb_core_->resource_factory ()->create_cached_connection_lock ();
-
this->lock_ =
this->orb_core_->resource_factory ()->create_cached_connection_lock ();
@@ -40,15 +36,20 @@ TAO_Connection_Handler::TAO_Connection_Handler (TAO_ORB_Core *orb_core)
this->state_changed (TAO_LF_Event::LFS_CONNECTION_WAIT);
}
-
TAO_Connection_Handler::~TAO_Connection_Handler (void)
{
- ACE_ASSERT(this->transport_ == 0);
- ACE_ASSERT(this->reference_count_ == 0);
+ int result =
+ this->release_os_resources ();
+
+ if (result == -1 && TAO_debug_level)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "TAO (%P|%t) - Connection_Handler::~Connection_Handler,"
+ "release_os_resources() failed %p\n"));
+ }
// @@ TODO Use auto_ptr<>
delete this->lock_;
- delete this->refcount_lock_;
}
@@ -126,8 +127,8 @@ TAO_Connection_Handler::svc_i (void)
(void) this->transport ()->update_transport ();
result =
- this->transport ()->handle_input_i (rh,
- max_wait_time);
+ this->transport ()->handle_input (rh,
+ max_wait_time);
if (result == -1 && errno == ETIME)
{
@@ -159,110 +160,17 @@ TAO_Connection_Handler::svc_i (void)
void
TAO_Connection_Handler::transport (TAO_Transport* transport)
{
- // The transport can be reset, but not changed!
- ACE_ASSERT(this->transport_ == 0 || transport == 0);
-
- TAO_Transport * tmp = 0;
- {
- // Make the change atomic
- ACE_GUARD (ACE_Lock, ace_mon, *this->lock_);
- tmp = this->transport_;
- this->transport_ = TAO_Transport::_duplicate (transport);
- }
-
- if (tmp != 0) {
- tmp->connection_handler_closing ();
- TAO_Transport::release (tmp);
- }
-}
-
-long
-TAO_Connection_Handler::incr_refcount (void)
-{
- ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->refcount_lock_, -1);
-
- ACE_ASSERT(this->reference_count_ > 0);
- return ++this->reference_count_;
-}
-
-long
-TAO_Connection_Handler::decr_refcount (void)
-{
- {
- ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->refcount_lock_, -1);
-
- if(--this->reference_count_ > 0)
- return this->reference_count_;
- }
-
- ACE_ASSERT(this->reference_count_ == 0);
-
-
- int r = this->release_os_resources ();
-
- if (r == -1 && TAO_debug_level)
- {
- ACE_ERROR ((LM_ERROR,
- "TAO (%P|%t) - Connection_Handler::"
- "decr_refcount, release_os_resources() failed %p\n"));
- }
-
- delete this;
-
- return 0;
-}
-
-void
-TAO_Connection_Handler::connection_close_wait (void)
-{
- ACE_GUARD (ACE_Lock, ace_mon, *this->lock_);
- this->state_changed (TAO_LF_Event::LFS_CONNECTION_CLOSE_WAIT);
-}
-
-
-
-int
-TAO_Connection_Handler::handle_close_eh (
- ACE_HANDLE handle, unsigned long reactor_mask, ACE_Event_Handler * eh)
-{
- ACE_HANDLE my_handle = eh->get_handle ();
-
- if (TAO_debug_level)
- {
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - Connection_Handler[%d]::handle_close_eh, "
- "(%d, %d)\n",
- my_handle, handle, reactor_mask));
- }
-
- if (this->close_connection () == 0)
- {
- if (TAO_debug_level)
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - Connection_Handler[%d]::"
- "handle_close, connection closing or already closed\n",
- my_handle));
- return 0;
- }
-
- if (TAO_debug_level)
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - Connection_Handler[%d]::"
- "handle_close, connection fully closed\n",
- my_handle));
+ this->transport_ = transport;
- return 0;
+ // Enable reference counting on the event handler.
+ this->transport_->event_handler_i ()->reference_counting_policy ().value
+ (ACE_Event_Handler::Reference_Counting_Policy::ENABLED);
}
int
TAO_Connection_Handler::handle_output_eh (
ACE_HANDLE, ACE_Event_Handler * eh)
{
- // We are going to use the transport object to write data. Just make
- // sure that we have transport objects to proceed. This is
- // perfectly valid assert
- ACE_ASSERT (this->transport () != 0);
-
// Let the transport that it is going to be used
(void) this->transport ()->update_transport ();
@@ -281,7 +189,7 @@ TAO_Connection_Handler::handle_output_eh (
return_value = this->transport ()->handle_output ();
- this->pos_io_hook(return_value);
+ this->pos_io_hook (return_value);
if (return_value != 0)
{
resume_handle.set_flag (TAO_Resume_Handle::TAO_HANDLE_LEAVE_SUSPENDED);
@@ -294,11 +202,6 @@ int
TAO_Connection_Handler::handle_input_eh (
ACE_HANDLE h, ACE_Event_Handler * eh)
{
- // We are going to use the transport object to read data. Just make
- // sure that we have transport objects to proceed. This is
- // perfectly valid assert
- ACE_ASSERT (this->transport () != 0);
-
// Let the transport know that it is used
(void) this->transport ()->update_transport ();
@@ -308,20 +211,13 @@ TAO_Connection_Handler::handle_input_eh (
size_t t_id =
this->transport ()->id ();
-
- // Increase the reference count on the upcall that have passed us.
- //
- // REFCNT: Matches decr_refcount() in this function...
- long refcount = this->incr_refcount ();
- ACE_ASSERT (refcount > 0);
-
if (TAO_debug_level > 6)
{
ACE_HANDLE handle = eh->get_handle();
ACE_DEBUG ((LM_DEBUG,
"TAO (%P|%t) - Connection_Handler[%d]::handle_input, "
- "handle = %d/%d, refcount = %d\n",
- t_id, handle, h, refcount));
+ "handle = %d/%d\n",
+ t_id, handle, h));
}
TAO_Resume_Handle resume_handle (this->orb_core (),
@@ -331,220 +227,114 @@ TAO_Connection_Handler::handle_input_eh (
this->pre_io_hook (return_value);
if (return_value != 0)
- {
- // REFCNT: Matches incr_refcount() at the beginning...
- refcount = this->decr_refcount ();
- ACE_ASSERT (refcount >= 0);
- return return_value;
- }
-
-
- return_value = this->transport ()->handle_input_i (resume_handle);
+ return return_value;
- this->pos_io_hook(return_value);
+ return_value = this->transport ()->handle_input (resume_handle);
- // REFCNT: Matches incr_refcount() at the beginning...
- refcount = this->decr_refcount ();
- ACE_ASSERT (refcount >= 0);
+ this->pos_io_hook (return_value);
if (TAO_debug_level > 6)
{
ACE_HANDLE handle = eh->get_handle ();
ACE_DEBUG ((LM_DEBUG,
"TAO (%P|%t) - Connection_Handler[%d]::handle_input, "
- "handle = %d/%d, refcount = %d, retval = %d\n",
- t_id, handle, h, refcount, return_value));
- }
-
- if (return_value == -1 || refcount == 0)
- {
- // This is really a odd case. We could have a race condition if
- // we dont do this. Looks like this what happens
- // - imagine we have more than 1 server threads
- // - The server has got more than one connection from the
- // clients
- // - The clients make requests and they start dissappearing.
- // - The connections start getting closed
- // - at that point one of the server threads is woken up to
- // and handle_input () is called.
- // - the handle_input sees no data and so is about return a -1.
- // - if the handle is resumed, it looks like the oen more thread
- // gets access to the handle and the handle_input is called by
- // another thread.
- // - at that point of time if the thread returning -1 to the
- // reactor starts closing down the handler, bad things start
- // happening.
- // Looks subtle though. After adding this I dont see anything
- // bad happenin and so let us stick with it...
- resume_handle.set_flag (TAO_Resume_Handle::TAO_HANDLE_LEAVE_SUSPENDED);
+ "handle = %d/%d, retval = %d\n",
+ t_id, handle, h, return_value));
}
return return_value;
}
int
-TAO_Connection_Handler::close_connection_eh (ACE_Event_Handler * eh)
+TAO_Connection_Handler::close_connection_eh (ACE_Event_Handler *eh)
{
- // Perform a double checked locking on the underlying ACE_HANDLE
+ this->transport ()->send_connection_closed_notifications ();
+
+ // Save the ID for debugging messages
ACE_HANDLE handle = eh->get_handle ();
+ size_t id = this->transport ()->id ();
+ if (TAO_debug_level)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) - Connection_Handler[%d]::"
+ "close_connection, purging entry from cache\n",
+ handle));
+ }
+ this->transport ()->purge_entry ();
- // If the handle is ACE_INVALID_HANDLE then there is no work to be
- // done in this function, and we return immediately. Returning 0
- // indicates the caller (handle_close() most likely), that there is
- // no work to be done.
- if (handle == ACE_INVALID_HANDLE)
+ // @@ This seems silly, but if we have no reason to be in the
+ // reactor, then we dont remove ourselves.
+ if (this->transport ()->wait_strategy ()->is_registered ())
{
- return 0;
+ ACE_Reactor *eh_reactor = eh->reactor ();
+
+ // These checks are valid as long as the ORB_Core is not
+ // shutdown. It is good to have these checks and they are valid
+ // for most of the cases. Please see below for exceptions
+ if (this->orb_core_->has_shutdown () == 0)
+ {
+ // The exception when these are not valid is for
+ // RTCORBA. With RTCORBA on, you can threads in different
+ // lanes creating handlers and registering them with reactor
+ // in those respective lanes. These threads could then even
+ // go away leaving the task of reclaiming these resources to
+ // the main thread. For the main thread that takes the
+ // responsibility of finalizing () the lanes and the pools,
+ // the calls and comparison make no sense.
+ ACE_Reactor * reactor =
+ this->transport()->orb_core()->reactor ();
+ ACE_ASSERT (eh_reactor == 0 || eh_reactor == reactor);
+
+ ACE_Reactor * orb_core_reactor = this->orb_core_->reactor ();
+ ACE_ASSERT (reactor == orb_core_reactor);
+
+ if (eh_reactor == 0)
+ eh_reactor = reactor;
+
+ ACE_UNUSED_ARG (orb_core_reactor);
+ }
+
+ // The Reactor must not be null, otherwise something else is
+ // horribly broken.
+ ACE_ASSERT (eh_reactor != 0);
+
+ if (TAO_debug_level)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) - Connection_Handler[%d]::"
+ "close_connection, removing from the reactor\n",
+ handle));
+ }
+
+ eh_reactor->remove_handler (handle,
+ ACE_Event_Handler::ALL_EVENTS_MASK |
+ ACE_Event_Handler::DONT_CALL);
+
+ // Also cancel any timers, we may create those for time-limited
+ // buffering
+ if (TAO_debug_level)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) - Connection_Handler[%d]::"
+ "close_connection, cancel all timers\n",
+ handle));
+ }
+
+ eh_reactor->cancel_timer (eh);
+
+ // @@ This seems silly, the reactor is a much better authority to
+ // find out if a handle is registered...
+ this->transport ()->wait_strategy ()->is_registered (0);
}
- size_t id = 0;
- {
- ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0);
-
- handle = eh->get_handle ();
-
- // Double-checked locking.
- if(handle == ACE_INVALID_HANDLE)
- {
- return 0;
- }
-
- // Before closing the socket we need to remove ourselves from the
- // Reactor. Sounds silly, as supposedly handle_close() was called
- // *BY* the Reactor, but the Reactor calls handle_close() with
- // only the masks implied by the handle_XXX() call that returned
- // -1, and it does *NOT* remove the Event Handler from all masks.
- // Furthermore, this method is also called outside the Reactor
- // event loop, for example, when an I/O error is detected during a
- // write().
-
- // The following assertion is true because:
- //
- //
- // 1) When a connection handler is initialized Transport is not zero
- // and the handle is *NOT* ACE_INVALID_HANDLE.
- // 2) The code here is run only once, if we get to this point the
- // handle was not ACE_INVALID_HANDLE
- // 3) this->transport() is only reset after we run this code
- // successfully
- //
- // Or: for this code to run the handle must have changed state from
- // something valid to ACE_INVALID_HANDLE, and the transport() field
- // will not be changed before that state transition.
- //
- ACE_ASSERT (this->transport () != 0);
-
- // Save the ID for debugging messages
- id = this->transport()->id ();
- if (TAO_debug_level)
- {
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - Connection_Handler[%d]::"
- "close_connection, purging entry from cache\n",
- handle));
- }
- this->transport ()->purge_entry ();
-
- // @@ This seems silly, but if we have no reason to be in the
- // reactor, then we dont remove ourselves.
- if (this->transport ()->wait_strategy ()->is_registered ())
- {
- ACE_Reactor * eh_reactor = eh->reactor ();
-
- // These checks are valid as long as the ORB_Core is not
- // shutdown. It is good to have these checks and they are valid
- // for most of the cases. Please see below for exceptions
- if (this->orb_core_->has_shutdown () == 0)
- {
- // The exception when these are not valid is for RTCORBA. With
- // RTCORBA on, you can threads in different lanes creating
- // handlers and registering them with reactor in those
- // respective lanes. These threads could then even go away
- // leaving the task of reclaiming these resources to the main
- // thread. For the main thread that takes the responsibility
- // of finalizing () the lanes and the pools, the calls and
- // comparison make no sense.
- ACE_Reactor * reactor =
- this->transport()->orb_core()->reactor ();
- ACE_ASSERT (eh_reactor == 0 || eh_reactor == reactor);
-
- ACE_Reactor * orb_core_reactor = this->orb_core_->reactor ();
- ACE_ASSERT (reactor == orb_core_reactor);
-
- if (eh_reactor == 0)
- eh_reactor = reactor;
-
- ACE_UNUSED_ARG (orb_core_reactor);
- }
-
- // The Reactor must not be null, otherwise something else is
- // horribly broken.
- ACE_ASSERT (eh_reactor != 0);
-
- if (TAO_debug_level)
- {
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - Connection_Handler[%d]::"
- "close_connection, removing from the reactor\n",
- handle));
- }
-
- int r =
- eh_reactor->remove_handler (handle,
- (ACE_Event_Handler::ALL_EVENTS_MASK
- | ACE_Event_Handler::DONT_CALL));
- if(r == -1 && TAO_debug_level)
- {
- ACE_ERROR ((LM_ERROR,
- "TAO (%P|%t) - Connection_Handler[%d]::"
- "close_connection, problem in remove_handler (%d)\n",
- handle, r));
- }
-
- // Also cancel any timers, we may create those for time-limited
- // buffering
- if (TAO_debug_level)
- {
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - Connection_Handler[%d]::"
- "close_connection, cancel all timers and refcount [%d]\n",
- handle, reference_count_));
- }
- r = eh_reactor->cancel_timer (eh);
- if (r == -1 && TAO_debug_level)
- {
- ACE_ERROR ((LM_ERROR,
- "TAO (%P|%t) - Connection_Handler[%d]::"
- "close_connection, error cancelling timers\n",
- handle));
- }
-
- // @@ This seems silly, the reactor is a much better authority to
- // find out if a handle is registered...
- this->transport ()->wait_strategy ()->is_registered (0);
- }
-
- this->state_changed (TAO_LF_Event::LFS_CONNECTION_CLOSED);
- }
-
- ACE_ASSERT (this->transport () != 0);
-
- // Signal the transport that we will no longer have
- // a reference to it. This will eventually call
- // TAO_Transport::release ().
- this->transport (0);
-
- // The Reactor (or the Connector) holds an implicit reference.
- // REFCNT: Matches start count
- // REFCNT: only this or handle_input_eh() are called
- long refcount = this->decr_refcount ();
+ this->state_changed (TAO_LF_Event::LFS_CONNECTION_CLOSED);
if (TAO_debug_level)
{
ACE_DEBUG ((LM_DEBUG,
"TAO (%P|%t) - Connection_Handler[%d]::"
- "close_connection, refcount = %d\n",
- id, refcount));
+ "close_connection\n",
+ id));
}
return 1;
diff --git a/TAO/tao/Connection_Handler.h b/TAO/tao/Connection_Handler.h
index 6401e86aca6..9394e52c1ac 100644
--- a/TAO/tao/Connection_Handler.h
+++ b/TAO/tao/Connection_Handler.h
@@ -17,12 +17,12 @@
#include "ace/pre.h"
#include "LF_CH_Event.h"
+#include "ace/Event_Handler.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
-
class TAO_ORB_Core;
class TAO_ORB_Core_TSS_Resources;
class TAO_Transport;
@@ -51,23 +51,23 @@ public:
/// Constructor
TAO_Connection_Handler (TAO_ORB_Core *orb_core);
+ /// Destructor
+ virtual ~TAO_Connection_Handler (void);
+
/// Return the underlying transport object
TAO_Transport *transport (void);
/// Set the underlying transport object
void transport (TAO_Transport* transport);
- /// Is the state final?
- int is_finalized (void);
+ /// Is the handler closed?
+ int is_closed (void);
- /// Increment and decrement the refcount. The object is deleted when
- /// the refcount reaches zero.
- long incr_refcount (void);
- long decr_refcount (void);
+ /// Is the handler open?
+ int is_open (void);
- /// Set the handler in <CODE>LF_EVENT_CONNECTION_CLOSE_WAIT </CODE>
- /// state
- void connection_close_wait (void);
+ /// Is the handler in the process of being connected?
+ int is_connecting (void);
/// Close the underlying connection.
/**
@@ -96,13 +96,6 @@ public:
protected:
- /// Destructor
- /**
- * Protected destructor to enforce proper memory management through
- * the reference counting mechanism.
- */
- virtual ~TAO_Connection_Handler (void);
-
/// Return our TAO_ORB_Core pointer
TAO_ORB_Core *orb_core (void);
@@ -125,11 +118,6 @@ protected:
* place.
*/
- /// Implement the handle_close() callback
- virtual int handle_close_eh (ACE_HANDLE h,
- unsigned long reactor_mask,
- ACE_Event_Handler * eh);
-
/// Implement the handle_output() callback
int handle_output_eh (ACE_HANDLE h, ACE_Event_Handler * eh);
@@ -140,8 +128,7 @@ protected:
/// also Event_Handlers.
int close_connection_eh (ACE_Event_Handler * eh);
- /// Release the OS resources related to this handler, used in
- /// handle_close_eh()
+ /// Release the OS resources related to this handler.
virtual int release_os_resources (void);
/// Pre-invocation hook for I/O operations (handle_input() &
@@ -170,12 +157,6 @@ private:
/// Cached tss resources of the ORB that activated this object.
TAO_ORB_Core_TSS_Resources *tss_resources_;
- /// Pretty obvious
- long reference_count_;
-
- /// Lock for the reference count
- ACE_Lock *refcount_lock_;
-
/// Internal state lock, needs to be separate from the reference
/// count / pending upcalls lock because they interleave.
ACE_Lock * lock_;
diff --git a/TAO/tao/Connection_Handler.inl b/TAO/tao/Connection_Handler.inl
index 7de61103ad9..3562b10159a 100644
--- a/TAO/tao/Connection_Handler.inl
+++ b/TAO/tao/Connection_Handler.inl
@@ -20,23 +20,20 @@ TAO_Connection_Handler::transport (void)
return this->transport_;
}
-#if 0
-// NOTE: Not used
ACE_INLINE int
-TAO_Connection_Handler::is_connect_complete (void) const
+TAO_Connection_Handler::is_closed (void)
{
- return this->successful () || this->error_detected ();
+ return this->state_ == TAO_LF_Event::LFS_CONNECTION_CLOSED;
}
ACE_INLINE int
-TAO_Connection_Handler::is_connect_successful (void) const
+TAO_Connection_Handler::is_open (void)
{
- return (this->error_detected () == 0);
+ return this->state_ == TAO_LF_Event::LFS_SUCCESS;
}
-#endif /*if 0*/
ACE_INLINE int
-TAO_Connection_Handler::is_finalized (void)
+TAO_Connection_Handler::is_connecting (void)
{
- return this->is_state_final ();
+ return this->state_ == TAO_LF_Event::LFS_CONNECTION_WAIT;
}
diff --git a/TAO/tao/Connector_Impl.cpp b/TAO/tao/Connector_Impl.cpp
index a4bb4cee8c0..577427054c0 100644
--- a/TAO/tao/Connector_Impl.cpp
+++ b/TAO/tao/Connector_Impl.cpp
@@ -39,12 +39,11 @@ TAO_Connect_Creation_Strategy<SVC_HANDLER>::make_svc_handler (SVC_HANDLER *&sh)
this->arg_),
-1);
- // Add a reference count. Why is this needed? We need this to make
- // sure that the connector doesnt delete this handler when we are
- // waiting for non-blocking connects to complete.
+ // We add to the #REFCOUNT# since the Connector needs this. See
+ // Connector::make_connection() for details.
+ sh->add_reference ();
- // REFCNT: matches decr_refcount() in XXX_Connector::make_connection()
- sh->incr_refcount ();
+ // At this point, the #REFCOUNT# is two.
return 0;
}
diff --git a/TAO/tao/IIOP_Connection_Handler.cpp b/TAO/tao/IIOP_Connection_Handler.cpp
index 9ea68fc555f..46c61744cdb 100644
--- a/TAO/tao/IIOP_Connection_Handler.cpp
+++ b/TAO/tao/IIOP_Connection_Handler.cpp
@@ -34,7 +34,7 @@ TAO_IIOP_Connection_Handler::TAO_IIOP_Connection_Handler (ACE_Thread_Manager *t)
// 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 (0);
}
@@ -54,7 +54,6 @@ TAO_IIOP_Connection_Handler::TAO_IIOP_Connection_Handler (
// store this pointer (indirectly increment ref count)
this->transport (specific_transport);
- TAO_Transport::release (specific_transport);
}
TAO_IIOP_Connection_Handler::TAO_IIOP_Connection_Handler (TAO_ORB_Core *orb_core,
@@ -67,12 +66,11 @@ TAO_IIOP_Connection_Handler::TAO_IIOP_Connection_Handler (TAO_ORB_Core *orb_core
{
}
-
TAO_IIOP_Connection_Handler::~TAO_IIOP_Connection_Handler (void)
{
+ delete this->transport ();
}
-
int
TAO_IIOP_Connection_Handler::open_handler (void *v)
{
@@ -134,7 +132,6 @@ TAO_IIOP_Connection_Handler::open (void*)
return -1;
}
-
if (TAO_debug_level > 0)
{
ACE_TCHAR client[MAXHOSTNAMELEN + 16];
@@ -158,10 +155,6 @@ TAO_IIOP_Connection_Handler::open (void*)
return 0;
}
-
-
-
-
int
TAO_IIOP_Connection_Handler::resume_handler (void)
{
@@ -177,26 +170,63 @@ TAO_IIOP_Connection_Handler::close_connection (void)
int
TAO_IIOP_Connection_Handler::handle_input (ACE_HANDLE h)
{
- return this->handle_input_eh (h, this);
+ int result =
+ this->handle_input_eh (h, this);
+
+ if (result == -1)
+ {
+ this->close_connection ();
+ return 0;
+ }
+
+ return result;
}
int
TAO_IIOP_Connection_Handler::handle_output (ACE_HANDLE handle)
{
- return this->handle_output_eh (handle, this);
+ int result =
+ this->handle_output_eh (handle, this);
+
+ if (result == -1)
+ {
+ this->close_connection ();
+ return 0;
+ }
+
+ return result;
+}
+
+int
+TAO_IIOP_Connection_Handler::handle_timeout (const ACE_Time_Value &,
+ const void *)
+{
+ // We don't use this upcall for I/O. This is only used by the
+ // Connector to indicate that the connection timedout. Therefore,
+ // we should call close().
+ return this->close ();
}
int
-TAO_IIOP_Connection_Handler::handle_close (ACE_HANDLE handle,
- ACE_Reactor_Mask rm)
+TAO_IIOP_Connection_Handler::handle_close (ACE_HANDLE,
+ ACE_Reactor_Mask)
{
- return this->handle_close_eh (handle, rm, this);
+ ACE_ASSERT (0);
+ return 0;
+}
+
+int
+TAO_IIOP_Connection_Handler::close (u_long)
+{
+ this->state_changed (TAO_LF_Event::LFS_CONNECTION_CLOSED);
+ this->transport ()->remove_reference ();
+ return 0;
}
int
TAO_IIOP_Connection_Handler::release_os_resources (void)
{
- return this->peer().close ();
+ return this->peer ().close ();
}
int
diff --git a/TAO/tao/IIOP_Connection_Handler.h b/TAO/tao/IIOP_Connection_Handler.h
index fe7d26c3881..57a562fd0ea 100644
--- a/TAO/tao/IIOP_Connection_Handler.h
+++ b/TAO/tao/IIOP_Connection_Handler.h
@@ -83,7 +83,7 @@ class TAO_Export TAO_IIOP_Connection_Handler : public TAO_IIOP_SVC_HANDLER,
public:
- TAO_IIOP_Connection_Handler (ACE_Thread_Manager* t = 0);
+ TAO_IIOP_Connection_Handler (ACE_Thread_Manager * = 0);
/// Constructor. <arg> parameter is used by the Acceptor to pass the
/// protocol configuration properties for this connection.
@@ -99,6 +99,10 @@ public:
/// connected. Argument is unused.
virtual int open (void *);
+ /// Close called by the Acceptor or Connector when connection
+ /// establishment fails.
+ int close (u_long = 0);
+
//@{
/** @name Event Handler overloads
*/
@@ -107,6 +111,8 @@ public:
virtual int handle_input (ACE_HANDLE);
virtual int handle_output (ACE_HANDLE);
virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask);
+ virtual int handle_timeout (const ACE_Time_Value &current_time,
+ const void *act = 0);
//@}
/// Add ourselves to Cache.
diff --git a/TAO/tao/IIOP_Connector.cpp b/TAO/tao/IIOP_Connector.cpp
index feaaeede5f9..fa3c81b0d21 100644
--- a/TAO/tao/IIOP_Connector.cpp
+++ b/TAO/tao/IIOP_Connector.cpp
@@ -15,25 +15,17 @@
#include "ace/Strategies_T.h"
-
ACE_RCSID (TAO,
IIOP_Connector,
"$Id$")
-
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class TAO_Connect_Concurrency_Strategy<TAO_IIOP_Connection_Handler>;
template class TAO_Connect_Creation_Strategy<TAO_IIOP_Connection_Handler>;
template class ACE_Strategy_Connector<TAO_IIOP_Connection_Handler, ACE_SOCK_CONNECTOR>;
template class ACE_Connect_Strategy<TAO_IIOP_Connection_Handler, ACE_SOCK_CONNECTOR>;
template class ACE_Connector<TAO_IIOP_Connection_Handler, ACE_SOCK_CONNECTOR>;
-template class ACE_Svc_Tuple<TAO_IIOP_Connection_Handler>;
-
-template class ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<TAO_IIOP_Connection_Handler> *, TAO_SYNCH_RW_MUTEX>;
-template class ACE_Map_Iterator_Base<ACE_HANDLE, ACE_Svc_Tuple<TAO_IIOP_Connection_Handler> *, TAO_SYNCH_RW_MUTEX>;
-template class ACE_Map_Entry<ACE_HANDLE,ACE_Svc_Tuple<TAO_IIOP_Connection_Handler>*>;
-template class ACE_Map_Iterator<ACE_HANDLE,ACE_Svc_Tuple<TAO_IIOP_Connection_Handler>*,TAO_SYNCH_RW_MUTEX>;
-template class ACE_Map_Reverse_Iterator<ACE_HANDLE,ACE_Svc_Tuple<TAO_IIOP_Connection_Handler>*,TAO_SYNCH_RW_MUTEX>;
+template class ACE_NonBlocking_Connect_Handler<TAO_IIOP_Connection_Handler>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
@@ -42,17 +34,10 @@ template class ACE_Map_Reverse_Iterator<ACE_HANDLE,ACE_Svc_Tuple<TAO_IIOP_Connec
#pragma instantiate ACE_Strategy_Connector<TAO_IIOP_Connection_Handler, ACE_SOCK_CONNECTOR>
#pragma instantiate ACE_Connect_Strategy<TAO_IIOP_Connection_Handler, ACE_SOCK_CONNECTOR>
#pragma instantiate ACE_Connector<TAO_IIOP_Connection_Handler, ACE_SOCK_CONNECTOR>
-#pragma instantiate ACE_Svc_Tuple<TAO_IIOP_Connection_Handler>
-
-#pragma instantiate ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<TAO_IIOP_Connection_Handler> *, TAO_SYNCH_RW_MUTEX>
-#pragma instantiate ACE_Map_Iterator_Base<ACE_HANDLE, ACE_Svc_Tuple<TAO_IIOP_Connection_Handler> *, TAO_SYNCH_RW_MUTEX>
-#pragma instantiate ACE_Map_Entry<ACE_HANDLE,ACE_Svc_Tuple<TAO_IIOP_Connection_Handler>*>
-#pragma instantiate ACE_Map_Iterator<ACE_HANDLE,ACE_Svc_Tuple<TAO_IIOP_Connection_Handler>*,TAO_SYNCH_RW_MUTEX>
-#pragma instantiate ACE_Map_Reverse_Iterator<ACE_HANDLE,ACE_Svc_Tuple<TAO_IIOP_Connection_Handler>*,TAO_SYNCH_RW_MUTEX>
+#pragma instantiate ACE_NonBlocking_Connect_Handler<TAO_IIOP_Connection_Handler>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
-
TAO_IIOP_Connector::TAO_IIOP_Connector (CORBA::Boolean flag)
: TAO_Connector (IOP::TAG_INTERNET_IOP),
lite_flag_ (flag),
@@ -154,130 +139,214 @@ TAO_IIOP_Connector::make_connection (TAO_GIOP_Invocation *invocation,
TAO_IIOP_Endpoint *iiop_endpoint =
this->remote_endpoint (desc->endpoint ());
- if (iiop_endpoint == 0)
- return -1;
-
- const ACE_INET_Addr &remote_address =
- iiop_endpoint->object_addr ();
-
- if (TAO_debug_level > 2)
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - IIOP_Connector::make_connection, "
- "to <%s:%d>\n",
- iiop_endpoint->host(), iiop_endpoint->port()));
-
- // Get the right synch options
- ACE_Synch_Options synch_options;
-
- this->active_connect_strategy_->synch_options (max_wait_time,
- synch_options);
-
- TAO_IIOP_Connection_Handler *svc_handler = 0;
-
- // Active connect
- int result = this->base_connector_.connect (svc_handler,
- remote_address,
- synch_options);
-
-
- if (result == -1 && errno == EWOULDBLOCK)
- {
- if (TAO_debug_level > 2)
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - IIOP_Connector::make_connection, "
- "going to wait for connection completion on local"
- "handle [%d]\n",
- svc_handler->get_handle ()));
-
- result =
- this->active_connect_strategy_->wait (svc_handler,
- max_wait_time);
-
- if (TAO_debug_level > 2)
- {
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - IIOP_Connector::make_connection"
- "wait done for handle[%d], result = %d\n",
- svc_handler->get_handle (), result));
- }
-
- }
-
- int status =
- svc_handler->is_finalized ();
-
- // Reduce the refcount to the svc_handler that we have. The
- // increment to the handler is done in make_svc_handler (). Now
- // that we dont need the reference to it anymore we can decrement
- // the refcount whether the connection is successful ot not.
-
- // REFCNT: Matches with TAO_Connect_Strategy<>::make_svc_handler()
- long refcount = svc_handler->decr_refcount ();
+ if (iiop_endpoint == 0)
+ return -1;
- ACE_ASSERT (refcount >= 0);
+ const ACE_INET_Addr &remote_address =
+ iiop_endpoint->object_addr ();
+
+ if (TAO_debug_level > 2)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) - IIOP_Connector::make_connection, "
+ "to <%s:%d>\n",
+ iiop_endpoint->host(), iiop_endpoint->port()));
+
+ // Get the right synch options
+ ACE_Synch_Options synch_options;
+
+ this->active_connect_strategy_->synch_options (max_wait_time,
+ synch_options);
+
+ TAO_IIOP_Connection_Handler *svc_handler = 0;
+
+ // Connect.
+ int result =
+ this->base_connector_.connect (svc_handler,
+ remote_address,
+ synch_options);
+
+ // The connect() method creates the service handler and bumps the
+ // #REFCOUNT# up one extra. There are three possibilities from
+ // calling connect(): (a) connection succeeds immediately - in this
+ // case, the #REFCOUNT# on the handler is two; (b) connection
+ // completion is pending - in this case, the #REFCOUNT# on the
+ // handler is also two; (c) connection fails immediately - in this
+ // case, the #REFCOUNT# on the handler is one since close() gets
+ // called on the handler.
+ //
+ // The extra reference count in
+ // TAO_Connect_Creation_Strategy::make_svc_handler() is needed in
+ // the case when connection completion is pending and we are going
+ // to wait on a variable in the handler to changes, signifying
+ // success or failure. Note, that this increment cannot be done
+ // once the connect() returns since this might be too late if
+ // another thread pick up the completion and potentially deletes the
+ // handler before we get a chance to increment the reference count.
+
+ // No immediate result. Wait for completion.
+ if (result == -1 && errno == EWOULDBLOCK)
+ {
+ if (TAO_debug_level > 2)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) - IIOP_Connector::make_connection, "
+ "going to wait for connection completion on local"
+ "handle [%d]\n",
+ svc_handler->get_handle ()));
+
+ // Wait for connection completion. No need to specify timeout
+ // to wait() since the correct timeout was passed to the
+ // Connector. The Connector will close the handler in the case
+ // of timeouts, so the event will complete (either success or
+ // failure) within timeout.
+ result =
+ this->active_connect_strategy_->wait (svc_handler,
+ 0);
+
+ if (TAO_debug_level > 2)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) - IIOP_Connector::make_connection"
+ "wait done for handle[%d], result = %d\n",
+ svc_handler->get_handle (), result));
+ }
+
+ // There are three possibilities when wait() returns: (a)
+ // connection succeeded; (b) connection failed; (c) wait()
+ // failed because of some other error. It is easy to deal with
+ // (a) and (b). (c) is tricky since the connection is still
+ // pending and may get completed by some other thread. The
+ // following code deals with (c).
+
+ // Check if the handler has been closed.
+ int closed =
+ svc_handler->is_closed ();
+
+ // In case of failures and close() has not be called.
+ if (result == -1 &&
+ !closed)
+ {
+ // First, cancel from connector.
+ this->base_connector_.cancel (svc_handler);
+
+ // Double check to make sure the handler has not been closed
+ // yet. This double check is required to ensure that the
+ // connection handler was not closed yet by some other
+ // thread since it was still registered with the connector.
+ // Once connector.cancel() has been processed, we are
+ // assured that the connector will no longer open/close this
+ // handler.
+ closed =
+ svc_handler->is_closed ();
+
+ // If closed, there is nothing to do here. If not closed,
+ // it was either opened or is still pending.
+ if (!closed)
+ {
+ // Check if the handler has been opened.
+ int open =
+ svc_handler->is_open ();
+
+ // Some other thread was able to open the handler even
+ // though wait failed for this thread.
+ if (open)
+ // Overwrite <result>.
+ result = 0;
+ else
+ {
+ // Assert that it is still connecting.
+ ACE_ASSERT (svc_handler->is_connecting ());
+
+ // Force close the handler now.
+ svc_handler->close ();
+ }
+ }
+ }
+ }
- ACE_UNUSED_ARG (refcount);
+ // Irrespective of success or failure, remove the extra #REFCOUNT#.
+ svc_handler->remove_reference ();
- if (result == -1)
- {
- // Give users a clue to the problem.
- if (TAO_debug_level)
- {
- ACE_DEBUG ((LM_ERROR,
- "TAO (%P|%t) - IIOP_Connector::make_connection, "
- "connection to <%s:%d> failed (%p)\n",
- iiop_endpoint->host (), iiop_endpoint->port (),
- "errno"));
- }
+ // In case of errors.
+ if (result == -1)
+ {
+ // Give users a clue to the problem.
+ if (TAO_debug_level)
+ {
+ ACE_DEBUG ((LM_ERROR,
+ "TAO (%P|%t) - IIOP_Connector::make_connection, "
+ "connection to <%s:%d> failed (%p)\n",
+ iiop_endpoint->host (), iiop_endpoint->port (),
+ "errno"));
+ }
+
+ return -1;
+ }
- (void) this->active_connect_strategy_->post_failed_connect (svc_handler,
- status);
+ // At this point, the connection has be successfully connected.
+ // #REFCOUNT# is one.
+ if (TAO_debug_level > 2)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) - IIOP_Connector::make_connection, "
+ "new connection to <%s:%d> on Transport[%d]\n",
+ iiop_endpoint->host (), iiop_endpoint->port (),
+ svc_handler->peer ().get_handle ()));
+
+ TAO_Transport *transport =
+ svc_handler->transport ();
+
+ // Add the handler to Cache
+ int retval =
+ this->orb_core ()->lane_resources ().transport_cache ().cache_transport (desc,
+ transport);
+
+ // Failure in adding to cache.
+ if (retval != 0)
+ {
+ // Close the handler.
+ svc_handler->close ();
- return -1;
- }
+ if (TAO_debug_level > 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "TAO (%P|%t) - IIOP_Connector::make_connection, "
+ "could not add the new connection to cache\n"));
+ }
- if (TAO_debug_level > 2)
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - IIOP_Connector::make_connection, "
- "new connection to <%s:%d> on Transport[%d]\n",
- iiop_endpoint->host (), iiop_endpoint->port (),
- svc_handler->peer ().get_handle ()));
+ return -1;
+ }
- TAO_Transport *base_transport =
- TAO_Transport::_duplicate (svc_handler->transport ());
+ // If the wait strategy wants us to be registered with the reactor
+ // then we do so. If registeration is required and it succeeds,
+ // #REFCOUNT# becomes two.
+ retval = transport->wait_strategy ()->register_handler ();
- // Add the handler to Cache
- int retval =
- this->orb_core ()->lane_resources ().transport_cache ().cache_transport (desc,
- base_transport);
+ // Registration failures.
+ if (retval != 0)
+ {
+ // Purge from the connection cache.
+ transport->purge_entry ();
- if (retval != 0 && TAO_debug_level > 0)
- {
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - IIOP_Connector::make_connection, "
- "could not add the new connection to cache\n"));
- }
+ // Close the handler.
+ svc_handler->close ();
- // If the wait strategy wants us to be registered with the reactor
- // then we do so.
- retval = base_transport->wait_strategy ()->register_handler ();
+ if (TAO_debug_level > 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "TAO (%P|%t) - IIOP_Connector::make_connection, "
+ "could not register the new connection in the reactor\n"));
+ }
- if (retval != 0 && TAO_debug_level > 0)
- {
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - IIOP_Connector::make_connection, "
- "could not register the new connection in the reactor\n"));
- }
+ return -1;
+ }
- // Handover the transport pointer to the Invocation class.
- TAO_Transport *&transport = invocation->transport ();
- transport = base_transport;
+ // Handover the transport pointer to the Invocation class.
+ TAO_Transport *&invocation_transport =
+ invocation->transport ();
+ invocation_transport = transport;
- return 0;
+ return 0;
}
-
-
TAO_Profile *
TAO_IIOP_Connector::create_profile (TAO_InputCDR& cdr)
{
diff --git a/TAO/tao/IIOP_Transport.cpp b/TAO/tao/IIOP_Transport.cpp
index 716ec4f1cde..522a04233b6 100644
--- a/TAO/tao/IIOP_Transport.cpp
+++ b/TAO/tao/IIOP_Transport.cpp
@@ -35,13 +35,6 @@ TAO_IIOP_Transport::TAO_IIOP_Transport (TAO_IIOP_Connection_Handler *handler,
, connection_handler_ (handler)
, messaging_object_ (0)
{
- if (connection_handler_ != 0)
- {
- // REFCNT: Matches one of
- // TAO_Transport::connection_handler_close() or
- // TAO_Transport::close_connection_shared.
- this->connection_handler_->incr_refcount();
- }
if (flag)
{
// Use the lite version of the protocol
@@ -58,7 +51,6 @@ TAO_IIOP_Transport::TAO_IIOP_Transport (TAO_IIOP_Connection_Handler *handler,
TAO_IIOP_Transport::~TAO_IIOP_Transport (void)
{
- ACE_ASSERT(this->connection_handler_ == 0);
delete this->messaging_object_;
}
@@ -81,9 +73,9 @@ TAO_IIOP_Transport::messaging_object (void)
}
ssize_t
-TAO_IIOP_Transport::send_i (iovec *iov, int iovcnt,
- size_t &bytes_transferred,
- const ACE_Time_Value *max_wait_time)
+TAO_IIOP_Transport::send (iovec *iov, int iovcnt,
+ size_t &bytes_transferred,
+ const ACE_Time_Value *max_wait_time)
{
ssize_t retval = this->connection_handler_->peer ().sendv (iov, iovcnt,
max_wait_time);
@@ -94,9 +86,9 @@ TAO_IIOP_Transport::send_i (iovec *iov, int iovcnt,
}
ssize_t
-TAO_IIOP_Transport::recv_i (char *buf,
- size_t len,
- const ACE_Time_Value *max_wait_time)
+TAO_IIOP_Transport::recv (char *buf,
+ size_t len,
+ const ACE_Time_Value *max_wait_time)
{
ssize_t n = this->connection_handler_->peer ().recv (buf,
len,
@@ -121,7 +113,6 @@ TAO_IIOP_Transport::recv_i (char *buf,
if (errno == EWOULDBLOCK)
return 0;
-
return -1;
}
@@ -138,32 +129,6 @@ TAO_IIOP_Transport::recv_i (char *buf,
}
int
-TAO_IIOP_Transport::register_handler_i (void)
-{
- if (TAO_debug_level > 4)
- {
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - IIOP_Transport[%d]::register_handler\n",
- this->id ()));
- }
-
- ACE_Reactor *r = this->orb_core_->reactor ();
-
- if (r == this->connection_handler_->reactor ())
- return 0;
-
- // Set the flag in the Connection Handler and in the Wait Strategy
- // @@Maybe we should set these flags after registering with the
- // reactor. What if the registration fails???
- this->ws_->is_registered (1);
-
- // Register the handler with the reactor
- return r->register_handler (this->connection_handler_,
- ACE_Event_Handler::READ_MASK);
-}
-
-
-int
TAO_IIOP_Transport::send_request (TAO_Stub *stub,
TAO_ORB_Core *orb_core,
TAO_OutputCDR &stream,
@@ -261,9 +226,6 @@ TAO_IIOP_Transport::send_message_shared (
{
ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->handler_lock_, -1);
- if (this->check_event_handler_i ("IIOP_Transport::send_message_shared") == -1)
- return -1;
-
if (TAO_debug_level > 6)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("TAO (%P|%t) - ")
@@ -271,8 +233,7 @@ TAO_IIOP_Transport::send_message_shared (
ACE_TEXT ("enable_network_priority = %d\n"),
this->connection_handler_->enable_network_priority ()));
- if (this->connection_handler_ != 0)
- this->connection_handler_->set_dscp_codepoint ();
+ this->connection_handler_->set_dscp_codepoint ();
r = this->send_message_shared_i (stub, message_semantics,
message_block, max_wait_time);
@@ -309,7 +270,6 @@ TAO_IIOP_Transport::generate_request_header (TAO_Operation_Details &opdetails,
// setup
opdetails.modify_request_id (this->bidirectional_flag ());
-
return TAO_Transport::generate_request_header (opdetails,
spec,
msg);
@@ -341,17 +301,6 @@ TAO_IIOP_Transport::tear_listen_point_list (TAO_InputCDR &cdr)
// 1 (i.e., non-originating side)
this->bidirectional_flag (1);
- // Just make sure that the connection handler is sane before we go
- // head and do anything with it.
- ACE_GUARD_RETURN (ACE_Lock,
- ace_mon,
- *this->handler_lock_,
- -1);
-
- if (this->check_event_handler_i ("IIOP_Transport::tear_listen_point_list")
- == -1)
- return -1;
-
return this->connection_handler_->process_listen_point_list (listen_list);
}
@@ -421,28 +370,16 @@ TAO_IIOP_Transport::get_listen_point (
// Get the local address of the connection
ACE_INET_Addr local_addr;
- {
- // Just make sure that the connection handler is sane before we go
- // head and do anything with it.
- ACE_GUARD_RETURN (ACE_Lock,
- ace_mon,
- *this->handler_lock_,
- -1);
-
- if (this->check_event_handler_i ("IIOP_Transport::get_listen_point")
- == -1)
- return -1;
- if (this->connection_handler_->peer ().get_local_addr (local_addr)
- == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("(%P|%t) Could not resolve local ")
- ACE_TEXT ("host address in ")
- ACE_TEXT ("get_listen_point()\n")),
- -1);
- }
- }
+ if (this->connection_handler_->peer ().get_local_addr (local_addr)
+ == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) Could not resolve local ")
+ ACE_TEXT ("host address in ")
+ ACE_TEXT ("get_listen_point()\n")),
+ -1);
+ }
// Note: Looks like there is no point in sending the list of
// endpoints on interfaces on which this connection has not
@@ -484,33 +421,12 @@ TAO_IIOP_Transport::get_listen_point (
return 1;
}
-TAO_Connection_Handler *
-TAO_IIOP_Transport::invalidate_event_handler_i (void)
-{
- TAO_Connection_Handler * eh = this->connection_handler_;
- this->connection_handler_ = 0;
- return eh;
-}
-
void
TAO_IIOP_Transport::update_protocol_properties (int snd_buf_sz,
int rcv_buf_sz,
int no_delay,
int enable_nw_prio)
{
- // Just make sure that the connection handler is sane before we go
- // head and do anything with it.
- ACE_GUARD (ACE_Lock,
- ace_mon,
- *this->handler_lock_);
-
- if (this->check_event_handler_i (
- "IIOP_Transport::update_protocol_properties") == -1)
- return;
-
- /// Making an outbound call holding a lock. This is not suposed to
- /// be done. But it would be dangerous to leave the lock since the
- /// connection handler could dissappear.
this->connection_handler_->update_protocol_properties (
snd_buf_sz,
rcv_buf_sz,
diff --git a/TAO/tao/IIOP_Transport.h b/TAO/tao/IIOP_Transport.h
index 820f7e67e97..1670858789b 100644
--- a/TAO/tao/IIOP_Transport.h
+++ b/TAO/tao/IIOP_Transport.h
@@ -70,20 +70,17 @@ protected:
//@{
virtual ACE_Event_Handler * event_handler_i (void);
- virtual TAO_Connection_Handler * invalidate_event_handler_i (void);
/// Access the underlying messaging object
virtual TAO_Pluggable_Messaging *messaging_object (void);
- virtual ssize_t send_i (iovec *iov, int iovcnt,
- size_t &bytes_transferred,
- const ACE_Time_Value *timeout = 0);
+ virtual ssize_t send (iovec *iov, int iovcnt,
+ size_t &bytes_transferred,
+ const ACE_Time_Value *timeout = 0);
- virtual ssize_t recv_i (char *buf,
- size_t len,
- const ACE_Time_Value *s = 0);
-
- virtual int register_handler_i (void);
+ virtual ssize_t recv (char *buf,
+ size_t len,
+ const ACE_Time_Value *s = 0);
virtual int send_message_shared (TAO_Stub *stub,
int message_semantics,
diff --git a/TAO/tao/Invocation.cpp b/TAO/tao/Invocation.cpp
index 46af924c2ea..9561555ce18 100644
--- a/TAO/tao/Invocation.cpp
+++ b/TAO/tao/Invocation.cpp
@@ -147,7 +147,8 @@ TAO_GIOP_Invocation::~TAO_GIOP_Invocation (void)
/// Ossama remove this when you are done..
if (this->profile_)
this->profile_->_decr_refcnt ();
- TAO_Transport::release (this->transport_);
+ if (this->transport_)
+ this->transport_->remove_reference ();
}
// The public API involves creating an invocation, starting it, filling
@@ -236,13 +237,10 @@ TAO_GIOP_Invocation::perform_call (TAO_Transport_Descriptor_Interface &desc
if (this->transport_ != 0)
{
this->transport_->make_idle ();
+ this->transport_->remove_reference ();
+ this->transport_ = 0;
}
- // Release the transport prior to connecting.
- // In most cases the transport_ will already be zero.
- TAO_Transport::release (this->transport_);
- this->transport_ = 0;
-
// Get a pointer to the connector registry, which might be in
// thread-specific storage, depending on the concurrency model.
TAO_Connector_Registry *conn_reg =
@@ -494,8 +492,7 @@ TAO_GIOP_Invocation::close_connection (void)
// false error reports to applications.
this->transport_->close_connection ();
- // this->transport_->idle ();
- TAO_Transport::release (this->transport_);
+ this->transport_->remove_reference ();
this->transport_ = 0;
this->endpoint_ = 0;
diff --git a/TAO/tao/LF_CH_Event.cpp b/TAO/tao/LF_CH_Event.cpp
index 700871bf95d..907e58821a2 100644
--- a/TAO/tao/LF_CH_Event.cpp
+++ b/TAO/tao/LF_CH_Event.cpp
@@ -48,23 +48,13 @@ TAO_LF_CH_Event::state_changed_i (int new_state)
}
else if (this->state_ == TAO_LF_Event::LFS_SUCCESS)
{
- if (new_state == TAO_LF_Event::LFS_CONNECTION_CLOSE_WAIT
- || new_state == TAO_LF_Event::LFS_CONNECTION_CLOSED)
+ if (new_state == TAO_LF_Event::LFS_CONNECTION_CLOSED)
{
this->prev_state_ = this->state_;
this->state_ = new_state;
}
return;
}
- else if (this->state_ == TAO_LF_Event::LFS_CONNECTION_CLOSE_WAIT)
- {
- if (new_state == TAO_LF_Event::LFS_CONNECTION_CLOSED)
- {
- // Dont reset the previous state. We could have come only
- // from SUCESS. Let that state be preserved.
- this->state_ = new_state;
- }
- }
else if (this->state_ == TAO_LF_Event::LFS_TIMEOUT)
{
if (new_state == TAO_LF_Event::LFS_CONNECTION_CLOSED)
@@ -91,8 +81,6 @@ TAO_LF_CH_Event::error_detected (void) const
{
if (this->prev_state_ == TAO_LF_Event::LFS_CONNECTION_WAIT)
return this->state_ == TAO_LF_Event::LFS_CONNECTION_CLOSED;
- else if (this->prev_state_ == TAO_LF_Event::LFS_CONNECTION_CLOSE_WAIT)
- return (this->state_ != TAO_LF_Event::LFS_CONNECTION_CLOSED);
return 0;
}
diff --git a/TAO/tao/LF_CH_Event.h b/TAO/tao/LF_CH_Event.h
index 587874266b4..bbc54d64363 100644
--- a/TAO/tao/LF_CH_Event.h
+++ b/TAO/tao/LF_CH_Event.h
@@ -75,27 +75,21 @@ private:
*
* LFS_TIMEOUT - The event has timed out.
*
- * LFS_CONNECTION_CLOSE_WAIT - A temporary state before complete
- * connection closure. An event
- * handler in this state is supposed to
- * be getting ready for closure.
- *
* LFS_CONNECTION_CLOSED - The connection was closed since
* an error occured while trying to
* establish connection
*
* Event State Diagram
* -------------------
- * |----> CLOSED <-|
- * | ^ |
- * | | |
- * IDLE ---> CONNECTION_WAIT-| | CLOSE_WAIT
- * | | ^
- * | | |
- * |----> SUCESS--->
+ * |----> CLOSED
+ * | ^
+ * | |
+ * IDLE ---> CONNECTION_WAIT--| |
+ * | |
+ * | |
+ * |----> SUCESS
*
- * Timeouts can occur while waiting for connections or during
- * CLOSE_WAIT state.
+ * Timeouts can occur while waiting for connections.
*
*/
virtual void state_changed_i (int new_state);
diff --git a/TAO/tao/LF_Connect_Strategy.cpp b/TAO/tao/LF_Connect_Strategy.cpp
index b69fe08fc5d..f641d87813a 100644
--- a/TAO/tao/LF_Connect_Strategy.cpp
+++ b/TAO/tao/LF_Connect_Strategy.cpp
@@ -68,11 +68,8 @@ TAO_LF_Connect_Strategy::wait (TAO_Connection_Handler *ch,
max_wait_time);
// Set the result.
- if (!ch->successful () && result != -1)
+ if (ch->error_detected () && result != -1)
result = -1;
- // @@todo We need to use a auto_ptr<>-like object here!
- // TAO_Transport::release(transport);
-
return result;
}
diff --git a/TAO/tao/LF_Event.h b/TAO/tao/LF_Event.h
index c6d919a333a..6dd77f6e23b 100644
--- a/TAO/tao/LF_Event.h
+++ b/TAO/tao/LF_Event.h
@@ -89,9 +89,6 @@ public:
LFS_FAILURE,
/// The event has timed out
LFS_TIMEOUT,
- /// The event is waiting for connection closure. This is a
- /// temporary state
- LFS_CONNECTION_CLOSE_WAIT,
/// The connection was closed.
LFS_CONNECTION_CLOSED
};
diff --git a/TAO/tao/Makefile.bor b/TAO/tao/Makefile.bor
index 0ca53ad1279..6766c6a1b36 100644
--- a/TAO/tao/Makefile.bor
+++ b/TAO/tao/Makefile.bor
@@ -61,7 +61,6 @@ OBJFILES = \
$(OBJDIR)\Default_Collocation_Resolver.obj \
$(OBJDIR)\Connection_Purging_Strategy.obj \
$(OBJDIR)\Connection_Handler.obj \
- $(OBJDIR)\Notify_Handler.obj \
$(OBJDIR)\Thread_Per_Connection_Handler.obj \
$(OBJDIR)\Connector_Impl.obj \
$(OBJDIR)\Connector_Registry.obj \
diff --git a/TAO/tao/Makefile.tao b/TAO/tao/Makefile.tao
index 7f02bc8a0e6..b926ce56dac 100644
--- a/TAO/tao/Makefile.tao
+++ b/TAO/tao/Makefile.tao
@@ -92,7 +92,6 @@ PLUGGABLE_PROTOCOLS_FILES = \
Transport_Connector \
Transport \
Incoming_Message_Queue \
- Notify_Handler \
Resume_Handle \
Profile \
Endpoint \
@@ -1326,7 +1325,7 @@ realclean:
Queued_Message.inl Asynch_Queued_Message.h Flushing_Strategy.h \
Thread_Lane_Resources.h \
Thread_Lane_Resources.i \
- debug.h Resume_Handle.h Resume_Handle.inl Notify_Handler.h \
+ debug.h Resume_Handle.h Resume_Handle.inl \
Codeset_Manager.h \
CONV_FRAMEC.h \
Codeset_Translator_Factory.h \
@@ -1607,296 +1606,6 @@ realclean:
$(ACE_ROOT)/ace/Thread_Manager.i \
ORB_Core.i debug.h
-.obj/Notify_Handler.o .obj/Notify_Handler.so .shobj/Notify_Handler.o .shobj/Notify_Handler.so: Notify_Handler.cpp Notify_Handler.h \
- $(ACE_ROOT)/ace/pre.h \
- TAO_Export.h \
- $(ACE_ROOT)/ace/post.h \
- $(ACE_ROOT)/ace/ace_wchar.h \
- $(ACE_ROOT)/ace/ace_wchar.inl \
- $(ACE_ROOT)/ace/Event_Handler.h \
- $(ACE_ROOT)/ace/ACE_export.h \
- $(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/OS_Dirent.h \
- $(ACE_ROOT)/ace/OS_Export.h \
- $(ACE_ROOT)/ace/OS_Errno.h \
- $(ACE_ROOT)/ace/OS_Errno.inl \
- $(ACE_ROOT)/ace/OS_Dirent.inl \
- $(ACE_ROOT)/ace/OS_String.h \
- $(ACE_ROOT)/ace/Basic_Types.h \
- $(ACE_ROOT)/ace/Basic_Types.i \
- $(ACE_ROOT)/ace/OS_String.inl \
- $(ACE_ROOT)/ace/OS_Memory.h \
- $(ACE_ROOT)/ace/OS_Memory.inl \
- $(ACE_ROOT)/ace/OS_TLI.h \
- $(ACE_ROOT)/ace/OS_TLI.inl \
- $(ACE_ROOT)/ace/Time_Value.h \
- $(ACE_ROOT)/ace/Time_Value.inl \
- $(ACE_ROOT)/ace/Default_Constants.h \
- $(ACE_ROOT)/ace/Global_Macros.h \
- $(ACE_ROOT)/ace/Min_Max.h \
- $(ACE_ROOT)/ace/streams.h \
- $(ACE_ROOT)/ace/Trace.h \
- $(ACE_ROOT)/ace/OS.i \
- $(ACE_ROOT)/ace/Event_Handler.i \
- Connection_Handler.h LF_CH_Event.h LF_Event.h LF_Event.inl \
- LF_Invocation_Event.inl \
- Connection_Handler.inl \
- Transport.h corbafwd.h \
- $(ACE_ROOT)/ace/CDR_Base.h \
- $(ACE_ROOT)/ace/CDR_Base.inl \
- orbconf.h \
- TAO_Export.h \
- corbafwd.i \
- Exception.h \
- corbafwd.h \
- $(ACE_ROOT)/ace/CORBA_macros.h \
- $(ACE_ROOT)/ace/Exception_Macros.h \
- $(ACE_ROOT)/ace/SStringfwd.h \
- $(ACE_ROOT)/ace/iosfwd.h \
- Exception.i \
- Transport_Descriptor_Interface.h \
- Transport_Descriptor_Interface.inl \
- Transport_Cache_Manager.h \
- Cache_Entries.h \
- Transport_Descriptor_Interface.h \
- $(ACE_ROOT)/ace/Recyclable.h \
- $(ACE_ROOT)/ace/Recyclable.inl \
- Cache_Entries.inl \
- $(ACE_ROOT)/ace/Hash_Map_Manager_T.h \
- $(ACE_ROOT)/ace/Functor.h \
- $(ACE_ROOT)/ace/ACE.h \
- $(ACE_ROOT)/ace/Flag_Manip.h \
- $(ACE_ROOT)/ace/Flag_Manip.i \
- $(ACE_ROOT)/ace/Handle_Ops.h \
- $(ACE_ROOT)/ace/Handle_Ops.i \
- $(ACE_ROOT)/ace/Lib_Find.h \
- $(ACE_ROOT)/ace/Lib_Find.i \
- $(ACE_ROOT)/ace/Init_ACE.h \
- $(ACE_ROOT)/ace/Init_ACE.i \
- $(ACE_ROOT)/ace/Sock_Connect.h \
- $(ACE_ROOT)/ace/Sock_Connect.i \
- $(ACE_ROOT)/ace/ACE.i \
- $(ACE_ROOT)/ace/Functor.i \
- $(ACE_ROOT)/ace/Functor_T.h \
- $(ACE_ROOT)/ace/Functor_T.i \
- $(ACE_ROOT)/ace/Functor_T.cpp \
- $(ACE_ROOT)/ace/Log_Msg.h \
- $(ACE_ROOT)/ace/Log_Priority.h \
- $(ACE_ROOT)/ace/OS_Log_Msg_Attributes.h \
- $(ACE_ROOT)/ace/OS_Log_Msg_Attributes.inl \
- $(ACE_ROOT)/ace/Hash_Map_Manager_T.i \
- $(ACE_ROOT)/ace/Synch.h \
- $(ACE_ROOT)/ace/Synch.i \
- $(ACE_ROOT)/ace/Synch_T.h \
- $(ACE_ROOT)/ace/Synch_T.i \
- $(ACE_ROOT)/ace/Thread.h \
- $(ACE_ROOT)/ace/Thread_Adapter.h \
- $(ACE_ROOT)/ace/Base_Thread_Adapter.h \
- $(ACE_ROOT)/ace/Base_Thread_Adapter.inl \
- $(ACE_ROOT)/ace/Thread_Adapter.inl \
- $(ACE_ROOT)/ace/Thread.i \
- $(ACE_ROOT)/ace/Synch_T.cpp \
- $(ACE_ROOT)/ace/Hash_Map_Manager_T.cpp \
- $(ACE_ROOT)/ace/Service_Config.h \
- $(ACE_ROOT)/ace/Unbounded_Queue.h \
- $(ACE_ROOT)/ace/Node.h \
- $(ACE_ROOT)/ace/Node.cpp \
- $(ACE_ROOT)/ace/Unbounded_Queue.inl \
- $(ACE_ROOT)/ace/Unbounded_Queue.cpp \
- $(ACE_ROOT)/ace/Malloc_Base.h \
- $(ACE_ROOT)/ace/Unbounded_Set.h \
- $(ACE_ROOT)/ace/Unbounded_Set.inl \
- $(ACE_ROOT)/ace/Unbounded_Set.cpp \
- $(ACE_ROOT)/ace/SString.h \
- $(ACE_ROOT)/ace/String_Base.h \
- $(ACE_ROOT)/ace/String_Base_Const.h \
- $(ACE_ROOT)/ace/String_Base.i \
- $(ACE_ROOT)/ace/String_Base.cpp \
- $(ACE_ROOT)/ace/Malloc.h \
- $(ACE_ROOT)/ace/Malloc.i \
- $(ACE_ROOT)/ace/Malloc_T.h \
- $(ACE_ROOT)/ace/Malloc_Allocator.h \
- $(ACE_ROOT)/ace/Malloc_Allocator.i \
- $(ACE_ROOT)/ace/Free_List.h \
- $(ACE_ROOT)/ace/Free_List.i \
- $(ACE_ROOT)/ace/Free_List.cpp \
- $(ACE_ROOT)/ace/Malloc_T.i \
- $(ACE_ROOT)/ace/Malloc_T.cpp \
- $(ACE_ROOT)/ace/Memory_Pool.h \
- $(ACE_ROOT)/ace/Signal.h \
- $(ACE_ROOT)/ace/Signal.i \
- $(ACE_ROOT)/ace/Mem_Map.h \
- $(ACE_ROOT)/ace/Mem_Map.i \
- $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \
- $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \
- $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \
- $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \
- $(ACE_ROOT)/ace/Memory_Pool.i \
- $(ACE_ROOT)/ace/Auto_Ptr.h \
- $(ACE_ROOT)/ace/Auto_Ptr.i \
- $(ACE_ROOT)/ace/Auto_Ptr.cpp \
- $(ACE_ROOT)/ace/SString.i \
- $(ACE_ROOT)/ace/XML_Svc_Conf.h \
- $(ACE_ROOT)/ace/Service_Config.i \
- $(ACE_ROOT)/ace/Reactor.h \
- $(ACE_ROOT)/ace/Handle_Set.h \
- $(ACE_ROOT)/ace/Handle_Set.i \
- $(ACE_ROOT)/ace/Timer_Queue.h \
- $(ACE_ROOT)/ace/Timer_Queue_T.h \
- $(ACE_ROOT)/ace/Test_and_Set.h \
- $(ACE_ROOT)/ace/Test_and_Set.i \
- $(ACE_ROOT)/ace/Test_and_Set.cpp \
- $(ACE_ROOT)/ace/Timer_Queue_T.i \
- $(ACE_ROOT)/ace/Timer_Queue_T.cpp \
- $(ACE_ROOT)/ace/Reactor.i \
- $(ACE_ROOT)/ace/Reactor_Impl.h \
- $(ACE_ROOT)/ace/Svc_Conf_Tokens.h \
- Transport_Cache_Manager.inl \
- Transport_Timer.h Incoming_Message_Queue.h Pluggable_Messaging_Utils.h \
- IOP_IORC.h \
- OctetSeqC.h \
- Sequence.h \
- Managed_Types.h \
- Managed_Types.i \
- $(ACE_ROOT)/ace/Message_Block.h \
- $(ACE_ROOT)/ace/Message_Block.i \
- $(ACE_ROOT)/ace/Message_Block_T.h \
- $(ACE_ROOT)/ace/Message_Block_T.i \
- $(ACE_ROOT)/ace/Message_Block_T.cpp \
- Sequence.i \
- Sequence_T.h \
- Sequence_T.i \
- Sequence_T.cpp \
- Typecode.h \
- Exception.h \
- Pseudo_VarOut_T.h \
- Pseudo_VarOut_T.inl \
- Pseudo_VarOut_T.cpp \
- Typecode.i \
- Environment.h \
- Environment.i \
- Seq_Var_T.h \
- Seq_Var_T.inl \
- Seq_Var_T.cpp \
- Seq_Out_T.h \
- Seq_Out_T.inl \
- Seq_Out_T.cpp \
- OctetSeqC.i \
- VarOut_T.h \
- VarOut_T.inl \
- VarOut_T.cpp \
- CDR.h \
- $(ACE_ROOT)/ace/CDR_Stream.h \
- $(ACE_ROOT)/ace/CDR_Stream.i \
- CDR.i \
- IOP_IORC.i \
- Pluggable_Messaging_Utils.i \
- Incoming_Message_Queue.inl Synch_Refcountable.h \
- $(ACE_ROOT)/ace/Refcountable.h \
- $(ACE_ROOT)/ace/Refcountable.inl \
- Synch_Refcountable.inl Transport.inl ORB_Core.h ORB.h ServicesC.h \
- ServicesC.i CORBA_String.h \
- CORBA_String.inl \
- ObjectIdListC.h ObjectIdListC.i objectid.h PolicyC.h CurrentC.h \
- Object.h \
- Policy_ForwardC.h \
- Objref_VarOut_T.h \
- varbase.h \
- Objref_VarOut_T.inl \
- Objref_VarOut_T.cpp \
- Policy_ForwardC.i \
- Object_KeyC.h \
- Object_KeyC.i \
- Object.i \
- Any_Impl_T.h \
- Any.h \
- Any.i \
- Any_Impl_T.inl \
- Any_Impl_T.cpp \
- Marshal.h \
- Marshal.i \
- debug.h \
- CurrentC.i Policy_ForwardC.h Remote_Object_Proxy_Impl.h \
- Object_Proxy_Impl.h \
- PolicyC.i \
- ORB.i \
- Environment.h Policy_Manager.h \
- Policy_Set.h \
- PolicyC.h \
- Policy_Set.i \
- LocalObject.h \
- LocalObject.i \
- Policy_Manager.i \
- Resource_Factory.h \
- $(ACE_ROOT)/ace/Service_Object.h \
- $(ACE_ROOT)/ace/Shared_Object.h \
- $(ACE_ROOT)/ace/Shared_Object.i \
- $(ACE_ROOT)/ace/DLL.h \
- $(ACE_ROOT)/ace/Service_Object.i \
- CONV_FRAMEC.h CONV_FRAMEC.i params.h \
- params.i \
- TAO_Singleton_Manager.h \
- TAO_Singleton_Manager.inl \
- TAO_Singleton.h \
- TAO_Singleton.inl \
- TAO_Singleton.cpp \
- TAO_Singleton.h \
- $(ACE_ROOT)/ace/Object_Manager.h \
- $(ACE_ROOT)/ace/Object_Manager.i \
- $(ACE_ROOT)/ace/Managed_Object.h \
- $(ACE_ROOT)/ace/Managed_Object.i \
- $(ACE_ROOT)/ace/Managed_Object.cpp \
- TAO_Singleton_Manager.h \
- Adapter.h Adapter.i PolicyFactory_Registry.h PortableInterceptorC.h \
- PI_ForwardC.h OctetSeqC.h StringSeqC.h Sequence.h StringSeqC.i \
- PI_ForwardC.i DynamicC.h \
- Any_Dual_Impl_T.h \
- Any_Dual_Impl_T.inl \
- Any_Dual_Impl_T.cpp \
- DynamicC.i Messaging_SyncScopeC.h Messaging_SyncScopeC.i IOPC.h \
- IOP_CodecC.h \
- IOP_CodecC.i \
- IOPC.i PortableInterceptorC.i \
- $(ACE_ROOT)/ace/Map_Manager.h \
- $(ACE_ROOT)/ace/Map_Manager.i \
- $(ACE_ROOT)/ace/Map_Manager.cpp \
- Parser_Registry.h \
- Parser_Registry.i \
- Service_Callbacks.h \
- IOPC.h \
- Service_Callbacks.i \
- Fault_Tolerance_Service.h \
- Fault_Tolerance_Service.i \
- Cleanup_Func_Registry.h \
- $(ACE_ROOT)/ace/Array_Base.h \
- $(ACE_ROOT)/ace/Array_Base.inl \
- $(ACE_ROOT)/ace/Array_Base.cpp \
- Cleanup_Func_Registry.inl Object_Ref_Table.h ObjectKey_Table.h \
- $(ACE_ROOT)/ace/RB_Tree.h \
- $(ACE_ROOT)/ace/RB_Tree.i \
- $(ACE_ROOT)/ace/RB_Tree.cpp \
- Interceptor_List.h Interceptor_List.inl PICurrent.h LocalObject.h \
- PICurrent.inl \
- $(ACE_ROOT)/ace/Thread_Manager.h \
- $(ACE_ROOT)/ace/Thread_Exit.h \
- $(ACE_ROOT)/ace/Thread_Control.h \
- $(ACE_ROOT)/ace/Thread_Control.inl \
- $(ACE_ROOT)/ace/Containers.h \
- $(ACE_ROOT)/ace/Containers.i \
- $(ACE_ROOT)/ace/Containers_T.h \
- $(ACE_ROOT)/ace/Containers_T.i \
- $(ACE_ROOT)/ace/Containers_T.cpp \
- $(ACE_ROOT)/ace/Singleton.h \
- $(ACE_ROOT)/ace/Singleton.i \
- $(ACE_ROOT)/ace/Singleton.cpp \
- $(ACE_ROOT)/ace/Framework_Component.h \
- $(ACE_ROOT)/ace/Framework_Component.inl \
- $(ACE_ROOT)/ace/Framework_Component_T.h \
- $(ACE_ROOT)/ace/Framework_Component_T.inl \
- $(ACE_ROOT)/ace/Framework_Component_T.cpp \
- $(ACE_ROOT)/ace/Thread_Manager.i \
- ORB_Core.i Resume_Handle.h Resume_Handle.inl
-
.obj/Resume_Handle.o .obj/Resume_Handle.so .shobj/Resume_Handle.o .shobj/Resume_Handle.so: Resume_Handle.cpp Resume_Handle.h \
$(ACE_ROOT)/ace/pre.h \
TAO_Export.h \
diff --git a/TAO/tao/Notify_Handler.cpp b/TAO/tao/Notify_Handler.cpp
deleted file mode 100644
index 22011d19569..00000000000
--- a/TAO/tao/Notify_Handler.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-#include "Notify_Handler.h"
-#include "Connection_Handler.h"
-#include "Transport.h"
-#include "ORB_Core.h"
-#include "ace/Malloc_T.h"
-#include "Resume_Handle.h"
-
-ACE_RCSID (tao,
- Notify_Handler,
- "$Id$")
-
-TAO_Notify_Handler::TAO_Notify_Handler (TAO_Transport *t,
- ACE_HANDLE h,
- ACE_Allocator *alloc)
- : ACE_Event_Handler (t->orb_core ()->reactor ()),
- // REFCNT: Matches with Notify_Handler::~Notify_Handler()
- t_ (TAO_Transport::_duplicate (t)),
- h_ (h),
- allocator_ (alloc)
-{
-}
-
-TAO_Notify_Handler::TAO_Notify_Handler (TAO_Connection_Handler *ch,
- ACE_Allocator *alloc)
- : ACE_Event_Handler (ch->transport ()->orb_core ()->reactor ()),
- // REFCNT: Matches with Notify_Handler::~Notify_Handler()
- t_ (ch->transport ()),
- h_ (ACE_INVALID_HANDLE),
- allocator_ (alloc)
-{
- // This constructor should *never* get called, it is just here to
- // for backward comptibility.
- ACE_ASSERT (ch == 0);
-}
-
-TAO_Notify_Handler::~TAO_Notify_Handler (void)
-{
- TAO_Transport::release (this->t_);
-}
-
-
-/*static*/ TAO_Notify_Handler *
-TAO_Notify_Handler::create_handler (TAO_Connection_Handler *,
- ACE_Allocator *)
-{
- return 0;
-}
-
-/*static*/ TAO_Notify_Handler *
-TAO_Notify_Handler::create_handler (TAO_Transport *t,
- ACE_HANDLE h,
- ACE_Allocator *alloc)
-{
- TAO_Notify_Handler *nh = 0;
-
- if (alloc)
- {
- ACE_NEW_MALLOC_RETURN (nh,
- ACE_static_cast (
- TAO_Notify_Handler *,
- alloc->malloc (sizeof (TAO_Notify_Handler))),
- TAO_Notify_Handler (t,
- h,
- alloc),
- 0);
-
- return nh;
- }
-
- return 0;
-}
-
-
-/*static*/ void
-TAO_Notify_Handler::destroy_handler (TAO_Notify_Handler *nh)
-{
- if (nh->allocator_)
- {
- ACE_DES_FREE (nh,
- nh->allocator_->free,
- TAO_Notify_Handler);
- }
-
- return;
-}
-
-
-int
-TAO_Notify_Handler::handle_input (ACE_HANDLE)
-{
- // NOTE: We will do what the Connection_Handler will do with some
- // exceptions though.. Quite a few things done are not required
- // by the Notify_Handler at all.
-
- // Let the transport know that it is used
- (void) this->t_->update_transport ();
-
- TAO_Resume_Handle resume_handle (this->t_->orb_core (),
- this->h_);
-
- // Does return value matter? Not is my opinion.
- (void) this->t_->handle_input_i (resume_handle);
-
- // Yes, we are wantedly returning this so that handle_close () would
- // be called
- return -1;
-}
-
-
-int
-TAO_Notify_Handler::handle_close (ACE_HANDLE /*fd*/,
- ACE_Reactor_Mask /*close_mask*/)
-{
- TAO_Notify_Handler::destroy_handler (this);
- return 0;
-}
diff --git a/TAO/tao/Notify_Handler.h b/TAO/tao/Notify_Handler.h
deleted file mode 100644
index ebf9b9cc4de..00000000000
--- a/TAO/tao/Notify_Handler.h
+++ /dev/null
@@ -1,99 +0,0 @@
-// -*- C++ -*-
-
-//=============================================================================
-/**
- * @file Notify_Handler.h
- *
- * $Id$
- *
- * @author Balchanadran Natarajan <bala@cs.wustl.edu>
- */
-//=============================================================================
-
-#ifndef TAO_NOTIFY_HANDLER_H
-#define TAO_NOTIFY_HANDLER_H
-#include "ace/pre.h"
-
-#include "TAO_Export.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "ace/Event_Handler.h"
-#include "ace/Global_Macros.h"
-
-class TAO_Transport;
-class ACE_Allocator;
-class TAO_Connection_Handler;
-
-/**
- * @class TAO_Notify_Handler
- *
- * @brief Represents the handler used by the notify calls to the
- * reactor within the ORB.
- *
- * Cluttering the *IOP handlers with the job of handling notify calls
- * introduces problems as mentioned in [BUG 1230]. This special
- * handler can help to avoid that problem by splitting the
- * responsibilities between actual connection handling and notify
- * handling that is done underneath the ORB.
- */
-class TAO_Export TAO_Notify_Handler: public ACE_Event_Handler
-{
-public:
-
- /// Dtor
- ~TAO_Notify_Handler (void);
-
- /// NOTE: Needs to be deprecated. Just here for backward
- /// compatibility
- static TAO_Notify_Handler *create_handler (TAO_Connection_Handler *ch,
- ACE_Allocator *alloc);
-
- /// Static method to create an instance of this object in the
- /// memory pool
- static TAO_Notify_Handler *create_handler (TAO_Transport *t,
- ACE_HANDLE h,
- ACE_Allocator *alloc);
-
- /// Static method to destroy an instance of this object
- static void destroy_handler (TAO_Notify_Handler *nh);
-
- /// The standard handle_input method, it just redirects to the
- /// connection handler
- virtual int handle_input (ACE_HANDLE fd);
- virtual int handle_close (ACE_HANDLE fd,
- ACE_Reactor_Mask close_mask);
-
-protected:
-
- /// NOTE: Needs to be deprecated.
- TAO_Notify_Handler (TAO_Connection_Handler *ch,
- ACE_Allocator *alloc);
-
- /// Ctor
- TAO_Notify_Handler (TAO_Transport *t,
- ACE_HANDLE h,
- ACE_Allocator *alloc);
-
-private:
-
- /// Preventing default ctor's.
- ACE_UNIMPLEMENTED_FUNC (TAO_Notify_Handler (void))
-
-private:
- /// Our copy of the TAO_TRansport, reference count incremented
- /// and stored.
- TAO_Transport *t_;
-
- /// The handle that we should be concerened with
- ACE_HANDLE h_;
-
- /// Our allocator
- ACE_Allocator *allocator_;
-};
-
-
-#include "ace/post.h"
-#endif /*TAO_NOTIFY_HANDLER_H*/
diff --git a/TAO/tao/PortableServer/AMH_Response_Handler.cpp b/TAO/tao/PortableServer/AMH_Response_Handler.cpp
index fbf1707511c..143241ec685 100644
--- a/TAO/tao/PortableServer/AMH_Response_Handler.cpp
+++ b/TAO/tao/PortableServer/AMH_Response_Handler.cpp
@@ -16,12 +16,13 @@ TAO_AMH_Response_Handler (TAO_ServerRequest &server_request)
: mesg_base_ (server_request.mesg_base_)
, request_id_ (server_request.request_id_)
, response_expected_ (server_request.response_expected_)
- , transport_ (TAO_Transport::_duplicate (server_request.transport ()))
+ , transport_ (server_request.transport ())
, orb_core_ (server_request.orb_core ())
, argument_flag_ (1)
, exception_type_ (TAO_GIOP_NO_EXCEPTION)
, reply_status_ (TAO_RS_UNINITIALIZED)
{
+ this->transport_->add_reference ();
}
TAO_AMH_Response_Handler::~TAO_AMH_Response_Handler (void)
@@ -34,10 +35,10 @@ TAO_AMH_Response_Handler::~TAO_AMH_Response_Handler (void)
if (this->response_expected_ == 0) //oneway ?
{
// if client is not expecting anything, don't send anything
- TAO_Transport::release (this->transport_);
+ this->transport_->remove_reference ();
return;
}
-
+
// If the ResponseHandler is being destroyed before a reply has
// been sent to the client, we send a system exception
// CORBA::NO_RESPONSE, with minor code to indicate the problem.
@@ -55,17 +56,17 @@ TAO_AMH_Response_Handler::~TAO_AMH_Response_Handler (void)
this->_tao_rh_send_exception (ex ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
- TAO_Transport::release (this->transport_);
+ this->transport_->remove_reference ();
}
ACE_CATCHALL
{
- TAO_Transport::release (this->transport_);
+ this->transport_->remove_reference ();
}
ACE_ENDTRY;
}
else
{
- TAO_Transport::release (this->transport_);
+ this->transport_->remove_reference ();
}
}
}
@@ -140,7 +141,7 @@ TAO_AMH_Response_Handler::_tao_rh_send_reply (ACE_ENV_SINGLE_ARG_DECL)
}
// Send the message.
- int result = this->transport_->send_message (this->_tao_out,
+ int result = this->transport_->send_message (this->_tao_out,
0,
TAO_Transport::TAO_REPLY);
@@ -180,7 +181,7 @@ TAO_AMH_Response_Handler::_tao_rh_send_exception (CORBA::Exception &ex
}
this->reply_status_ = TAO_RS_SENDING;
}
-
+
TAO_Pluggable_Reply_Params_Base reply_params;
reply_params.request_id_ = this->request_id_;
reply_params.svc_ctx_.length (0);
@@ -192,14 +193,14 @@ TAO_AMH_Response_Handler::_tao_rh_send_exception (CORBA::Exception &ex
// ExceptionHolder information.
if (CORBA::SystemException::_downcast (&ex))
reply_params.reply_status_ = TAO_GIOP_SYSTEM_EXCEPTION;
-
+
if (this->mesg_base_->generate_exception_reply (this->_tao_out,
reply_params,
ex) == -1)
{
ACE_THROW (CORBA::INTERNAL ());
}
-
+
// Send the Exception
if (this->transport_->send_message (this->_tao_out,
0,
@@ -209,7 +210,7 @@ TAO_AMH_Response_Handler::_tao_rh_send_exception (CORBA::Exception &ex
ACE_TEXT ("TAO: (%P|%t|%N|%l): ")
ACE_TEXT ("TAO_AMH_Response_Handler: could not send exception reply\n")));
}
-
+
{
ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_);
this->reply_status_ = TAO_RS_SENT;
diff --git a/TAO/tao/Strategies/DIOP_Acceptor.cpp b/TAO/tao/Strategies/DIOP_Acceptor.cpp
index 741c9e3834a..eff267c20f1 100644
--- a/TAO/tao/Strategies/DIOP_Acceptor.cpp
+++ b/TAO/tao/Strategies/DIOP_Acceptor.cpp
@@ -18,8 +18,8 @@
#include "DIOP_Acceptor.i"
#endif /* __ACE_INLINE__ */
-ACE_RCSID (tao,
- DIOP_Acceptor,
+ACE_RCSID (tao,
+ DIOP_Acceptor,
"$Id$")
TAO_DIOP_Acceptor::TAO_DIOP_Acceptor (CORBA::Boolean flag)
@@ -228,13 +228,12 @@ TAO_DIOP_Acceptor::close (void)
if (this->connection_handler_->get_handle () != ACE_INVALID_HANDLE)
{
this->connection_handler_->reactor ()->remove_handler (this->connection_handler_,
- ACE_Event_Handler::READ_MASK);
- }
- else
- {
- this->connection_handler_->handle_close (ACE_INVALID_HANDLE,
- ACE_Event_Handler::ALL_EVENTS_MASK);
+ ACE_Event_Handler::READ_MASK |
+ ACE_Event_Handler::DONT_CALL);
}
+
+ this->connection_handler_->remove_reference ();
+
this->connection_handler_ = 0;
}
return 0;
diff --git a/TAO/tao/Strategies/DIOP_Connection_Handler.cpp b/TAO/tao/Strategies/DIOP_Connection_Handler.cpp
index 21be6692f27..0fb564fd24e 100644
--- a/TAO/tao/Strategies/DIOP_Connection_Handler.cpp
+++ b/TAO/tao/Strategies/DIOP_Connection_Handler.cpp
@@ -34,7 +34,7 @@ TAO_DIOP_Connection_Handler::TAO_DIOP_Connection_Handler (ACE_Thread_Manager *t)
// 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 (0);
}
@@ -52,12 +52,12 @@ TAO_DIOP_Connection_Handler::TAO_DIOP_Connection_Handler (TAO_ORB_Core *orb_core
// store this pointer (indirectly increment ref count)
this->transport (specific_transport);
- TAO_Transport::release (specific_transport);
}
TAO_DIOP_Connection_Handler::~TAO_DIOP_Connection_Handler (void)
{
+ delete this->transport ();
this->udp_socket_.close ();
}
@@ -166,67 +166,64 @@ TAO_DIOP_Connection_Handler::close_connection (void)
int
TAO_DIOP_Connection_Handler::handle_input (ACE_HANDLE h)
{
- return this->handle_input_eh (h, this);
+ int result =
+ this->handle_input_eh (h, this);
+
+ if (result == -1)
+ {
+ this->close_connection ();
+ return 0;
+ }
+
+ return result;
}
int
TAO_DIOP_Connection_Handler::handle_output (ACE_HANDLE handle)
{
- return this->handle_output_eh (handle, this);
+ int result =
+ this->handle_output_eh (handle, this);
+
+ if (result == -1)
+ {
+ this->close_connection ();
+ return 0;
+ }
+
+ return result;
}
int
-TAO_DIOP_Connection_Handler::handle_close (ACE_HANDLE handle,
- ACE_Reactor_Mask rm)
+TAO_DIOP_Connection_Handler::handle_timeout (const ACE_Time_Value &,
+ const void *)
{
- return this->handle_close_eh (handle, rm, this);
+ // We don't use this upcall from the Reactor. However, we should
+ // override this since the base class returns -1 which will result
+ // in handle_close() getting called.
+ return 0;
}
int
-TAO_DIOP_Connection_Handler::release_os_resources (void)
+TAO_DIOP_Connection_Handler::handle_close (ACE_HANDLE,
+ ACE_Reactor_Mask)
{
- return this->peer().close ();
+ ACE_ASSERT (0);
+ return 0;
}
-// @@ Frank: Hopefully this isn't needed
-/*
int
-TAO_DIOP_Connection_Handler::process_listen_point_list (
- DIOP::ListenPointList &listen_list)
+TAO_DIOP_Connection_Handler::close (u_long)
{
- // Get the size of the list
- CORBA::ULong len = listen_list.length ();
-
- for (CORBA::ULong i = 0; i < len; ++ i)
- {
- DIOP::ListenPoint listen_point = listen_list[i];
- ACE_INET_Addr addr (listen_point.port,
- listen_point.host.in ());
-
-
- // Construct an DIOP_Endpoint object
- TAO_DIOP_Endpoint endpoint (addr,
- 0);
-
- // Construct a property object
- TAO_Base_Transport_Property prop (&endpoint);
-
- // Mark the connection as bidirectional
- prop.set_bidir_flag (1);
-
- // The property for this handler has changed. Recache the
- // handler with this property
- int retval = this->transport ()->recache_transport (&prop);
- if (retval == -1)
- return retval;
-
- // Make the handler idle and ready for use
- this->transport ()->make_idle ();
- }
-
+ this->state_changed (TAO_LF_Event::LFS_CONNECTION_CLOSED);
+ this->transport ()->remove_reference ();
return 0;
}
-*/
+
+int
+TAO_DIOP_Connection_Handler::release_os_resources (void)
+{
+ return this->peer().close ();
+}
// ****************************************************************
diff --git a/TAO/tao/Strategies/DIOP_Connection_Handler.h b/TAO/tao/Strategies/DIOP_Connection_Handler.h
index 4fbf5155a7a..e234b8e74b7 100644
--- a/TAO/tao/Strategies/DIOP_Connection_Handler.h
+++ b/TAO/tao/Strategies/DIOP_Connection_Handler.h
@@ -102,6 +102,10 @@ public:
virtual int open_handler (void *);
//@}
+ /// Close called by the Acceptor or Connector when connection
+ /// establishment fails.
+ int close (u_long = 0);
+
//@{
/** @name Event Handler overloads
*/
@@ -110,6 +114,8 @@ public:
virtual int handle_input (ACE_HANDLE);
virtual int handle_output (ACE_HANDLE);
virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask);
+ virtual int handle_timeout (const ACE_Time_Value &current_time,
+ const void *act = 0);
//@}
/// Add ourselves to Cache.
diff --git a/TAO/tao/Strategies/DIOP_Connector.cpp b/TAO/tao/Strategies/DIOP_Connector.cpp
index cdfa8da9826..6eebb705664 100644
--- a/TAO/tao/Strategies/DIOP_Connector.cpp
+++ b/TAO/tao/Strategies/DIOP_Connector.cpp
@@ -24,30 +24,16 @@ ACE_RCSID (DIOP,
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
-template class ACE_Svc_Tuple<TAO_DIOP_Connection_Handler>;
-template class ACE_Map_Manager<int, ACE_Svc_Tuple<TAO_DIOP_Connection_Handler> *, TAO_SYNCH_RW_MUTEX>;
-template class ACE_Map_Iterator_Base<int, ACE_Svc_Tuple<TAO_DIOP_Connection_Handler> *, TAO_SYNCH_RW_MUTEX>;
-template class ACE_Map_Entry<int,ACE_Svc_Tuple<TAO_DIOP_Connection_Handler>*>;
-
+template class ACE_NonBlocking_Connect_Handler<TAO_DIOP_Connection_Handler>;
template class ACE_Map_Entry<ACE_INET_Addr, TAO_DIOP_Connection_Handler *>;
-
-template class ACE_Map_Iterator<int,ACE_Svc_Tuple<TAO_DIOP_Connection_Handler>*,TAO_SYNCH_RW_MUTEX>;
-template class ACE_Map_Reverse_Iterator<int,ACE_Svc_Tuple<TAO_DIOP_Connection_Handler>*,TAO_SYNCH_RW_MUTEX>;
template class ACE_Hash_Map_Iterator_Base_Ex < ACE_INET_Addr, TAO_DIOP_Connection_Handler *, ACE_Hash < ACE_INET_Addr >, ACE_Equal_To < ACE_INET_Addr >, ACE_Null_Mutex >;
template class ACE_Hash_Map_Iterator_Ex<ACE_INET_Addr, TAO_DIOP_Connection_Handler *, ACE_Hash<ACE_INET_Addr>, ACE_Equal_To<ACE_INET_Addr>, ACE_Null_Mutex>;
template class ACE_Hash_Map_Reverse_Iterator_Ex<ACE_INET_Addr, TAO_DIOP_Connection_Handler *, ACE_Hash<ACE_INET_Addr>, ACE_Equal_To<ACE_INET_Addr>, ACE_Null_Mutex>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
-#pragma instantiate ACE_Svc_Tuple<TAO_DIOP_Connection_Handler>
-#pragma instantiate ACE_Map_Manager<int, ACE_Svc_Tuple<TAO_DIOP_Connection_Handler> *, TAO_SYNCH_RW_MUTEX>
-#pragma instantiate ACE_Map_Iterator_Base<int, ACE_Svc_Tuple<TAO_DIOP_Connection_Handler> *, TAO_SYNCH_RW_MUTEX>
-#pragma instantiate ACE_Map_Entry<int,ACE_Svc_Tuple<TAO_DIOP_Connection_Handler>*>
+#pragma instantiate ACE_NonBlocking_Connect_Handler<TAO_DIOP_Connection_Handler>
#pragma instantiate ACE_Map_Entry<ACE_INET_Addr, TAO_DIOP_Connection_Handler *>
-
-#pragma instantiate ACE_Map_Iterator<int,ACE_Svc_Tuple<TAO_DIOP_Connection_Handler>*,TAO_SYNCH_RW_MUTEX>
-#pragma instantiate ACE_Map_Reverse_Iterator<int,ACE_Svc_Tuple<TAO_DIOP_Connection_Handler>*,TAO_SYNCH_RW_MUTEX>
-
#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex < ACE_INET_Addr,TAO_DIOP_Connection_Handler *, ACE_Hash < ACE_INET_Addr >, ACE_Equal_To < ACE_INET_Addr >, ACE_Null_Mutex >
#pragma instantiate ACE_Hash_Map_Iterator_Ex<ACE_INET_Addr, TAO_DIOP_Connection_Handler *, ACE_Hash<ACE_INET_Addr>, ACE_Equal_To<ACE_INET_Addr>, ACE_Null_Mutex>
#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<ACE_INET_Addr, TAO_DIOP_Connection_Handler *, ACE_Hash<ACE_INET_Addr>, ACE_Equal_To<ACE_INET_Addr>, ACE_Null_Mutex>
@@ -86,7 +72,7 @@ TAO_DIOP_Connector::close (void)
while (!iter.done ())
{
- (*iter).int_id_->decr_refcount();
+ (*iter).int_id_->remove_reference ();
iter++;
}
@@ -170,8 +156,8 @@ TAO_DIOP_Connector::make_connection (TAO_GIOP_Invocation *invocation,
}
// @@ Michael: We do not use regular connection management.
-
- transport = TAO_Transport::_duplicate (svc_handler->transport ());
+ svc_handler->add_reference ();
+ transport = svc_handler->transport ();
return 0;
}
diff --git a/TAO/tao/Strategies/DIOP_Transport.cpp b/TAO/tao/Strategies/DIOP_Transport.cpp
index ea03fd05281..d4edd4c8c80 100644
--- a/TAO/tao/Strategies/DIOP_Transport.cpp
+++ b/TAO/tao/Strategies/DIOP_Transport.cpp
@@ -36,13 +36,6 @@ TAO_DIOP_Transport::TAO_DIOP_Transport (TAO_DIOP_Connection_Handler *handler,
, connection_handler_ (handler)
, messaging_object_ (0)
{
- if (connection_handler_ != 0)
- {
- // REFCNT: Matches one of
- // TAO_Transport::connection_handler_close() or
- // TAO_Transport::close_connection_shared.
- this->connection_handler_->incr_refcount();
- }
// @@ Michael: Set the input CDR size to ACE_MAX_DGRAM_SIZE so that
// we read the whole UDP packet on a single read.
if (flag)
@@ -63,7 +56,6 @@ TAO_DIOP_Transport::TAO_DIOP_Transport (TAO_DIOP_Connection_Handler *handler,
TAO_DIOP_Transport::~TAO_DIOP_Transport (void)
{
- ACE_ASSERT(this->connection_handler_ == 0);
delete this->messaging_object_;
}
@@ -86,9 +78,9 @@ TAO_DIOP_Transport::messaging_object (void)
}
ssize_t
-TAO_DIOP_Transport::send_i (iovec *iov, int iovcnt,
- size_t &bytes_transferred,
- const ACE_Time_Value *)
+TAO_DIOP_Transport::send (iovec *iov, int iovcnt,
+ size_t &bytes_transferred,
+ const ACE_Time_Value *)
{
const ACE_INET_Addr &addr = this->connection_handler_->addr ();
@@ -109,9 +101,9 @@ TAO_DIOP_Transport::send_i (iovec *iov, int iovcnt,
}
ssize_t
-TAO_DIOP_Transport::recv_i (char *buf,
- size_t len,
- const ACE_Time_Value * /* max_wait_time */)
+TAO_DIOP_Transport::recv (char *buf,
+ size_t len,
+ const ACE_Time_Value * /* max_wait_time */)
{
ACE_INET_Addr from_addr;
@@ -136,7 +128,7 @@ TAO_DIOP_Transport::recv_i (char *buf,
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("TAO (%P|%t) - %p \n"),
ACE_TEXT ("TAO - read message failure ")
- ACE_TEXT ("recv_i () \n")));
+ ACE_TEXT ("recv () \n")));
}
// Error handling
@@ -161,9 +153,9 @@ TAO_DIOP_Transport::recv_i (char *buf,
}
int
-TAO_DIOP_Transport::handle_input_i (TAO_Resume_Handle &rh,
- ACE_Time_Value *max_wait_time,
- int /*block*/)
+TAO_DIOP_Transport::handle_input (TAO_Resume_Handle &rh,
+ ACE_Time_Value *max_wait_time,
+ int /*block*/)
{
// If there are no messages then we can go ahead to read from the
// handle for further reading..
@@ -236,7 +228,7 @@ TAO_DIOP_Transport::handle_input_i (TAO_Resume_Handle &rh,
int
-TAO_DIOP_Transport::register_handler_i (void)
+TAO_DIOP_Transport::register_handler (void)
{
// @@ Michael:
//
@@ -318,173 +310,4 @@ TAO_DIOP_Transport::messaging_init (CORBA::Octet major,
return 1;
}
-// @@ Frank: Hopefully DIOP doesn't need this
-/*
-int
-TAO_DIOP_Transport::tear_listen_point_list (TAO_InputCDR &cdr)
-{
- CORBA::Boolean byte_order;
- if ((cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0)
- return -1;
-
- cdr.reset_byte_order (ACE_static_cast(int,byte_order));
-
- DIOP::ListenPointList listen_list;
- if ((cdr >> listen_list) == 0)
- return -1;
-
- // As we have received a bidirectional information, set the flag to
- // 1
- this->bidirectional_flag (1);
- return this->connection_handler_->process_listen_point_list (listen_list);
-}
-*/
-
-
-
-// @@ Frank: Hopefully DIOP doesn't need this
-/*
-void
-TAO_DIOP_Transport::set_bidir_context_info (TAO_Operation_Details &opdetails)
-{
-
- // Get a handle on to the acceptor registry
- TAO_Acceptor_Registry * ar =
- this->orb_core ()->acceptor_registry ();
-
-
- // Get the first acceptor in the registry
- TAO_AcceptorSetIterator acceptor = ar->begin ();
-
- DIOP::ListenPointList listen_point_list;
-
- for (;
- acceptor != ar->end ();
- acceptor++)
- {
- // Check whether it is a DIOP acceptor
- if ((*acceptor)->tag () == TAO_TAG_UDP_PROFILE)
- {
- this->get_listen_point (listen_point_list,
- *acceptor);
- }
- }
-
- // We have the ListenPointList at this point. Create a output CDR
- // stream at this point
- TAO_OutputCDR cdr;
-
- // Marshall the information into the stream
- if ((cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)== 0)
- || (cdr << listen_point_list) == 0)
- return;
-
- // Add this info in to the svc_list
- opdetails.service_context ().set_context (IOP::BI_DIR_DIOP,
- cdr);
-
- return;
-}
-
-
-int
-TAO_DIOP_Transport::get_listen_point (
- DIOP::ListenPointList &listen_point_list,
- TAO_Acceptor *acceptor)
-{
- TAO_DIOP_Acceptor *iiop_acceptor =
- ACE_dynamic_cast (TAO_DIOP_Acceptor *,
- acceptor );
-
- // Get the array of endpoints serviced by <iiop_acceptor>
- const ACE_INET_Addr *endpoint_addr =
- iiop_acceptor->endpoints ();
-
- // Get the count
- size_t count =
- iiop_acceptor->endpoint_count ();
-
- // Get the local address of the connection
- ACE_INET_Addr local_addr;
-
- if (this->connection_handler_->peer ().get_local_addr (local_addr)
- == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("(%P|%t) Could not resolve local host")
- ACE_TEXT (" address in set_bidir_context_info () \n")),
- -1);
- }
-
-
- // Note: Looks like there is no point in sending the list of
- // endpoints on interfaces on which this connection has not
- // been established. If this is wrong, please correct me.
- char *local_interface = 0;
-
- // Get the hostname for the local address
- if (iiop_acceptor->hostname (this->orb_core_,
- local_addr,
- local_interface) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("(%P|%t) Could not resolve local host")
- ACE_TEXT (" name \n")),
- -1);
- }
-
- ACE_INET_Addr *tmp_addr = ACE_const_cast (ACE_INET_Addr *,
- endpoint_addr);
-
- for (size_t index = 0;
- index <= count;
- index++)
- {
- // Get the listen point on that acceptor if it has the same
- // interface on which this connection is established
- char *acceptor_interface = 0;
-
- if (iiop_acceptor->hostname (this->orb_core_,
- tmp_addr[index],
- acceptor_interface) == -1)
- continue;
-
- // @@ This is very bad for performance, but it is a one time
- // affair
- if (ACE_OS::strcmp (local_interface,
- acceptor_interface) == 0)
- {
- // We have the connection and the acceptor endpoint on the
- // same interface
- DIOP::ListenPoint point;
- point.host = CORBA::string_dup (local_interface);
- point.port = endpoint_addr[index].get_port_number ();
-
- // Get the count of the number of elements
- CORBA::ULong len = listen_point_list.length ();
-
- // Increase the length by 1
- listen_point_list.length (len + 1);
-
- // Add the new length to the list
- listen_point_list[len] = point;
- }
-
- // @@ This is bad....
- CORBA::string_free (acceptor_interface);
- }
-
- CORBA::string_free (local_interface);
- return 1;
-}
-*/
-
-TAO_Connection_Handler *
-TAO_DIOP_Transport::invalidate_event_handler_i (void)
-{
- TAO_Connection_Handler * eh = this->connection_handler_;
- this->connection_handler_ = 0;
- return eh;
-}
-
#endif /* TAO_HAS_DIOP && TAO_HAS_DIOP != 0 */
diff --git a/TAO/tao/Strategies/DIOP_Transport.h b/TAO/tao/Strategies/DIOP_Transport.h
index c47c60d1a93..1ffe7064ff2 100644
--- a/TAO/tao/Strategies/DIOP_Transport.h
+++ b/TAO/tao/Strategies/DIOP_Transport.h
@@ -63,9 +63,9 @@ public:
~TAO_DIOP_Transport (void);
/// Look for the documentation in Transport.h.
- virtual int handle_input_i (TAO_Resume_Handle &rh,
- ACE_Time_Value *max_wait_time = 0,
- int block = 0);
+ virtual int handle_input (TAO_Resume_Handle &rh,
+ ACE_Time_Value *max_wait_time = 0,
+ int block = 0);
protected:
/** @name Overridden Template Methods
*
@@ -75,21 +75,20 @@ protected:
virtual ACE_Event_Handler * event_handler_i (void);
virtual TAO_Connection_Handler *connection_handler_i (void);
- virtual TAO_Connection_Handler * invalidate_event_handler_i (void);
virtual TAO_Pluggable_Messaging *messaging_object (void);
/// Write the complete Message_Block chain to the connection.
- virtual ssize_t send_i (iovec *iov, int iovcnt,
- size_t &bytes_transferred,
- const ACE_Time_Value *max_wait_time);
+ virtual ssize_t send (iovec *iov, int iovcnt,
+ size_t &bytes_transferred,
+ const ACE_Time_Value *max_wait_time);
/// Read len bytes from into buf.
- virtual ssize_t recv_i (char *buf,
- size_t len,
- const ACE_Time_Value *s = 0);
+ virtual ssize_t recv (char *buf,
+ size_t len,
+ const ACE_Time_Value *s = 0);
- virtual int register_handler_i (void);
+ virtual int register_handler (void);
///@}
public:
diff --git a/TAO/tao/Strategies/SCIOP_Connection_Handler.cpp b/TAO/tao/Strategies/SCIOP_Connection_Handler.cpp
index 187dae6aaa6..dcd9b6e9967 100644
--- a/TAO/tao/Strategies/SCIOP_Connection_Handler.cpp
+++ b/TAO/tao/Strategies/SCIOP_Connection_Handler.cpp
@@ -39,7 +39,7 @@ TAO_SCIOP_Connection_Handler::TAO_SCIOP_Connection_Handler (ACE_Thread_Manager *
// 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 (0);
}
@@ -57,7 +57,6 @@ TAO_SCIOP_Connection_Handler::TAO_SCIOP_Connection_Handler (TAO_ORB_Core *orb_co
// store this pointer (indirectly increment ref count)
this->transport (specific_transport);
- TAO_Transport::release (specific_transport);
}
TAO_SCIOP_Connection_Handler::TAO_SCIOP_Connection_Handler (TAO_ORB_Core *orb_core,
@@ -73,6 +72,7 @@ TAO_SCIOP_Connection_Handler::TAO_SCIOP_Connection_Handler (TAO_ORB_Core *orb_co
TAO_SCIOP_Connection_Handler::~TAO_SCIOP_Connection_Handler (void)
{
+ delete this->transport ();
}
int
@@ -174,20 +174,57 @@ TAO_SCIOP_Connection_Handler::close_connection (void)
int
TAO_SCIOP_Connection_Handler::handle_input (ACE_HANDLE h)
{
- return this->handle_input_eh (h, this);
+ int result =
+ this->handle_input_eh (h, this);
+
+ if (result == -1)
+ {
+ this->close_connection ();
+ return 0;
+ }
+
+ return result;
}
int
TAO_SCIOP_Connection_Handler::handle_output (ACE_HANDLE handle)
{
- return this->handle_output_eh (handle, this);
+ int result =
+ this->handle_output_eh (handle, this);
+
+ if (result == -1)
+ {
+ this->close_connection ();
+ return 0;
+ }
+
+ return result;
+}
+
+int
+TAO_SCIOP_Connection_Handler::handle_timeout (const ACE_Time_Value &,
+ const void *)
+{
+ // We don't use this upcall for I/O. This is only used by the
+ // Connector to indicate that the connection timedout. Therefore,
+ // we should call close().
+ return this->close ();
}
int
-TAO_SCIOP_Connection_Handler::handle_close (ACE_HANDLE handle,
- ACE_Reactor_Mask rm)
+TAO_SCIOP_Connection_Handler::handle_close (ACE_HANDLE,
+ ACE_Reactor_Mask)
{
- return this->handle_close_eh (handle, rm, this);
+ ACE_ASSERT (0);
+ return 0;
+}
+
+int
+TAO_SCIOP_Connection_Handler::close (u_long)
+{
+ this->state_changed (TAO_LF_Event::LFS_CONNECTION_CLOSED);
+ this->transport ()->remove_reference ();
+ return 0;
}
int
diff --git a/TAO/tao/Strategies/SCIOP_Connection_Handler.h b/TAO/tao/Strategies/SCIOP_Connection_Handler.h
index 2d7b694793e..b3492dc1504 100644
--- a/TAO/tao/Strategies/SCIOP_Connection_Handler.h
+++ b/TAO/tao/Strategies/SCIOP_Connection_Handler.h
@@ -96,8 +96,9 @@ public:
*/
-class TAO_Strategies_Export TAO_SCIOP_Connection_Handler : public TAO_SCIOP_SVC_HANDLER,
- public TAO_Connection_Handler
+class TAO_Strategies_Export TAO_SCIOP_Connection_Handler
+ : public TAO_SCIOP_SVC_HANDLER,
+ public TAO_Connection_Handler
{
public:
@@ -121,6 +122,10 @@ public:
virtual int open_handler (void *);
//@}
+ /// Close called by the Acceptor or Connector when connection
+ /// establishment fails.
+ int close (u_long = 0);
+
//@{
/** @name Event Handler overloads
*/
@@ -129,6 +134,8 @@ public:
virtual int handle_input (ACE_HANDLE);
virtual int handle_output (ACE_HANDLE);
virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask);
+ virtual int handle_timeout (const ACE_Time_Value &current_time,
+ const void *act = 0);
//@}
/// Add ourselves to Cache.
diff --git a/TAO/tao/Strategies/SCIOP_Connector.cpp b/TAO/tao/Strategies/SCIOP_Connector.cpp
index 2be650999a0..24aaccf8eed 100644
--- a/TAO/tao/Strategies/SCIOP_Connector.cpp
+++ b/TAO/tao/Strategies/SCIOP_Connector.cpp
@@ -157,124 +157,205 @@ TAO_SCIOP_Connector::make_connection (TAO_GIOP_Invocation *invocation,
TAO_SCIOP_Endpoint *sciop_endpoint =
this->remote_endpoint (desc->endpoint ());
- if (sciop_endpoint == 0)
- return -1;
-
- const ACE_INET_Addr &remote_address =
- sciop_endpoint->object_addr ();
+ if (sciop_endpoint == 0)
+ return -1;
- if (TAO_debug_level > 2)
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - SCIOP_Connector::make_connection, "
- "to <%s:%d>\n",
- sciop_endpoint->host(), sciop_endpoint->port()));
+ const ACE_INET_Addr &remote_address =
+ sciop_endpoint->object_addr ();
- // Get the right synch options
- ACE_Synch_Options synch_options;
+ if (TAO_debug_level > 2)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) - SCIOP_Connector::make_connection, "
+ "to <%s:%d>\n",
+ sciop_endpoint->host(), sciop_endpoint->port()));
- this->active_connect_strategy_->synch_options (max_wait_time,
- synch_options);
+ // Get the right synch options
+ ACE_Synch_Options synch_options;
- TAO_SCIOP_Connection_Handler *svc_handler = 0;
+ this->active_connect_strategy_->synch_options (max_wait_time,
+ synch_options);
- // Active connect
- int result = this->base_connector_.connect (svc_handler,
- remote_address,
- synch_options);
+ TAO_SCIOP_Connection_Handler *svc_handler = 0;
- if (result == -1 && errno == EWOULDBLOCK)
- {
- if (TAO_debug_level > 2)
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - SCIOP_Connector::make_connection, "
- "going to wait for connection completion on local"
- "handle [%d]\n",
- svc_handler->get_handle ()));
-
- result =
- this->active_connect_strategy_->wait (svc_handler,
- max_wait_time);
-
- if (TAO_debug_level > 2)
- {
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - SCIOP_Connector::make_connection"
- "wait done for handle[%d], result = %d\n",
- svc_handler->get_handle (), result));
- }
+ // Connect.
+ int result = this->base_connector_.connect (svc_handler,
+ remote_address,
+ synch_options);
- }
-
- int status =
- svc_handler->is_finalized ();
-
- // Reduce the refcount to the svc_handler that we have. The
- // increment to the handler is done in make_svc_handler (). Now
- // that we dont need the reference to it anymore we can decrement
- // the refcount whether the connection is successful ot not.
- // REFCNT: Matches with TAO_Connect_Strategy<>::make_svc_handler()
- long refcount = svc_handler->decr_refcount ();
-
- ACE_ASSERT (refcount >= 0);
-
- ACE_UNUSED_ARG (refcount);
+ // This call creates the service handler and bumps the #REFCOUNT# up
+ // one extra. There are three possibilities: (a) connection
+ // succeeds immediately - in this case, the #REFCOUNT# on the
+ // handler is two; (b) connection completion is pending - in this
+ // case, the #REFCOUNT# on the handler is also two; (c) connection
+ // fails immediately - in this case, the #REFCOUNT# on the handler
+ // is one since close() gets called on the handler.
+ //
+ // The extra reference count in
+ // TAO_Connect_Creation_Strategy::make_svc_handler() is needed in
+ // the case when connection completion is pending and we are going
+ // to wait on a variable in the handler to changes, signifying
+ // success or failure. Note, that this increment cannot be done
+ // once the connect() returns since this might be too late if
+ // another thread pick up the completion and potentially deletes the
+ // handler before we get a chance to increment the reference count.
+
+ // No immediate result. Wait for completion.
+ if (result == -1 && errno == EWOULDBLOCK)
+ {
+ if (TAO_debug_level > 2)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) - SCIOP_Connector::make_connection, "
+ "going to wait for connection completion on local"
+ "handle [%d]\n",
+ svc_handler->get_handle ()));
+
+ // Wait for connection completion. No need to specify timeout
+ // to wait() since the correct timeout was passed to the
+ // Connector. The Connector will close the handler in the case
+ // of timeouts, so the event will complete (either success or
+ // failure) within timeout.
+ result =
+ this->active_connect_strategy_->wait (svc_handler,
+ 0);
+
+ if (TAO_debug_level > 2)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) - SCIOP_Connector::make_connection"
+ "wait done for handle[%d], result = %d\n",
+ svc_handler->get_handle (), result));
+ }
+
+ // There are three possibilities when wait() returns: (a)
+ // connection succeeded; (b) connection failed; (c) wait()
+ // failed because of some other error. It is easy to deal with
+ // (a) and (b). (c) is tricky since the connection is still
+ // pending and may get completed by some other thread. The
+ // following code deals with (c).
+
+ // Check if the handler has been closed.
+ int closed =
+ svc_handler->is_closed ();
+
+ // In case of failures and close() has not be called.
+ if (result == -1 &&
+ !closed)
+ {
+ // First, cancel from connector.
+ this->base_connector_.cancel (svc_handler);
+
+ // Double check to make sure the handler has not been closed
+ // yet. This double check is required to ensure that the
+ // connection handler was not closed yet by some other
+ // thread since it was still registered with the connector.
+ // Once connector.cancel() has been processed, we are
+ // assured that the connector will no longer open/close this
+ // handler.
+ closed =
+ svc_handler->is_closed ();
+
+ // If closed, there is nothing to do here. If not closed,
+ // it was either opened or is still pending.
+ if (!closed)
+ {
+ // Check if the handler has been opened.
+ int open =
+ svc_handler->is_open ();
+
+ // Some other thread was able to open the handler even
+ // though wait failed for this thread.
+ if (open)
+ // Overwrite <result>.
+ result = 0;
+ else
+ {
+ // Assert that it is still connecting.
+ ACE_ASSERT (svc_handler->is_connecting ());
+
+ // Force close the handler now.
+ svc_handler->close ();
+ }
+ }
+ }
+ }
- if (result == -1)
- {
- // Give users a clue to the problem.
- if (TAO_debug_level)
- {
- ACE_DEBUG ((LM_ERROR,
- "TAO (%P|%t) - SCIOP_Connector::make_connection, "
- "connection to <%s:%d> failed (%p)\n",
- sciop_endpoint->host (), sciop_endpoint->port (),
- "errno"));
- }
+ // Irrespective of success or failure, remove the extra #REFCOUNT#.
+ svc_handler->remove_reference ();
- (void) this->active_connect_strategy_->post_failed_connect (svc_handler,
- status);
+ // In case of errors.
+ if (result == -1)
+ {
+ // Give users a clue to the problem.
+ if (TAO_debug_level)
+ {
+ ACE_DEBUG ((LM_ERROR,
+ "TAO (%P|%t) - SCIOP_Connector::make_connection, "
+ "connection to <%s:%d> failed (%p)\n",
+ sciop_endpoint->host (), sciop_endpoint->port (),
+ "errno"));
+ }
+
+ return -1;
+ }
- return -1;
- }
+ // At this point, the connection has be successfully connected.
+ // #REFCOUNT# is one.
+ if (TAO_debug_level > 2)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) - SCIOP_Connector::make_connection, "
+ "new connection to <%s:%d> on Transport[%d]\n",
+ sciop_endpoint->host (), sciop_endpoint->port (),
+ svc_handler->peer ().get_handle ()));
+
+ TAO_Transport *transport =
+ svc_handler->transport ();
+
+ // Add the handler to Cache
+ int retval =
+ this->orb_core ()->lane_resources ().transport_cache ().cache_transport (desc,
+ base_transport);
+
+ // Failure in adding to cache.
+ if (retval != 0)
+ {
+ // Close the handler.
+ svc_handler->close ();
- if (TAO_debug_level > 2)
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - SCIOP_Connector::make_connection, "
- "new connection to <%s:%d> on Transport[%d]\n",
- sciop_endpoint->host (), sciop_endpoint->port (),
- svc_handler->peer ().get_handle ()));
+ if (TAO_debug_level > 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "TAO (%P|%t) - SCIOP_Connector::make_connection, "
+ "could not add the new connection to cache\n"));
+ }
- TAO_Transport *base_transport =
- TAO_Transport::_duplicate (svc_handler->transport ());
+ return -1;
+ }
- // Add the handler to Cache
- int retval =
- this->orb_core ()->lane_resources ().transport_cache ().cache_transport (desc,
- base_transport);
+ // Registration failures.
+ if (retval != 0)
+ {
+ // Purge from the connection cache.
+ transport->purge_entry ();
- if (retval != 0 && TAO_debug_level > 0)
- {
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - SCIOP_Connector::make_connection, "
- "could not add the new connection to cache\n"));
- }
+ // Close the handler.
+ svc_handler->close ();
- // If the wait strategy wants us to be registered with the reactor
- // then we do so.
- retval = base_transport->wait_strategy ()->register_handler ();
+ if (TAO_debug_level > 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "TAO (%P|%t) - SCIOP_Connector::make_connection, "
+ "could not register the new connection in the reactor\n"));
+ }
- if (retval != 0 && TAO_debug_level > 0)
- {
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - SCIOP_Connector::make_connection, "
- "could not register the new connection in the reactor\n"));
- }
+ return -1;
+ }
- // Handover the transport pointer to the Invocation class.
- TAO_Transport *&transport = invocation->transport ();
- transport = base_transport;
+ // Handover the transport pointer to the Invocation class.
+ TAO_Transport *&invocation_transport =
+ invocation->transport ();
+ invocation_transport = transport;
- return 0;
+ return 0;
}
diff --git a/TAO/tao/Strategies/SCIOP_Transport.cpp b/TAO/tao/Strategies/SCIOP_Transport.cpp
index 75cde3d8814..14eec2c17c2 100644
--- a/TAO/tao/Strategies/SCIOP_Transport.cpp
+++ b/TAO/tao/Strategies/SCIOP_Transport.cpp
@@ -41,13 +41,6 @@ TAO_SCIOP_Transport::TAO_SCIOP_Transport (TAO_SCIOP_Connection_Handler *handler,
, connection_handler_ (handler)
, messaging_object_ (0)
{
- if (connection_handler_ != 0)
- {
- // REFCNT: Matches one of
- // TAO_Transport::connection_handler_close() or
- // TAO_Transport::close_connection_shared.
- this->connection_handler_->incr_refcount();
- }
if (flag)
{
// Use the lite version of the protocol
@@ -64,7 +57,6 @@ TAO_SCIOP_Transport::TAO_SCIOP_Transport (TAO_SCIOP_Connection_Handler *handler,
TAO_SCIOP_Transport::~TAO_SCIOP_Transport (void)
{
- ACE_ASSERT(this->connection_handler_ == 0);
delete this->messaging_object_;
}
@@ -87,9 +79,9 @@ TAO_SCIOP_Transport::messaging_object (void)
}
ssize_t
-TAO_SCIOP_Transport::send_i (iovec *iov, int iovcnt,
- size_t &bytes_transferred,
- const ACE_Time_Value *max_wait_time)
+TAO_SCIOP_Transport::send (iovec *iov, int iovcnt,
+ size_t &bytes_transferred,
+ const ACE_Time_Value *max_wait_time)
{
ssize_t retval = this->connection_handler_->peer ().sendv (iov, iovcnt,
max_wait_time);
@@ -100,9 +92,9 @@ TAO_SCIOP_Transport::send_i (iovec *iov, int iovcnt,
}
ssize_t
-TAO_SCIOP_Transport::recv_i (char *buf,
- size_t len,
- const ACE_Time_Value *max_wait_time)
+TAO_SCIOP_Transport::recv (char *buf,
+ size_t len,
+ const ACE_Time_Value *max_wait_time)
{
ssize_t n = this->connection_handler_->peer ().recv (buf,
len,
@@ -115,7 +107,7 @@ TAO_SCIOP_Transport::recv_i (char *buf,
errno != ETIME)
{
ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("TAO (%P|%t) - SCIOP_Transport[%d]::recv_i, ")
+ ACE_TEXT ("TAO (%P|%t) - SCIOP_Transport[%d]::recv, ")
ACE_TEXT ("read failure - %m\n"),
this->id ()));
}
@@ -143,32 +135,6 @@ TAO_SCIOP_Transport::recv_i (char *buf,
}
int
-TAO_SCIOP_Transport::register_handler_i (void)
-{
- if (TAO_debug_level > 4)
- {
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - SCIOP_Transport[%d]::register_handler\n",
- this->id ()));
- }
-
- ACE_Reactor *r = this->orb_core_->reactor ();
-
- if (r == this->connection_handler_->reactor ())
- return 0;
-
- // Set the flag in the Connection Handler and in the Wait Strategy
- // @@Maybe we should set these flags after registering with the
- // reactor. What if the registration fails???
- this->ws_->is_registered (1);
-
- // Register the handler with the reactor
- return r->register_handler (this->connection_handler_,
- ACE_Event_Handler::READ_MASK);
-}
-
-
-int
TAO_SCIOP_Transport::send_request (TAO_Stub *stub,
TAO_ORB_Core *orb_core,
TAO_OutputCDR &stream,
@@ -184,12 +150,6 @@ TAO_SCIOP_Transport::send_request (TAO_Stub *stub,
if (tph != 0)
{
- ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->handler_lock_, -1);
-
- if (this->check_event_handler_i ("SCIOP_Transport::send_request")
- == -1)
- return -1;
-
const char protocol[] = "sciop";
const char * protocol_type = protocol;
@@ -270,9 +230,6 @@ TAO_SCIOP_Transport::send_message_shared (TAO_Stub *stub,
{
ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->handler_lock_, -1);
- if (this->check_event_handler_i ("SCIOP_Transport::send_message_shared") == -1)
- return -1;
-
if (TAO_debug_level > 6)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("TAO (%P|%t) - ")
@@ -350,17 +307,6 @@ TAO_SCIOP_Transport::tear_listen_point_list (TAO_InputCDR &cdr)
// 1 (i.e., non-originating side)
this->bidirectional_flag (1);
- // Just make sure that the connection handler is sane before we go
- // head and do anything with it.
- ACE_GUARD_RETURN (ACE_Lock,
- ace_mon,
- *this->handler_lock_,
- -1);
-
- if (this->check_event_handler_i ("SCIOP_Transport::tear_listen_point_list")
- == -1)
- return -1;
-
return this->connection_handler_->process_listen_point_list (listen_list);
}
@@ -430,29 +376,17 @@ TAO_SCIOP_Transport::get_listen_point (
// Get the local address of the connection
ACE_INET_Addr local_addr;
- {
- // Just make sure that the connection handler is sane before we go
- // head and do anything with it.
- ACE_GUARD_RETURN (ACE_Lock,
- ace_mon,
- *this->handler_lock_,
- -1);
-
- if (this->check_event_handler_i ("IIOP_Transport::get_listen_point")
- == -1)
- return -1;
-
- if (this->connection_handler_->peer ().get_local_addr (local_addr)
- == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("(%P|%t) Could not resolve local ")
- ACE_TEXT ("host address in ")
- ACE_TEXT ("get_listen_point()\n")),
- -1);
- }
- }
-
+
+ if (this->connection_handler_->peer ().get_local_addr (local_addr)
+ == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) Could not resolve local ")
+ ACE_TEXT ("host address in ")
+ ACE_TEXT ("get_listen_point()\n")),
+ -1);
+ }
+
// Note: Looks like there is no point in sending the list of
// endpoints on interfaces on which this connection has not
// been established. If this is wrong, please correct me.
@@ -493,12 +427,4 @@ TAO_SCIOP_Transport::get_listen_point (
return 1;
}
-TAO_Connection_Handler *
-TAO_SCIOP_Transport::invalidate_event_handler_i (void)
-{
- TAO_Connection_Handler * eh = this->connection_handler_;
- this->connection_handler_ = 0;
- return eh;
-}
-
#endif /* TAO_HAS_SCIOP == 1 */
diff --git a/TAO/tao/Strategies/SCIOP_Transport.h b/TAO/tao/Strategies/SCIOP_Transport.h
index fe3905ae174..770be64e55d 100644
--- a/TAO/tao/Strategies/SCIOP_Transport.h
+++ b/TAO/tao/Strategies/SCIOP_Transport.h
@@ -70,25 +70,22 @@ protected:
//@{
virtual ACE_Event_Handler * event_handler_i (void);
- virtual TAO_Connection_Handler * invalidate_event_handler_i (void);
/// Access the underlying messaging object
virtual TAO_Pluggable_Messaging *messaging_object (void);
- virtual ssize_t send_i (iovec *iov, int iovcnt,
- size_t &bytes_transferred,
- const ACE_Time_Value *timeout = 0);
+ virtual ssize_t send (iovec *iov, int iovcnt,
+ size_t &bytes_transferred,
+ const ACE_Time_Value *timeout = 0);
- virtual ssize_t recv_i (char *buf,
- size_t len,
- const ACE_Time_Value *s = 0);
-
- virtual int register_handler_i (void);
+ virtual ssize_t recv (char *buf,
+ size_t len,
+ const ACE_Time_Value *s = 0);
virtual int send_message_shared (TAO_Stub *stub,
- int message_semantics,
- const ACE_Message_Block *message_block,
- ACE_Time_Value *max_wait_time);
+ int message_semantics,
+ const ACE_Message_Block *message_block,
+ ACE_Time_Value *max_wait_time);
public:
@@ -151,4 +148,3 @@ private:
#include "ace/post.h"
#endif /* TAO_SCIOP_TRANSPORT_H */
-
diff --git a/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp b/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp
index 6ff58729342..826317a92c9 100644
--- a/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp
+++ b/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp
@@ -31,7 +31,7 @@ TAO_SHMIOP_Connection_Handler::TAO_SHMIOP_Connection_Handler (ACE_Thread_Manager
// 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 (0);
}
@@ -47,12 +47,12 @@ TAO_SHMIOP_Connection_Handler::TAO_SHMIOP_Connection_Handler (TAO_ORB_Core *orb_
// store this pointer (indirectly increment ref count)
this->transport (specific_transport);
- TAO_Transport::release (specific_transport);
}
TAO_SHMIOP_Connection_Handler::~TAO_SHMIOP_Connection_Handler (void)
{
+ delete this->transport ();
}
int
@@ -133,20 +133,57 @@ TAO_SHMIOP_Connection_Handler::close_connection (void)
int
TAO_SHMIOP_Connection_Handler::handle_input (ACE_HANDLE h)
{
- return this->handle_input_eh (h, this);
+ int result =
+ this->handle_input_eh (h, this);
+
+ if (result == -1)
+ {
+ this->close_connection ();
+ return 0;
+ }
+
+ return result;
}
int
TAO_SHMIOP_Connection_Handler::handle_output (ACE_HANDLE handle)
{
- return this->handle_output_eh (handle, this);
+ int result =
+ this->handle_output_eh (handle, this);
+
+ if (result == -1)
+ {
+ this->close_connection ();
+ return 0;
+ }
+
+ return result;
+}
+
+int
+TAO_SHMIOP_Connection_Handler::handle_timeout (const ACE_Time_Value &,
+ const void *)
+{
+ // We don't use this upcall for I/O. This is only used by the
+ // Connector to indicate that the connection timedout. Therefore,
+ // we should call close().
+ return this->close ();
}
int
-TAO_SHMIOP_Connection_Handler::handle_close (ACE_HANDLE handle,
- ACE_Reactor_Mask rm)
+TAO_SHMIOP_Connection_Handler::handle_close (ACE_HANDLE,
+ ACE_Reactor_Mask)
{
- return this->handle_close_eh (handle, rm, this);
+ ACE_ASSERT (0);
+ return 0;
+}
+
+int
+TAO_SHMIOP_Connection_Handler::close (u_long)
+{
+ this->state_changed (TAO_LF_Event::LFS_CONNECTION_CLOSED);
+ this->transport ()->remove_reference ();
+ return 0;
}
int
diff --git a/TAO/tao/Strategies/SHMIOP_Connection_Handler.h b/TAO/tao/Strategies/SHMIOP_Connection_Handler.h
index fd1d046a43b..12562a37adf 100644
--- a/TAO/tao/Strategies/SHMIOP_Connection_Handler.h
+++ b/TAO/tao/Strategies/SHMIOP_Connection_Handler.h
@@ -71,6 +71,10 @@ public:
virtual int open_handler (void *);
//@}
+ /// Close called by the Acceptor or Connector when connection
+ /// establishment fails.
+ int close (u_long = 0);
+
//@{
/** @name Event Handler overloads
*/
@@ -79,6 +83,8 @@ public:
virtual int handle_input (ACE_HANDLE);
virtual int handle_output (ACE_HANDLE);
virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask);
+ virtual int handle_timeout (const ACE_Time_Value &current_time,
+ const void *act = 0);
//@}
/// Add ourselves to Cache.
diff --git a/TAO/tao/Strategies/SHMIOP_Connector.cpp b/TAO/tao/Strategies/SHMIOP_Connector.cpp
index 4a4d28a04c4..24f53525d68 100644
--- a/TAO/tao/Strategies/SHMIOP_Connector.cpp
+++ b/TAO/tao/Strategies/SHMIOP_Connector.cpp
@@ -29,13 +29,7 @@ template class TAO_Connect_Creation_Strategy<TAO_SHMIOP_Connection_Handler>;
template class ACE_Strategy_Connector<TAO_SHMIOP_Connection_Handler, ACE_MEM_CONNECTOR>;
template class ACE_Connect_Strategy<TAO_SHMIOP_Connection_Handler, ACE_MEM_CONNECTOR>;
template class ACE_Connector<TAO_SHMIOP_Connection_Handler, ACE_MEM_CONNECTOR>;
-template class ACE_Svc_Tuple<TAO_SHMIOP_Connection_Handler>;
-
-template class ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<TAO_SHMIOP_Connection_Handler> *, TAO_SYNCH_RW_MUTEX>;
-template class ACE_Map_Iterator_Base<ACE_HANDLE, ACE_Svc_Tuple<TAO_SHMIOP_Connection_Handler> *, TAO_SYNCH_RW_MUTEX>;
-template class ACE_Map_Entry<ACE_HANDLE,ACE_Svc_Tuple<TAO_SHMIOP_Connection_Handler>*>;
-template class ACE_Map_Iterator<ACE_HANDLE,ACE_Svc_Tuple<TAO_SHMIOP_Connection_Handler>*,TAO_SYNCH_RW_MUTEX>;
-template class ACE_Map_Reverse_Iterator<ACE_HANDLE,ACE_Svc_Tuple<TAO_SHMIOP_Connection_Handler>*,TAO_SYNCH_RW_MUTEX>;
+template class ACE_NonBlocking_Connect_Handler<TAO_SHMIOP_Connection_Handler>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
@@ -44,13 +38,7 @@ template class ACE_Map_Reverse_Iterator<ACE_HANDLE,ACE_Svc_Tuple<TAO_SHMIOP_Conn
#pragma instantiate ACE_Strategy_Connector<TAO_SHMIOP_Connection_Handler, ACE_MEM_CONNECTOR>
#pragma instantiate ACE_Connect_Strategy<TAO_SHMIOP_Connection_Handler, ACE_MEM_CONNECTOR>
#pragma instantiate ACE_Connector<TAO_SHMIOP_Connection_Handler, ACE_MEM_CONNECTOR>
-#pragma instantiate ACE_Svc_Tuple<TAO_SHMIOP_Connection_Handler>
-
-#pragma instantiate ACE_Map_Manager<ACE_HANDLE, ACE_Svc_Tuple<TAO_SHMIOP_Connection_Handler> *, TAO_SYNCH_RW_MUTEX>
-#pragma instantiate ACE_Map_Iterator_Base<ACE_HANDLE, ACE_Svc_Tuple<TAO_SHMIOP_Connection_Handler> *, TAO_SYNCH_RW_MUTEX>
-#pragma instantiate ACE_Map_Entry<ACE_HANDLE,ACE_Svc_Tuple<TAO_SHMIOP_Connection_Handler>*>
-#pragma instantiate ACE_Map_Iterator<ACE_HANDLE,ACE_Svc_Tuple<TAO_SHMIOP_Connection_Handler>*,TAO_SYNCH_RW_MUTEX>
-#pragma instantiate ACE_Map_Reverse_Iterator<ACE_HANDLE,ACE_Svc_Tuple<TAO_SHMIOP_Connection_Handler>*,TAO_SYNCH_RW_MUTEX>
+#pragma instantiate ACE_NonBlocking_Connect_Handler<TAO_SHMIOP_Connection_Handler>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
@@ -145,7 +133,7 @@ TAO_SHMIOP_Connector::set_validate_endpoint (TAO_Endpoint *endpoint)
if (TAO_debug_level > 0)
{
ACE_DEBUG ((LM_DEBUG,
- ACE_LIB_TEXT ("TAO (%P|%t) IIOP connection failed.\n")
+ ACE_LIB_TEXT ("TAO (%P|%t) SHMIOP connection failed.\n")
ACE_LIB_TEXT ("TAO (%P|%t) This is most likely ")
ACE_LIB_TEXT ("due to a hostname lookup ")
ACE_LIB_TEXT ("failure.\n")));
@@ -177,9 +165,6 @@ TAO_SHMIOP_Connector::make_connection (TAO_GIOP_Invocation *invocation,
const ACE_INET_Addr &remote_address =
shmiop_endpoint->object_addr ();
-
- TAO_SHMIOP_Connection_Handler *svc_handler = 0;
-
if (TAO_debug_level > 2)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) SHMIOP_Connector::connect ")
@@ -191,27 +176,25 @@ TAO_SHMIOP_Connector::make_connection (TAO_GIOP_Invocation *invocation,
this->active_connect_strategy_->synch_options (max_wait_time,
synch_options);
+ TAO_SHMIOP_Connection_Handler *svc_handler = 0;
+
+ // Connect.
int result = this->base_connector_.connect (svc_handler,
remote_address,
synch_options);
- int status = svc_handler->is_finalized ();
- // Reduce the refcount to the svc_handler that we have. The
- // increment to the handler is done in make_svc_handler (). Now
- // that we dont need the reference to it anymore we can decrement
- // the refcount whether the connection is successful ot not.
- long refcount = svc_handler->decr_refcount ();
-
- ACE_ASSERT (refcount >= 0);
- ACE_UNUSED_ARG (refcount);
+ // This call creates the service handler and bumps the #REFCOUNT# up
+ // one extra. There are two possibilities: (a) connection succeeds
+ // immediately - in this case, the #REFCOUNT# on the handler is two;
+ // (b) connection fails immediately - in this case, the #REFCOUNT#
+ // on the handler is one since close() gets called on the handler.
+ // We always use a blocking connection so the connection is never
+ // pending.
- // = We dont do a wait since we know that we are doing a blocking
- // connect
- if (TAO_debug_level > 4)
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("(%P|%t) SHMIOP_Connector::connect ")
- ACE_TEXT ("The result is <%d> \n"), result));
+ // Irrespective of success or failure, remove the extra #REFCOUNT#.
+ svc_handler->remove_reference ();
+ // In case of errors.
if (result == -1)
{
// Give users a clue to the problem.
@@ -227,47 +210,74 @@ TAO_SHMIOP_Connector::make_connection (TAO_GIOP_Invocation *invocation,
ACE_TEXT ("errno")));
}
- (void) this->active_connect_strategy_->post_failed_connect (svc_handler,
- status);
-
return -1;
}
- TAO_Transport *base_transport =
- TAO_Transport::_duplicate (svc_handler->transport ());
+ // 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",
+ shmiop_endpoint->host (), shmiop_endpoint->port (),
+ svc_handler->peer ().get_handle ()));
+
+ TAO_Transport *transport =
+ svc_handler->transport ();
// Add the handler to Cache
int retval =
this->orb_core ()->lane_resources ().transport_cache ().cache_transport (desc,
- base_transport);
+ transport);
- if (retval != 0 && TAO_debug_level > 0)
+ // Failure in adding to cache.
+ if (retval != 0)
{
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("(%P|%t) SHMIOP_Connector::connect ")
- ACE_TEXT ("could not add the new connection to Cache \n")));
- }
+ // Close the handler.
+ svc_handler->close ();
+ 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"));
+ }
+
+ return -1;
+ }
// If the wait strategy wants us to be registered with the reactor
- // then we do so.
- retval = base_transport->wait_strategy ()->register_handler ();
+ // then we do so. If registeration is required and it succeeds,
+ // #REFCOUNT# becomes two.
+ retval = transport->wait_strategy ()->register_handler ();
- if (retval != 0 && TAO_debug_level > 0)
+ // Registration failures.
+ if (retval != 0)
{
- ACE_DEBUG ((LM_DEBUG,
- ACE_LIB_TEXT ("(%P|%t) IIOP_Connector::connect ")
- ACE_LIB_TEXT ("could not add the new connection to reactor \n")));
+ // Purge from the connection cache.
+ transport->purge_entry ();
+
+ // Close the handler.
+ svc_handler->close ();
+
+ if (TAO_debug_level > 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "TAO (%P|%t) - SHMIOP_Connector::make_connection, "
+ "could not register the new connection in the reactor\n"));
+ }
+
+ return -1;
}
// Handover the transport pointer to the Invocation class.
- TAO_Transport *&transport = invocation->transport ();
- transport = base_transport;
+ TAO_Transport *&invocation_transport =
+ invocation->transport ();
+ invocation_transport = transport;
return 0;
}
-
TAO_Profile *
TAO_SHMIOP_Connector::create_profile (TAO_InputCDR& cdr)
{
diff --git a/TAO/tao/Strategies/SHMIOP_Transport.cpp b/TAO/tao/Strategies/SHMIOP_Transport.cpp
index 4151467e50f..77ef4957f7c 100644
--- a/TAO/tao/Strategies/SHMIOP_Transport.cpp
+++ b/TAO/tao/Strategies/SHMIOP_Transport.cpp
@@ -34,13 +34,6 @@ TAO_SHMIOP_Transport::TAO_SHMIOP_Transport (TAO_SHMIOP_Connection_Handler *handl
connection_handler_ (handler),
messaging_object_ (0)
{
- if (connection_handler_ != 0)
- {
- // REFCNT: Matches one of
- // TAO_Transport::connection_handler_close() or
- // TAO_Transport::close_connection_shared.
- this->connection_handler_->incr_refcount();
- }
if (flag)
{
// Use the lite version of the protocol
@@ -57,7 +50,6 @@ TAO_SHMIOP_Transport::TAO_SHMIOP_Transport (TAO_SHMIOP_Connection_Handler *handl
TAO_SHMIOP_Transport::~TAO_SHMIOP_Transport (void)
{
- ACE_ASSERT(this->connection_handler_ == 0);
delete this->messaging_object_;
}
@@ -81,9 +73,9 @@ TAO_SHMIOP_Transport::messaging_object (void)
ssize_t
-TAO_SHMIOP_Transport::send_i (iovec *iov, int iovcnt,
- size_t &bytes_transferred,
- const ACE_Time_Value *max_wait_time)
+TAO_SHMIOP_Transport::send (iovec *iov, int iovcnt,
+ size_t &bytes_transferred,
+ const ACE_Time_Value *max_wait_time)
{
bytes_transferred = 0;
for (int i = 0; i < iovcnt; ++i)
@@ -101,9 +93,9 @@ TAO_SHMIOP_Transport::send_i (iovec *iov, int iovcnt,
}
ssize_t
-TAO_SHMIOP_Transport::recv_i (char *buf,
- size_t len,
- const ACE_Time_Value *max_wait_time)
+TAO_SHMIOP_Transport::recv (char *buf,
+ size_t len,
+ const ACE_Time_Value *max_wait_time)
{
ssize_t n = 0;
@@ -200,32 +192,6 @@ TAO_SHMIOP_Transport::consolidate_message (ACE_Message_Block &incoming,
return this->process_parsed_messages (&pqd, rh);
}
-
-int
-TAO_SHMIOP_Transport::register_handler_i (void)
-{
- if (TAO_debug_level > 4)
- {
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - SHMIOP_Transport::register_handler %d\n",
- this->id ()));
- }
- // @@ It seems like this method should go away, the right reactor is
- // picked at object creation time.
- ACE_Reactor *r = this->orb_core_->reactor ();
-
- if (r == this->connection_handler_->reactor ())
- return 0;
-
- // Set the flag in the Connection Handler
- this->ws_->is_registered (1);
-
- // Register the handler with the reactor
- return r->register_handler (this->connection_handler_,
- ACE_Event_Handler::READ_MASK);
-}
-
-
int
TAO_SHMIOP_Transport::send_request (TAO_Stub *stub,
TAO_ORB_Core *orb_core,
@@ -292,12 +258,4 @@ TAO_SHMIOP_Transport::messaging_init (CORBA::Octet major,
return 1;
}
-TAO_Connection_Handler *
-TAO_SHMIOP_Transport::invalidate_event_handler_i (void)
-{
- TAO_Connection_Handler * eh = this->connection_handler_;
- this->connection_handler_ = 0;
- return eh;
-}
-
#endif /* TAO_HAS_SHMIOP && TAO_HAS_SHMIOP != 0 */
diff --git a/TAO/tao/Strategies/SHMIOP_Transport.h b/TAO/tao/Strategies/SHMIOP_Transport.h
index b41197303ae..a0089bae8a0 100644
--- a/TAO/tao/Strategies/SHMIOP_Transport.h
+++ b/TAO/tao/Strategies/SHMIOP_Transport.h
@@ -69,26 +69,23 @@ protected:
//@{
virtual ACE_Event_Handler * event_handler_i (void);
virtual TAO_Connection_Handler *connection_handler_i (void);
- virtual TAO_Connection_Handler * invalidate_event_handler_i (void);
virtual TAO_Pluggable_Messaging *messaging_object (void);
/// Write the complete Message_Block chain to the connection.
- virtual ssize_t send_i (iovec *iov, int iovcnt,
- size_t &bytes_transferred,
- const ACE_Time_Value *timeout = 0);
+ virtual ssize_t send (iovec *iov, int iovcnt,
+ size_t &bytes_transferred,
+ const ACE_Time_Value *timeout = 0);
/// Read len bytes from into buf.
- virtual ssize_t recv_i (char *buf,
- size_t len,
- const ACE_Time_Value *s = 0);
+ virtual ssize_t recv (char *buf,
+ size_t len,
+ const ACE_Time_Value *s = 0);
virtual int consolidate_message (ACE_Message_Block &incoming,
ssize_t missing_data,
TAO_Resume_Handle &rh,
ACE_Time_Value *max_wait_time);
- virtual int register_handler_i (void);
-
//@}
public:
diff --git a/TAO/tao/Strategies/UIOP_Connection_Handler.cpp b/TAO/tao/Strategies/UIOP_Connection_Handler.cpp
index ca1b2f1b95a..3ca211a4c57 100644
--- a/TAO/tao/Strategies/UIOP_Connection_Handler.cpp
+++ b/TAO/tao/Strategies/UIOP_Connection_Handler.cpp
@@ -34,7 +34,7 @@ TAO_UIOP_Connection_Handler::TAO_UIOP_Connection_Handler (ACE_Thread_Manager *t)
// 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 (0);
}
@@ -47,17 +47,17 @@ TAO_UIOP_Connection_Handler::TAO_UIOP_Connection_Handler (TAO_ORB_Core *orb_core
(TAO_UIOP_Properties *, arg))
{
TAO_UIOP_Transport* specific_transport = 0;
- ACE_NEW(specific_transport,
- TAO_UIOP_Transport(this, orb_core, flag));
+ ACE_NEW (specific_transport,
+ TAO_UIOP_Transport(this, orb_core, flag));
// store this pointer (indirectly increment ref count)
- this->transport(specific_transport);
- TAO_Transport::release (specific_transport);
+ this->transport (specific_transport);
}
TAO_UIOP_Connection_Handler::~TAO_UIOP_Connection_Handler (void)
{
+ delete this->transport ();
}
int
@@ -116,20 +116,57 @@ TAO_UIOP_Connection_Handler::close_connection (void)
int
TAO_UIOP_Connection_Handler::handle_input (ACE_HANDLE h)
{
- return this->handle_input_eh (h, this);
+ int result =
+ this->handle_input_eh (h, this);
+
+ if (result == -1)
+ {
+ this->close_connection ();
+ return 0;
+ }
+
+ return result;
}
int
TAO_UIOP_Connection_Handler::handle_output (ACE_HANDLE handle)
{
- return this->handle_output_eh (handle, this);
+ int result =
+ this->handle_output_eh (handle, this);
+
+ if (result == -1)
+ {
+ this->close_connection ();
+ return 0;
+ }
+
+ return result;
+}
+
+int
+TAO_UIOP_Connection_Handler::handle_timeout (const ACE_Time_Value &,
+ const void *)
+{
+ // We don't use this upcall for I/O. This is only used by the
+ // Connector to indicate that the connection timedout. Therefore,
+ // we should call close().
+ return this->close ();
}
int
-TAO_UIOP_Connection_Handler::handle_close (ACE_HANDLE handle,
- ACE_Reactor_Mask rm)
+TAO_UIOP_Connection_Handler::handle_close (ACE_HANDLE,
+ ACE_Reactor_Mask)
{
- return this->handle_close_eh (handle, rm, this);
+ ACE_ASSERT (0);
+ return 0;
+}
+
+int
+TAO_UIOP_Connection_Handler::close (u_long)
+{
+ this->state_changed (TAO_LF_Event::LFS_CONNECTION_CLOSED);
+ this->transport ()->remove_reference ();
+ return 0;
}
int
diff --git a/TAO/tao/Strategies/UIOP_Connection_Handler.h b/TAO/tao/Strategies/UIOP_Connection_Handler.h
index 1d5e1e212c5..da6216ab196 100644
--- a/TAO/tao/Strategies/UIOP_Connection_Handler.h
+++ b/TAO/tao/Strategies/UIOP_Connection_Handler.h
@@ -87,6 +87,10 @@ public:
virtual int open_handler (void *);
//@}
+ /// Close called by the Acceptor or Connector when connection
+ /// establishment fails.
+ int close (u_long = 0);
+
//@{
/** @name Event Handler overloads
*/
@@ -96,6 +100,8 @@ public:
virtual int handle_input (ACE_HANDLE);
virtual int handle_output (ACE_HANDLE);
virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask);
+ virtual int handle_timeout (const ACE_Time_Value &current_time,
+ const void *act = 0);
//@}
diff --git a/TAO/tao/Strategies/UIOP_Connector.cpp b/TAO/tao/Strategies/UIOP_Connector.cpp
index 1991c150ba1..f16a36bddfd 100644
--- a/TAO/tao/Strategies/UIOP_Connector.cpp
+++ b/TAO/tao/Strategies/UIOP_Connector.cpp
@@ -23,13 +23,7 @@ template class TAO_Connect_Creation_Strategy<TAO_UIOP_Connection_Handler>;
template class ACE_Strategy_Connector<TAO_UIOP_Connection_Handler, ACE_LSOCK_CONNECTOR>;
template class ACE_Connect_Strategy<TAO_UIOP_Connection_Handler, ACE_LSOCK_CONNECTOR>;
template class ACE_Connector<TAO_UIOP_Connection_Handler, ACE_LSOCK_CONNECTOR>;
-template class ACE_Svc_Tuple<TAO_UIOP_Connection_Handler>;
-
-template class ACE_Map_Manager<int, ACE_Svc_Tuple<TAO_UIOP_Connection_Handler> *, TAO_SYNCH_RW_MUTEX>;
-template class ACE_Map_Iterator_Base<int, ACE_Svc_Tuple<TAO_UIOP_Connection_Handler> *, TAO_SYNCH_RW_MUTEX>;
-template class ACE_Map_Entry<int,ACE_Svc_Tuple<TAO_UIOP_Connection_Handler>*>;
-template class ACE_Map_Iterator<int,ACE_Svc_Tuple<TAO_UIOP_Connection_Handler>*,TAO_SYNCH_RW_MUTEX>;
-template class ACE_Map_Reverse_Iterator<int,ACE_Svc_Tuple<TAO_UIOP_Connection_Handler>*,TAO_SYNCH_RW_MUTEX>;
+template class ACE_NonBlocking_Connect_Handler<TAO_UIOP_Connection_Handler>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
@@ -41,13 +35,7 @@ template class ACE_Map_Reverse_Iterator<int,ACE_Svc_Tuple<TAO_UIOP_Connection_Ha
#pragma instantiate ACE_Strategy_Connector<TAO_UIOP_Connection_Handler, ACE_LSOCK_CONNECTOR>
#pragma instantiate ACE_Connect_Strategy<TAO_UIOP_Connection_Handler, ACE_LSOCK_CONNECTOR>
#pragma instantiate ACE_Connector<TAO_UIOP_Connection_Handler, ACE_LSOCK_CONNECTOR>
-#pragma instantiate ACE_Svc_Tuple<TAO_UIOP_Connection_Handler>
-
-#pragma instantiate ACE_Map_Manager<int, ACE_Svc_Tuple<TAO_UIOP_Connection_Handler> *, TAO_SYNCH_RW_MUTEX>
-#pragma instantiate ACE_Map_Iterator_Base<int, ACE_Svc_Tuple<TAO_UIOP_Connection_Handler> *, TAO_SYNCH_RW_MUTEX>
-#pragma instantiate ACE_Map_Entry<int,ACE_Svc_Tuple<TAO_UIOP_Connection_Handler>*>
-#pragma instantiate ACE_Map_Iterator<int,ACE_Svc_Tuple<TAO_UIOP_Connection_Handler>*,TAO_SYNCH_RW_MUTEX>
-#pragma instantiate ACE_Map_Reverse_Iterator<int,ACE_Svc_Tuple<TAO_UIOP_Connection_Handler>*,TAO_SYNCH_RW_MUTEX>
+#pragma instantiate ACE_NonBlocking_Connect_Handler<TAO_UIOP_Connection_Handler>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
@@ -167,6 +155,7 @@ TAO_UIOP_Connector::make_connection (TAO_GIOP_Invocation *invocation,
ACE_TEXT ("(%P|%t) UIOP_Connector::connect ")
ACE_TEXT ("making a new connection \n")));
+ // Get the right synch options
ACE_Synch_Options synch_options;
this->active_connect_strategy_->synch_options (max_wait_time,
@@ -174,11 +163,30 @@ TAO_UIOP_Connector::make_connection (TAO_GIOP_Invocation *invocation,
TAO_UIOP_Connection_Handler *svc_handler = 0;
+ // Connect.
int result =
this->base_connector_.connect (svc_handler,
remote_address,
synch_options);
+ // This call creates the service handler and bumps the #REFCOUNT# up
+ // one extra. There are three possibilities: (a) connection
+ // succeeds immediately - in this case, the #REFCOUNT# on the
+ // handler is two; (b) connection completion is pending - in this
+ // case, the #REFCOUNT# on the handler is also two; (c) connection
+ // fails immediately - in this case, the #REFCOUNT# on the handler
+ // is one since close() gets called on the handler.
+ //
+ // The extra reference count in
+ // TAO_Connect_Creation_Strategy::make_svc_handler() is needed in
+ // the case when connection completion is pending and we are going
+ // to wait on a variable in the handler to changes, signifying
+ // success or failure. Note, that this increment cannot be done
+ // once the connect() returns since this might be too late if
+ // another thread pick up the completion and potentially deletes the
+ // handler before we get a chance to increment the reference count.
+
+ // No immediate result. Wait for completion.
if (result == -1 && errno == EWOULDBLOCK)
{
if (TAO_debug_level > 2)
@@ -187,9 +195,15 @@ TAO_UIOP_Connector::make_connection (TAO_GIOP_Invocation *invocation,
"going to wait for connection completion on local"
"handle [%d]\n",
svc_handler->get_handle ()));
+
+ // Wait for connection completion. No need to specify timeout
+ // to wait() since the correct timeout was passed to the
+ // Connector. The Connector will close the handler in the case
+ // of timeouts, so the event will complete (either success or
+ // failure) within timeout.
result =
this->active_connect_strategy_->wait (svc_handler,
- max_wait_time);
+ 0);
if (TAO_debug_level > 2)
{
@@ -198,26 +212,64 @@ TAO_UIOP_Connector::make_connection (TAO_GIOP_Invocation *invocation,
"wait done for handle[%d], result = %d\n",
svc_handler->get_handle (), result));
}
- }
-
- int status =
- svc_handler->is_finalized ();
+ // There are three possibilities when wait() returns: (a)
+ // connection succeeded; (b) connection failed; (c) wait()
+ // failed because of some other error. It is easy to deal with
+ // (a) and (b). (c) is tricky since the connection is still
+ // pending and may get completed by some other thread. The
+ // following code deals with (c).
- // Reduce the refcount to the svc_handler that we have. The
- // increment to the handler is done in make_svc_handler (). Now
- // that we dont need the reference to it anymore we can decrement
- // the refcount whether the connection is successful ot not.
- long refcount = svc_handler->decr_refcount ();
+ // Check if the handler has been closed.
+ int closed =
+ svc_handler->is_finalized ();
- ACE_ASSERT (refcount >= 0);
- ACE_UNUSED_ARG (refcount);
+ // In case of failures and close() has not be called.
+ if (result == -1 &&
+ !closed)
+ {
+ // First, cancel from connector.
+ this->base_connector_.cancel (svc_handler);
+
+ // Double check to make sure the handler has not been
+ // closed yet. This double check is required to ensure
+ // that the connection handler was not closed yet by some
+ // other thread since it was still registered with the
+ // connector. Once connector.cancel() has been processed,
+ // we are assured that the connector will no longer
+ // open/close this handler.
+ closed =
+ svc_handler->is_closed ();
+
+ // If closed, there is nothing to do here. If not closed,
+ // it was either opened or is still pending.
+ if (!closed)
+ {
+ // Check if the handler has been opened.
+ int open =
+ svc_handler->is_open ();
+
+ // Some other thread was able to open the handler even
+ // though wait failed for this thread.
+ if (open)
+ // Overwrite <result>.
+ result = 0;
+ else
+ {
+ // Assert that it is still connecting.
+ ACE_ASSERT (svc_handler->is_connecting ());
+
+ // Force close the handler now.
+ svc_handler->close ();
+ }
+ }
+ }
+ }
- if (TAO_debug_level > 0)
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("(%P|%t) UIOP_Connector::connect ")
- ACE_TEXT ("The result is <%d> \n"), result));
+ // Irrespective of success or failure, remove the extra #REFCOUNT#.
+ svc_handler->remove_reference ();
+ // In case of errors.
if (result == -1)
{
// Give users a clue to the problem.
@@ -232,46 +284,67 @@ TAO_UIOP_Connector::make_connection (TAO_GIOP_Invocation *invocation,
ACE_TEXT ("errno")));
}
- (void) this->active_connect_strategy_->post_failed_connect (svc_handler,
- status);
return -1;
}
- TAO_Transport *base_transport =
- TAO_Transport::_duplicate (svc_handler->transport ());
+ // At this point, the connection has be successfully connected.
+ // #REFCOUNT# is one.
+
+ TAO_Transport *transport =
+ svc_handler->transport ();
// Add the handler to Cache
int retval =
this->orb_core ()->lane_resources ().transport_cache ().cache_transport (desc,
- base_transport);
-
- if (retval != 0 && TAO_debug_level > 0)
+ transport);
+ // Failure in adding to cache.
+ if (retval != 0)
{
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("(%P|%t) UIOP_Connector::connect ")
- ACE_TEXT ("could not add the new connection to Cache \n")));
+ // Close the handler.
+ svc_handler->close ();
+
+ if (TAO_debug_level > 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) UIOP_Connector::connect ")
+ ACE_TEXT ("could not add the new connection to Cache \n")));
+ }
+
+ return -1;
}
// If the wait strategy wants us to be registered with the reactor
- // then we do so.
- retval = base_transport->wait_strategy ()->register_handler ();
+ // then we do so. If registeration is required and it succeeds,
+ // #REFCOUNT# becomes two.
+ retval = transport->wait_strategy ()->register_handler ();
- if (retval != 0 && TAO_debug_level > 0)
+ // Registration failures.
+ if (retval != 0)
{
- ACE_DEBUG ((LM_DEBUG,
- ACE_LIB_TEXT ("(%P|%t) IIOP_Connector::connect ")
- ACE_LIB_TEXT ("could not add the new connection to reactor \n")));
+ // Purge from the connection cache.
+ transport->purge_entry ();
+
+ // Close the handler.
+ svc_handler->close ();
+
+ if (TAO_debug_level > 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "TAO (%P|%t) - UIOP_Connector::make_connection, "
+ "could not register the new connection in the reactor\n"));
+ }
+
+ return -1;
}
// Handover the transport pointer to the Invocation class.
- TAO_Transport *&transport = invocation->transport ();
- transport = base_transport;
+ TAO_Transport *&invocation_transport =
+ invocation->transport ();
+ invocation_transport = transport;
return 0;
}
-
-
TAO_Profile *
TAO_UIOP_Connector::create_profile (TAO_InputCDR& cdr)
{
diff --git a/TAO/tao/Strategies/UIOP_Transport.cpp b/TAO/tao/Strategies/UIOP_Transport.cpp
index 3270f94f012..b5cfaf044dd 100644
--- a/TAO/tao/Strategies/UIOP_Transport.cpp
+++ b/TAO/tao/Strategies/UIOP_Transport.cpp
@@ -33,13 +33,6 @@ TAO_UIOP_Transport::TAO_UIOP_Transport (TAO_UIOP_Connection_Handler *handler,
, connection_handler_ (handler)
, messaging_object_ (0)
{
- if (connection_handler_ != 0)
- {
- // REFCNT: Matches one of
- // TAO_Transport::connection_handler_close() or
- // TAO_Transport::close_connection_shared.
- this->connection_handler_->incr_refcount();
- }
if (flag)
{
// Use the lite version of the protocol
@@ -56,7 +49,6 @@ TAO_UIOP_Transport::TAO_UIOP_Transport (TAO_UIOP_Connection_Handler *handler,
TAO_UIOP_Transport::~TAO_UIOP_Transport (void)
{
- ACE_ASSERT(this->connection_handler_ == 0);
delete this->messaging_object_;
}
@@ -79,9 +71,9 @@ TAO_UIOP_Transport::messaging_object (void)
}
ssize_t
-TAO_UIOP_Transport::send_i (iovec *iov, int iovcnt,
- size_t &bytes_transferred,
- const ACE_Time_Value *max_wait_time)
+TAO_UIOP_Transport::send (iovec *iov, int iovcnt,
+ size_t &bytes_transferred,
+ const ACE_Time_Value *max_wait_time)
{
ssize_t retval = this->connection_handler_->peer ().sendv (iov, iovcnt,
max_wait_time);
@@ -92,9 +84,9 @@ TAO_UIOP_Transport::send_i (iovec *iov, int iovcnt,
}
ssize_t
-TAO_UIOP_Transport::recv_i (char *buf,
- size_t len,
- const ACE_Time_Value *max_wait_time)
+TAO_UIOP_Transport::recv (char *buf,
+ size_t len,
+ const ACE_Time_Value *max_wait_time)
{
ssize_t n = this->connection_handler_->peer ().recv (buf,
len,
@@ -109,7 +101,7 @@ TAO_UIOP_Transport::recv_i (char *buf,
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("TAO (%P|%t) - %p \n"),
ACE_TEXT ("TAO - read message failure ")
- ACE_TEXT ("recv_i () \n")));
+ ACE_TEXT ("recv () \n")));
}
// Error handling
@@ -130,31 +122,6 @@ TAO_UIOP_Transport::recv_i (char *buf,
}
int
-TAO_UIOP_Transport::register_handler_i (void)
-{
- if (TAO_debug_level > 4)
- {
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - UIOP_Transport::register_handler %d\n",
- this->id ()));
- }
- // @@ It seems like this method should go away, the right reactor is
- // picked at object creation time.
- ACE_Reactor *r = this->orb_core_->reactor ();
-
- if (r == this->connection_handler_->reactor ())
- return 0;
-
- // Set the flag in the Connection Handler
- this->ws_->is_registered (1);
-
- // Register the handler with the reactor
- return r->register_handler (this->connection_handler_,
- ACE_Event_Handler::READ_MASK);
-}
-
-
-int
TAO_UIOP_Transport::send_request (TAO_Stub *stub,
TAO_ORB_Core *orb_core,
TAO_OutputCDR &stream,
@@ -220,12 +187,4 @@ TAO_UIOP_Transport::messaging_init (CORBA::Octet major,
return 1;
}
-TAO_Connection_Handler *
-TAO_UIOP_Transport::invalidate_event_handler_i (void)
-{
- TAO_Connection_Handler * eh = this->connection_handler_;
- this->connection_handler_ = 0;
- return eh;
-}
-
#endif /* TAO_HAS_UIOP */
diff --git a/TAO/tao/Strategies/UIOP_Transport.h b/TAO/tao/Strategies/UIOP_Transport.h
index cb504621570..1099d7e1bf0 100644
--- a/TAO/tao/Strategies/UIOP_Transport.h
+++ b/TAO/tao/Strategies/UIOP_Transport.h
@@ -68,20 +68,17 @@ protected:
virtual ACE_Event_Handler * event_handler_i (void);
virtual TAO_Connection_Handler *connection_handler_i (void);
- virtual TAO_Connection_Handler * invalidate_event_handler_i (void);
virtual TAO_Pluggable_Messaging *messaging_object (void);
/// Write the complete Message_Block chain to the connection.
- virtual ssize_t send_i (iovec *iov, int iovcnt,
- size_t &bytes_transferred,
- const ACE_Time_Value *timeout = 0);
+ virtual ssize_t send (iovec *iov, int iovcnt,
+ size_t &bytes_transferred,
+ const ACE_Time_Value *timeout = 0);
/// Read len bytes from into buf.
- virtual ssize_t recv_i (char *buf,
- size_t len,
- const ACE_Time_Value *s = 0);
-
- virtual int register_handler_i (void);
+ virtual ssize_t recv (char *buf,
+ size_t len,
+ const ACE_Time_Value *s = 0);
public:
/// @todo These methods IMHO should have more meaningful names.
diff --git a/TAO/tao/TAO.dsp b/TAO/tao/TAO.dsp
index 9b9c6708c55..f0a69a5809f 100644
--- a/TAO/tao/TAO.dsp
+++ b/TAO/tao/TAO.dsp
@@ -636,10 +636,6 @@ SOURCE=.\Muxed_TMS.cpp
# End Source File
# Begin Source File
-SOURCE=.\Notify_Handler.cpp
-# End Source File
-# Begin Source File
-
SOURCE=.\NVList.cpp
# End Source File
# Begin Source File
@@ -1532,10 +1528,6 @@ SOURCE=.\Muxed_TMS.h
# End Source File
# Begin Source File
-SOURCE=.\Notify_Handler.h
-# End Source File
-# Begin Source File
-
SOURCE=.\nvlist.h
# End Source File
# Begin Source File
diff --git a/TAO/tao/TAO_Static.dsp b/TAO/tao/TAO_Static.dsp
index 75d6d7cae45..682cfaf45be 100644
--- a/TAO/tao/TAO_Static.dsp
+++ b/TAO/tao/TAO_Static.dsp
@@ -555,10 +555,6 @@ SOURCE=.\Muxed_TMS.cpp
# End Source File
# Begin Source File
-SOURCE=.\Notify_Handler.cpp
-# End Source File
-# Begin Source File
-
SOURCE=.\NVList.cpp
# End Source File
# Begin Source File
@@ -1491,10 +1487,6 @@ SOURCE=.\Muxed_TMS.h
# End Source File
# Begin Source File
-SOURCE=.\Notify_Handler.h
-# End Source File
-# Begin Source File
-
SOURCE=.\nvlist.h
# End Source File
# Begin Source File
diff --git a/TAO/tao/Thread_Lane_Resources.cpp b/TAO/tao/Thread_Lane_Resources.cpp
index ff2b263fd1d..d0c9327755c 100644
--- a/TAO/tao/Thread_Lane_Resources.cpp
+++ b/TAO/tao/Thread_Lane_Resources.cpp
@@ -8,7 +8,9 @@ ACE_RCSID(tao, Thread_Lane_Resources, "$Id$")
#include "tao/Acceptor_Registry.h"
#include "tao/Transport_Cache_Manager.h"
#include "tao/Leader_Follower.h"
-#include "Connector_Registry.h"
+#include "tao/Connection_Handler.h"
+#include "tao/Transport.h"
+#include "tao/Connector_Registry.h"
#include "ace/Reactor.h"
@@ -260,37 +262,28 @@ TAO_Thread_Lane_Resources::finalize (void)
delete this->acceptor_registry_;
}
- // Set of file descriptors corresponding to open connections. This
- // handle set is used to explicitly deregister the connection event
- // handlers from the Reactor. This is particularly important for
- // dynamically loaded ORBs where an application level reactor, such
- // as the Singleton reactor, is used instead of an ORB created one.
- ACE_Handle_Set handle_set;
- TAO_EventHandlerSet unregistered;
-
- // Close the transport cache and return the handle set that needs
- // to be de-registered from the reactor.
- this->transport_cache_->close (handle_set, unregistered);
-
- // Shutdown all open connections that are registered with the ORB
- // Core. Note that the ACE_Event_Handler::DONT_CALL mask is NOT
- // used here since the reactor should invoke each handle's
- // corresponding ACE_Event_Handler::handle_close() method to ensure
- // that the connection is shutdown gracefully prior to destroying
- // the ORB Core.
- if (handle_set.num_set () > 0)
- (void) this->leader_follower ().reactor ()->remove_handler (handle_set,
- ACE_Event_Handler::ALL_EVENTS_MASK);
- if (!unregistered.is_empty ())
+ // Set of handlers still in the connection cache.
+ TAO_Connection_Handler_Set handlers;
+
+ // Close the transport cache and return the handlers that were still
+ // registered. The cache will decrease the #REFCOUNT# on the
+ // handler when it removes the handler from cache. However,
+ // #REFCOUNT# is increased when the handler is placed in the handler
+ // set.
+ this->transport_cache_->close (handlers);
+
+ // Go through the handler set, closing the connections and removing
+ // the references.
+ TAO_Connection_Handler **handler = 0;
+ for (TAO_Connection_Handler_Set::iterator iter (handlers);
+ iter.next (handler);
+ iter.advance ())
{
- ACE_Event_Handler** eh;
- for (TAO_EventHandlerSetIterator iter(unregistered);
- iter.next (eh);
- iter.advance())
- {
- (*eh)->handle_close (ACE_INVALID_HANDLE,
- ACE_Event_Handler::ALL_EVENTS_MASK);
- }
+ // Connection is closed. Potential removal from the Reactor.
+ (*handler)->close_connection ();
+
+ // #REFCOUNT# related to the handler set decreases.
+ (*handler)->transport ()->remove_reference ();
}
delete this->transport_cache_;
diff --git a/TAO/tao/Thread_Per_Connection_Handler.cpp b/TAO/tao/Thread_Per_Connection_Handler.cpp
index d69e6dcf0df..cc9d6edac94 100644
--- a/TAO/tao/Thread_Per_Connection_Handler.cpp
+++ b/TAO/tao/Thread_Per_Connection_Handler.cpp
@@ -13,14 +13,12 @@ TAO_Thread_Per_Connection_Handler::TAO_Thread_Per_Connection_Handler (
TAO_Connection_Handler *ch)
: ch_ (ch)
{
- // REFCNT: Matches decr_refcount() in the destructor.
- (void) this->ch_->incr_refcount ();
+ this->ch_->transport ()->add_reference ();
}
TAO_Thread_Per_Connection_Handler::~TAO_Thread_Per_Connection_Handler (void)
{
- // REFCNT: Matches incr_refcount() in the constructor.
- (void) this->ch_->decr_refcount ();
+ this->ch_->transport ()->remove_reference ();
}
int
diff --git a/TAO/tao/Transport.cpp b/TAO/tao/Transport.cpp
index e07169bb109..6cfccf24bab 100644
--- a/TAO/tao/Transport.cpp
+++ b/TAO/tao/Transport.cpp
@@ -20,7 +20,6 @@
#include "Thread_Lane_Resources.h"
#include "debug.h"
#include "Resume_Handle.h"
-#include "Notify_Handler.h"
#include "ace/Message_Block.h"
#include "ace/Reactor.h"
@@ -96,16 +95,9 @@ dump_iov (iovec *iov, int iovcnt, size_t id,
ACE_Log_Msg::instance ()->release ();
}
-/*
- * Definitions for methods declared in the transport class
- *
- */
-
-// Constructor.
TAO_Transport::TAO_Transport (CORBA::ULong tag,
TAO_ORB_Core *orb_core)
- : TAO_Synch_Refcountable (orb_core->resource_factory ()->create_cached_connection_lock (), 1)
- , tag_ (tag)
+ : tag_ (tag)
, orb_core_ (orb_core)
, cache_map_entry_ (0)
, bidirectional_flag_ (-1)
@@ -135,8 +127,6 @@ TAO_Transport::TAO_Transport (CORBA::ULong tag,
TAO_Transport::~TAO_Transport (void)
{
- ACE_ASSERT(this->refcount() == 0);
-
delete this->ws_;
delete this->tms_;
@@ -145,122 +135,17 @@ TAO_Transport::~TAO_Transport (void)
// By the time the destructor is reached all the connection stuff
// *must* have been cleaned up
- ACE_ASSERT(this->head_ == 0);
- ACE_ASSERT(this->cache_map_entry_ == 0);
-}
-
-
-/*
- *
- * Public utility methods that are called by other classes.
- *
- */
-/*static*/ TAO_Transport*
-TAO_Transport::_duplicate (TAO_Transport* transport)
-{
- if (transport != 0)
- {
- transport->increment ();
- }
- return transport;
-}
-
-/*static*/ void
-TAO_Transport::release (TAO_Transport* transport)
-{
- if (transport != 0)
- {
- int count = transport->decrement ();
-
- if (count == 0)
- {
- delete transport;
- }
- else if (count < 0)
- {
- ACE_ERROR ((LM_ERROR,
- "TAO (%P|%t) - Transport[%d]::release, "
- "reference count is less than zero: %d\n",
- transport->id (), count));
- ACE_OS::abort ();
- }
- }
+ ACE_ASSERT (this->head_ == 0);
+ ACE_ASSERT (this->cache_map_entry_ == 0);
}
-
void
-TAO_Transport::provide_handle (ACE_Handle_Set &reactor_registered,
- TAO_EventHandlerSet &unregistered)
-{
- ACE_MT (ACE_GUARD (ACE_Lock,
- guard,
- *this->handler_lock_));
- ACE_Event_Handler *eh = this->event_handler_i ();
-
- if (eh != 0)
- {
- if (this->ws_->is_registered ())
- {
- reactor_registered.set_bit (eh->get_handle ());
- }
- else
- {
- unregistered.insert (eh);
- }
- }
-}
-
-
-int
-TAO_Transport::register_handler (void)
-{
- ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
- guard,
- *this->handler_lock_,
- -1));
- if (this->check_event_handler_i ("Transport::register_handler") == -1)
- return -1;
-
- return this->register_handler_i ();
-}
-
-
-ssize_t
-TAO_Transport::send (iovec *iov, int iovcnt,
- size_t &bytes_transferred,
- const ACE_Time_Value *timeout)
-{
- ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
- guard,
- *this->handler_lock_,
- -1));
-
- if (this->check_event_handler_i ("Transport::send") == -1)
- return -1;
-
- // now call the template method
- return this->send_i (iov, iovcnt, bytes_transferred, timeout);
-}
-
-
-ssize_t
-TAO_Transport::recv (char *buffer,
- size_t len,
- const ACE_Time_Value *timeout)
+TAO_Transport::provide_handler (TAO_Connection_Handler_Set &handlers)
{
- ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
- guard,
- *this->handler_lock_,
- -1));
-
- if (this->check_event_handler_i ("Transport::recv") == -1)
- return -1;
-
- // now call the template method
- return this->recv_i (buffer, len, timeout);
+ this->add_reference ();
+ handlers.insert (this->connection_handler_i ());
}
-
int
TAO_Transport::idle_after_send (void)
{
@@ -282,8 +167,32 @@ TAO_Transport::tear_listen_point_list (TAO_InputCDR &)
void
TAO_Transport::close_connection (void)
{
- TAO_Connection_Handler * eh = this->invalidate_event_handler ();
- this->close_connection_shared (1, eh);
+ this->connection_handler_i ()->close_connection ();
+}
+
+int
+TAO_Transport::register_handler (void)
+{
+ if (TAO_debug_level > 4)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) - Transport[%d]::register_handler\n",
+ this->id ()));
+ }
+
+ ACE_Reactor *r = this->orb_core_->reactor ();
+
+ if (r == this->event_handler_i ()->reactor ())
+ return 0;
+
+ // Set the flag in the Connection Handler and in the Wait Strategy
+ // @@Maybe we should set these flags after registering with the
+ // reactor. What if the registration fails???
+ this->ws_->is_registered (1);
+
+ // Register the handler with the reactor
+ return r->register_handler (this->event_handler_i (),
+ ACE_Event_Handler::READ_MASK);
}
int
@@ -308,7 +217,6 @@ TAO_Transport::generate_locate_request (
return 0;
}
-
int
TAO_Transport::generate_request_header (
TAO_Operation_Details &opdetails,
@@ -318,8 +226,8 @@ TAO_Transport::generate_request_header (
// codeset service context is only supposed to be sent in the first request
// on a particular connection.
if (this->first_request_)
- this->orb_core()->codeset_manager()->
- generate_service_context( opdetails, *this );
+ this->orb_core ()->codeset_manager ()->
+ generate_service_context (opdetails, *this);
if (this->messaging_object ()->generate_request_header (opdetails,
spec,
@@ -337,32 +245,6 @@ TAO_Transport::generate_request_header (
return 0;
}
-
-/*
- * NOTE: Some of these calls looks like ideal fodder for
- * inlining. But, please note that the calls made within the method
- * are not inlined. This would increase closure cost on the
- * compiler.
- */
-void
-TAO_Transport::connection_handler_closing (void)
-{
- // The connection has closed, we must invalidate the handler to
- // ensure that any attempt to use this transport results in an
- // error. Basically all the other methods in the Transport
- // cooperate via check_event_handler_i()
-
- TAO_Connection_Handler * eh = this->invalidate_event_handler ();
- this->send_connection_closed_notifications ();
-
- if (eh != 0)
- {
- // REFCNT: Matches incr_refcnt in XXX_Transport::XXX_Transport
- // REFCNT: Only one of this or close_connection_shared() run
- eh->decr_refcount();
- }
-}
-
// @@TODO: Ideally the following should be inline.
int
TAO_Transport::recache_transport (TAO_Transport_Descriptor_Interface *desc)
@@ -378,7 +260,7 @@ TAO_Transport::recache_transport (TAO_Transport_Descriptor_Interface *desc)
void
TAO_Transport::purge_entry (void)
{
- (void) this->transport_cache_manager ().purge_entry (this->cache_map_entry_);
+ this->transport_cache_manager ().purge_entry (this->cache_map_entry_);
}
int
@@ -393,7 +275,6 @@ TAO_Transport::update_transport (void)
return this->transport_cache_manager ().update_entry (this->cache_map_entry_);
}
-
/*
*
* Methods called and used in the output path of the ORB.
@@ -427,7 +308,6 @@ TAO_Transport::handle_output (void)
return retval;
}
-
int
TAO_Transport::send_message_block_chain (const ACE_Message_Block *mb,
size_t &bytes_transferred,
@@ -435,9 +315,6 @@ TAO_Transport::send_message_block_chain (const ACE_Message_Block *mb,
{
ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->handler_lock_, -1);
- if (this->check_event_handler_i ("Transport::send_message_block_chain") == -1)
- return -1;
-
return this->send_message_block_chain_i (mb,
bytes_transferred,
max_wait_time);
@@ -490,22 +367,22 @@ TAO_Transport::send_message_shared (TAO_Stub *stub,
const ACE_Message_Block *message_block,
ACE_Time_Value *max_wait_time)
{
- int r;
+ int result;
+
{
ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->handler_lock_, -1);
- if (this->check_event_handler_i ("Transport::send_message_shared") == -1)
- return -1;
-
- r = this->send_message_shared_i (stub, message_semantics,
- message_block, max_wait_time);
- }
- if (r == -1)
- {
- this->close_connection ();
+ result =
+ this->send_message_shared_i (stub, message_semantics,
+ message_block, max_wait_time);
}
- return r;
+ if (result == -1)
+ {
+ this->close_connection ();
+ }
+
+ return result;
}
int
@@ -686,74 +563,6 @@ TAO_Transport::send_synch_message_helper_i (TAO_Synch_Queued_Message &synch_mess
return 0;
}
-
-void
-TAO_Transport::close_connection_i (void)
-{
- TAO_Connection_Handler * eh = this->invalidate_event_handler_i ();
- this->close_connection_shared (1, eh);
-}
-
-void
-TAO_Transport::close_connection_no_purge (void)
-{
- TAO_Connection_Handler * eh = this->invalidate_event_handler ();
-
- this->close_connection_shared (0,
- eh);
-}
-
-void
-TAO_Transport::close_connection_shared (int purge,
- TAO_Connection_Handler * eh)
-{
- // Purge the entry
- if (purge)
- {
- this->transport_cache_manager ().purge_entry (this->cache_map_entry_);
- }
-
- if (eh == 0)
- {
- // The connection was already closed
- return;
- }
-
- // Set the event handler in the connection close wait state.
- (void) eh->connection_close_wait ();
-
- // NOTE: If the wait strategy is in blocking mode, then there is no
- // chance that it could be inside the reactor. We can safely skip
- // driving the LF. If <purge> is 0, then we are cleaned up by the
- // cache. So no point in driving the LF either.
- if (this->ws_->non_blocking () && purge)
- {
- // NOTE: This is a work around for BUG 1020. We drive the leader
- // follower for a predetermined amount of time. Ideally this
- // needs to be an ORB option. But this is just the first
- // cut. Doing that will be a todo..
-
- ACE_Time_Value tv (ACE_DEFAULT_TIMEOUT, 0);
- this->orb_core_->leader_follower ().wait_for_event (eh,
- this,
- &tv);
-
- }
-
- // We need to explicitly shut it down to avoid memory leaks.
- if (!eh->successful () ||
- !this->ws_->non_blocking ())
- {
- eh->close_connection ();
- }
-
- this->send_connection_closed_notifications ();
-
- // REFCNT: Matches incr_refcnt in XXX_Transport::XXX_Transport
- // REFCNT: Only one of this or connection_handler_closing() run
- eh->decr_refcount ();
-}
-
int
TAO_Transport::queue_is_empty_i (void)
{
@@ -765,12 +574,7 @@ int
TAO_Transport::schedule_output_i (void)
{
ACE_Event_Handler *eh = this->event_handler_i ();
- if (eh == 0)
- return -1;
-
ACE_Reactor *reactor = eh->reactor ();
- if (reactor == 0)
- return -1;
if (TAO_debug_level > 3)
{
@@ -786,12 +590,7 @@ int
TAO_Transport::cancel_output_i (void)
{
ACE_Event_Handler *eh = this->event_handler_i ();
- if (eh == 0)
- return -1;
-
ACE_Reactor *reactor = eh->reactor ();
- if (reactor == 0)
- return -1;
if (TAO_debug_level > 3)
{
@@ -857,14 +656,11 @@ TAO_Transport::drain_queue (void)
int
TAO_Transport::drain_queue_helper (int &iovcnt, iovec iov[])
{
- if (this->check_event_handler_i ("Transport::drain_queue_helper") == -1)
- return -1;
-
size_t byte_count = 0;
// ... send the message ...
ssize_t retval =
- this->send_i (iov, iovcnt, byte_count);
+ this->send (iov, iovcnt, byte_count);
if (TAO_debug_level == 5)
{
@@ -896,7 +692,7 @@ TAO_Transport::drain_queue_helper (int &iovcnt, iovec iov[])
ACE_DEBUG ((LM_DEBUG,
"TAO (%P|%t) - Transport[%d]::drain_queue_helper, "
"error during %p\n",
- this->id (), "send_i()"));
+ this->id (), "send()"));
}
if (errno == EWOULDBLOCK)
return 0;
@@ -981,14 +777,8 @@ TAO_Transport::drain_queue_i (void)
if (this->flush_timer_pending ())
{
ACE_Event_Handler *eh = this->event_handler_i ();
- if (eh != 0)
- {
- ACE_Reactor *reactor = eh->reactor ();
- if (reactor != 0)
- {
- (void) reactor->cancel_timer (this->flush_timer_id_);
- }
- }
+ ACE_Reactor *reactor = eh->reactor ();
+ reactor->cancel_timer (this->flush_timer_id_);
this->reset_flush_timer ();
}
return 1;
@@ -1063,25 +853,19 @@ TAO_Transport::check_buffering_constraints_i (TAO_Stub *stub,
if (set_timer)
{
ACE_Event_Handler *eh = this->event_handler_i ();
- if (eh != 0)
- {
- ACE_Reactor *reactor = eh->reactor ();
- if (reactor != 0)
- {
- this->current_deadline_ = new_deadline;
- ACE_Time_Value delay =
- new_deadline - ACE_OS::gettimeofday ();
+ ACE_Reactor *reactor = eh->reactor ();
+ this->current_deadline_ = new_deadline;
+ ACE_Time_Value delay =
+ new_deadline - ACE_OS::gettimeofday ();
- if (this->flush_timer_pending ())
- {
- (void) reactor->cancel_timer (this->flush_timer_id_);
- }
- this->flush_timer_id_ =
- reactor->schedule_timer (&this->transport_timer_,
- &this->current_deadline_,
- delay);
- }
+ if (this->flush_timer_pending ())
+ {
+ reactor->cancel_timer (this->flush_timer_id_);
}
+ this->flush_timer_id_ =
+ reactor->schedule_timer (&this->transport_timer_,
+ &this->current_deadline_,
+ delay);
}
return constraints_reached;
@@ -1099,14 +883,6 @@ TAO_Transport::report_invalid_event_handler (const char *caller)
}
}
-TAO_Connection_Handler *
-TAO_Transport::invalidate_event_handler (void)
-{
- ACE_MT (ACE_GUARD_RETURN (ACE_Lock, guard, *this->handler_lock_, 0));
-
- return this->invalidate_event_handler_i ();
-}
-
void
TAO_Transport::send_connection_closed_notifications (void)
{
@@ -1152,7 +928,6 @@ TAO_Transport::send_message_shared_i (TAO_Stub *stub,
max_wait_time);
}
-
// Let's figure out if the message should be queued without trying
// to send first:
int try_sending_first = 1;
@@ -1287,8 +1062,6 @@ TAO_Transport::send_message_shared_i (TAO_Stub *stub,
return 0;
}
-
-
/*
*
* All the methods relevant to the incoming data path of the ORB are
@@ -1296,9 +1069,9 @@ TAO_Transport::send_message_shared_i (TAO_Stub *stub,
*
*/
int
-TAO_Transport::handle_input_i (TAO_Resume_Handle &rh,
- ACE_Time_Value * max_wait_time,
- int /*block*/)
+TAO_Transport::handle_input (TAO_Resume_Handle &rh,
+ ACE_Time_Value * max_wait_time,
+ int /*block*/)
{
if (TAO_debug_level > 3)
{
@@ -1319,9 +1092,8 @@ TAO_Transport::handle_input_i (TAO_Resume_Handle &rh,
"TAO (%P|%t) - Transport[%d]::handle_input_i, "
"error while parsing the head of the queue\n",
this->id()));
-
- this->send_connection_closed_notifications ();
}
+
return retval;
}
@@ -1376,14 +1148,7 @@ TAO_Transport::handle_input_i (TAO_Resume_Handle &rh,
// If there is an error return to the reactor..
if (n <= 0)
- {
- if (n == -1)
- {
- this->send_connection_closed_notifications ();
- }
-
- return n;
- }
+ return n;
if (TAO_debug_level > 2)
{
@@ -1492,7 +1257,6 @@ TAO_Transport::parse_incoming_messages (ACE_Message_Block &block)
"error in incoming message\n",
this->id ()));
- this->send_connection_closed_notifications ();
return -1;
}
}
@@ -1584,7 +1348,7 @@ TAO_Transport::consolidate_message (ACE_Message_Block &incoming,
"error while trying to consolidate\n",
this->id ()));
}
- this->send_connection_closed_notifications ();
+
return -1;
}
@@ -1936,8 +1700,6 @@ TAO_Transport::process_parsed_messages (TAO_Queued_Data *qd,
"received CloseConnection message %p\n",
this->id(), ""));
- this->send_connection_closed_notifications ();
-
// Return a "-1" so that the next stage can take care of
// closing connection and the necessary memory management.
return -1;
@@ -1945,17 +1707,6 @@ TAO_Transport::process_parsed_messages (TAO_Queued_Data *qd,
else if (t == TAO_PLUGGABLE_MESSAGE_REQUEST ||
t == TAO_PLUGGABLE_MESSAGE_LOCATEREQUEST)
{
- // Ready to process a request. Increment the refcount of <this
- // transport>. Theoretically, after handler resumption another
- // thread can access this very same transport and can even close
- // this. To have a valid Transport object for further processing
- // we should increment the refcount. Please see Bug 1382 for
- // more details.
- // REFCNT: Matched by the release before returning.
-
- // This generic class takes care of everything.
- TAO_Transport_Refcount_Guard rg (this);
-
// Let us resume the handle before we go ahead to process the
// request. This will open up the handle for other threads.
rh.resume_handle ();
@@ -1964,9 +1715,6 @@ TAO_Transport::process_parsed_messages (TAO_Queued_Data *qd,
this,
qd) == -1)
{
- this->send_connection_closed_notifications ();
-
-
// Return a "-1" so that the next stage can take care of
// closing connection and the necessary memory management.
return -1;
@@ -1975,8 +1723,6 @@ TAO_Transport::process_parsed_messages (TAO_Queued_Data *qd,
else if (t == TAO_PLUGGABLE_MESSAGE_REPLY ||
t == TAO_PLUGGABLE_MESSAGE_LOCATEREPLY)
{
- // Please see ..else if (XXX_REQUEST) for whys and whats..
- TAO_Transport_Refcount_Guard rg (this);
rh.resume_handle ();
// @@todo: Maybe the input_cdr can be constructed from the
@@ -1993,7 +1739,6 @@ TAO_Transport::process_parsed_messages (TAO_Queued_Data *qd,
"error in process_reply_message %p\n",
this->id (), ""));
- this->send_connection_closed_notifications ();
return -1;
}
@@ -2009,7 +1754,6 @@ TAO_Transport::process_parsed_messages (TAO_Queued_Data *qd,
"dispatch reply failed\n",
this->id ()));
- this->send_connection_closed_notifications ();
return -1;
}
@@ -2160,25 +1904,10 @@ TAO_Transport::notify_reactor (void)
ACE_Event_Handler *eh =
this->event_handler_i ();
- if (eh == 0)
- return -1;
-
// Get the reactor associated with the event handler
ACE_Reactor *reactor =
this->orb_core ()->reactor ();
- if (reactor == 0)
- return -1;
-
- // NOTE: Instead of creating the handler seperately, it would be
- // awesome if we could create the handler when we create the
- // TAO_Queued_Data. That would save us an allocation.
- TAO_Notify_Handler *nh =
- TAO_Notify_Handler::create_handler (
- this,
- eh->get_handle (),
- this->orb_core ()->transport_message_buffer_allocator ());
-
if (TAO_debug_level > 0)
{
ACE_DEBUG ((LM_DEBUG,
@@ -2189,7 +1918,7 @@ TAO_Transport::notify_reactor (void)
// Send a notification to the reactor...
- int retval = reactor->notify (nh,
+ int retval = reactor->notify (eh,
ACE_Event_Handler::READ_MASK);
if (retval < 0 && TAO_debug_level > 2)
@@ -2226,7 +1955,17 @@ TAO_Transport::assign_translators (TAO_InputCDR *inp, TAO_OutputCDR *outp)
}
}
+ACE_Event_Handler::Reference_Count
+TAO_Transport::add_reference (void)
+{
+ return this->event_handler_i ()->add_reference ();
+}
+ACE_Event_Handler::Reference_Count
+TAO_Transport::remove_reference (void)
+{
+ return this->event_handler_i ()->remove_reference ();
+}
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
diff --git a/TAO/tao/Transport.h b/TAO/tao/Transport.h
index e78fa5ea664..d329759ac16 100644
--- a/TAO/tao/Transport.h
+++ b/TAO/tao/Transport.h
@@ -28,7 +28,6 @@
#include "Transport_Cache_Manager.h"
#include "Transport_Timer.h"
#include "Incoming_Message_Queue.h"
-#include "Synch_Refcountable.h"
class TAO_ORB_Core;
class TAO_Target_Specification;
@@ -209,7 +208,7 @@ class TAO_Stub;
* http://deuce.doc.wustl.edu/cvsweb/ace-latest.cgi/ACE_wrappers/TAO/docs/pluggable_protocols/index.html
*
*/
-class TAO_Export TAO_Transport : private TAO_Synch_Refcountable
+class TAO_Export TAO_Transport
{
public:
@@ -220,10 +219,6 @@ public:
/// destructor
virtual ~TAO_Transport (void);
- // Maintain reference counting with these
- static TAO_Transport* _duplicate (TAO_Transport* transport);
- static void release (TAO_Transport* transport);
-
/// Return the protocol tag.
/**
* The OMG assigns unique tags (a 32-bit unsigned number) to each
@@ -289,20 +284,14 @@ public:
*/
int queue_is_empty (void);
- /// Fill in a handle_set with any associated handler's reactor handle.
+ /// Added event handler to the handlers set.
/**
- * Called by the cache when the cache is closing in order to fill
- * in a handle_set in a thread-safe manner.
- *
- * @param reactor_registered the ACE_Handle_Set into which the
- * transport should place any handle registered with the reactor
+ * Called by the cache when the cache is closing.
*
- * @param unregistered the TAO_EventHandlerSet into which the
- * transport should place any event handler that is not registered
- * with anyone
+ * @param handlers the TAO_Connection_Handler_Set into which the
+ * transport should place its handler
*/
- void provide_handle (ACE_Handle_Set &reactor_registered,
- TAO_EventHandlerSet &unregistered);
+ void provide_handler (TAO_Connection_Handler_Set &handlers);
/// Remove all messages from the outgoing queue.
@@ -311,13 +300,18 @@ public:
*/
// void dequeue_all (void);
+ /// Register the handler with the reactor.
/**
* Register the handler with the reactor. This method is used by the
* Wait_On_Reactor strategy. The transport must register its event
* handler with the ORB's Reactor.
+ *
+ * @todo: I think this method is pretty much useless, the
+ * connections are *always* registered with the Reactor, except in
+ * thread-per-connection mode. In that case putting the connection
+ * in the Reactor would produce unpredictable results anyway.
*/
- int register_handler (void);
-
+ virtual int register_handler (void);
/// Write the complete Message_Block chain to the connection.
/**
@@ -357,9 +351,9 @@ public:
* down). In that case, it returns -1 and sets errno to
* <code>ENOENT</code>.
*/
- ssize_t send (iovec *iov, int iovcnt,
- size_t &bytes_transferred,
- const ACE_Time_Value *timeout = 0);
+ virtual ssize_t send (iovec *iov, int iovcnt,
+ size_t &bytes_transferred,
+ const ACE_Time_Value *timeout = 0) = 0;
/// Read len bytes from into buf.
/**
@@ -371,9 +365,9 @@ public:
* not clear this this is the best place to specify this. The actual
* timeout values will be kept in the Policies.
*/
- ssize_t recv (char *buffer,
- size_t len,
- const ACE_Time_Value *timeout = 0);
+ virtual ssize_t recv (char *buffer,
+ size_t len,
+ const ACE_Time_Value *timeout = 0) = 0;
/**
* @name Control connection lifecycle
@@ -411,14 +405,18 @@ public:
virtual int messaging_init (CORBA::Octet major,
CORBA::Octet minor) = 0;
-
-
/// Extracts the list of listen points from the <cdr> stream. The
/// list would have the protocol specific details of the
/// ListenPoints
virtual int tear_listen_point_list (TAO_InputCDR &cdr);
-protected:
+ /// Memory management routines.
+ /*
+ * Forwards to event handler.
+ */
+ ACE_Event_Handler::Reference_Count add_reference (void);
+ ACE_Event_Handler::Reference_Count remove_reference (void);
+
/** @name Template methods
*
* The Transport class uses the Template Method Pattern to implement
@@ -445,71 +443,14 @@ protected:
*/
virtual ACE_Event_Handler * event_handler_i (void) = 0;
- virtual TAO_Connection_Handler * connection_handler_i (void) = 0;
+protected:
- /// Called by <code>connection_handler_closing()</code> to signal
- /// that the protocol-specific transport should dissociate itself
- /// with the protocol-specific connection handler.
- /**
- * Typically, this just sets the pointer to the associated connection
- * handler to zero, although it could also clear out any additional
- * resources associated with the handler association.
- *
- * @return The old event handler
- */
- virtual TAO_Connection_Handler * invalidate_event_handler_i (void) = 0;
+ virtual TAO_Connection_Handler * connection_handler_i (void) = 0;
/// Return the messaging object that is used to format the data that
/// needs to be sent.
virtual TAO_Pluggable_Messaging * messaging_object (void) = 0;
- /// Write the complete iovec chain to the connection.
- /**
- * Often the implementation simply forwards the arguments to the
- * underlying ACE_Svc_Handler class. Using the code factored out
- * into ACE.
- *
- * Be careful with protocols that perform non-trivial
- * transformations of the data, such as SSLIOP or protocols that
- * compress the stream.
- *
- * @param iov contains the data that must be sent.
- *
- * @param iovcnt is the number of iovec structures in the list
- * where iov points.
- *
- * @param bytes_transferred should return the total number of bytes
- * successfully transferred before the connection blocked. This is
- * required because in some platforms and/or protocols multiple
- * system calls may be required to send the chain of message
- * blocks. The first few calls can work successfully, but the final
- * one can fail or signal a flow control situation (via EAGAIN).
- * In this case the ORB expects the function to return -1, errno to
- * be appropriately set and this argument to return the number of
- * bytes already on the OS I/O subsystem.
- *
- * @param timeout is the maximum time that the application is
- * willing to wait for the data to be sent, useful in platforms that
- * implement timed writes.
- * The timeout value is obtained from the policies set by the
- * application.
- *
- */
- virtual ssize_t send_i (iovec *iov, int iovcnt,
- size_t &bytes_transferred,
- const ACE_Time_Value *timeout = 0) = 0;
-
- // Read len bytes from into buf.
- /**
- * @param buffer ORB allocated buffer where the data should be
- * @@ The ACE_Time_Value *s is just a place holder for now. It is
- * not clear this this is the best place to specify this. The actual
- * timeout values will be kept in the Policies.
- */
- virtual ssize_t recv_i (char *buffer,
- size_t len,
- const ACE_Time_Value *timeout = 0) = 0;
-
public:
/// This is a request for the transport object to write a
@@ -527,10 +468,6 @@ public:
/// recache ourselves in the cache
int recache_transport (TAO_Transport_Descriptor_Interface* desc);
- /// Method for the connection handler to signify that it
- /// is being closed and destroyed.
- virtual void connection_handler_closing (void);
-
/// Callback to read incoming data
/**
* The ACE_Event_Handler adapter invokes this method as part of its
@@ -550,10 +487,9 @@ public:
* @param block Is deprecated and ignored.
*
*/
- virtual int handle_input_i (TAO_Resume_Handle &rh,
- ACE_Time_Value *max_wait_time = 0,
- int block = 0);
-
+ virtual int handle_input (TAO_Resume_Handle &rh,
+ ACE_Time_Value *max_wait_time = 0,
+ int block = 0);
enum
{
@@ -562,8 +498,6 @@ public:
TAO_REPLY
};
-
-
/// Prepare the waiting and demuxing strategy to receive a reply for
/// a new request.
/**
@@ -633,19 +567,7 @@ public:
const ACE_Message_Block *message_block,
ACE_Time_Value *max_wait_time);
-
protected:
- /// Register the handler with the reactor.
- /**
- * This method is used by the Wait_On_Reactor strategy. The
- * transport must register its event handler with the ORB's Reactor.
- *
- * @todo: I think this method is pretty much useless, the
- * connections are *always* registered with the Reactor, except in
- * thread-per-connection mode. In that case putting the connection
- * in the Reactor would produce unpredictable results anyway.
- */
- virtual int register_handler_i (void) = 0;
/// Called by the handle_input_i (). This method is used to parse
/// message read by the handle_input_i () call. It also decides
@@ -677,9 +599,7 @@ protected:
int consolidate_fragments (TAO_Queued_Data *qd,
TAO_Resume_Handle &rh);
-
-
- /// First consolidate the message queue. If the message is still not
+ /// First consolidate the message queue. If the message is still not
/// complete, try to read from the handle again to make it
/// complete. If these dont help put the message back in the queue
/// and try to check the queue if we have message to process. (the
@@ -703,31 +623,20 @@ protected:
/// Make a queued data from the <incoming> message block
TAO_Queued_Data *make_queued_data (ACE_Message_Block &incoming);
- /// Implement send_message_shared() assuming the handler_lock_ is
+ /// Implement send_message_shared() assuming the handler_lock_ is
/// held.
int send_message_shared_i (TAO_Stub *stub,
int message_semantics,
const ACE_Message_Block *message_block,
ACE_Time_Value *max_wait_time);
- /// Check if the underlying event handler is still valid.
- /**
- * @return Returns -1 if not, 0 if it is.
- */
- int check_event_handler_i (const char *caller);
-
public:
-
-
-
/// Send a message block chain,
int send_message_block_chain (const ACE_Message_Block *message_block,
size_t &bytes_transferred,
ACE_Time_Value *max_wait_time = 0);
-
-
/// Send a message block chain, assuming the lock is held
int send_message_block_chain_i (const ACE_Message_Block *message_block,
size_t &bytes_transferred,
@@ -787,6 +696,11 @@ public:
/// Set the state of the first_request_ flag to 0
void first_request_sent();
+
+ /// Notify all the components inside a Transport when the underlying
+ /// connection is closed.
+ void send_connection_closed_notifications (void);
+
private:
/// Helper method that returns the Transport Cache Manager.
@@ -876,7 +790,6 @@ private:
/// not pending
void reset_flush_timer (void);
-
/// Print out error messages if the event handler is not valid
void report_invalid_event_handler (const char *caller);
@@ -893,32 +806,9 @@ private:
*/
int notify_reactor (void);
- /// Grab the mutex and then call invalidate_event_handler_i()
- TAO_Connection_Handler * invalidate_event_handler (void);
-
- /// Notify all the components inside a Transport when the underlying
- /// connection is closed.
- void send_connection_closed_notifications (void);
-
/// Assume the lock is held
void send_connection_closed_notifications_i (void);
- /// Implement close_connection() assuming the handler_lock_ is held.
- void close_connection_i (void);
-
- /// This class needs priviledged access to:
- /// close_connection_no_purge ()
- friend class TAO_Transport_Cache_Manager;
-
- /// Close the underlying connection, do not purge the entry from the
- /// map (supposedly it was purged already, trust the caller, yuck!)
- void close_connection_no_purge (void);
-
- /// Close the underlying connection, implements the code shared by
- /// all the close_connection_* variants.
- void close_connection_shared (int purge,
- TAO_Connection_Handler * eh);
-
/// Prohibited
ACE_UNIMPLEMENTED_FUNC (TAO_Transport (const TAO_Transport&))
ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_Transport&))
@@ -1005,6 +895,7 @@ protected:
unsigned long purging_order_;
private:
+
/// @@Phil, I think it would be nice if we could think of a way to
/// do the following.
/// We have been trying to use the transport for marking about
diff --git a/TAO/tao/Transport.inl b/TAO/tao/Transport.inl
index 53da1d841b9..ab9770b43f4 100644
--- a/TAO/tao/Transport.inl
+++ b/TAO/tao/Transport.inl
@@ -44,7 +44,6 @@ TAO_Transport::cache_map_entry (void)
return this->cache_map_entry_;
}
-
ACE_INLINE void
TAO_Transport::cache_map_entry (
TAO_Transport_Cache_Manager::HASH_MAP_ENTRY *entry)
@@ -90,8 +89,6 @@ TAO_Transport::queue_is_empty (void)
return this->queue_is_empty_i ();
}
-
-
ACE_INLINE int
TAO_Transport::flush_timer_pending (void) const
{
@@ -105,20 +102,6 @@ TAO_Transport::reset_flush_timer (void)
this->current_deadline_ = ACE_Time_Value::zero;
}
-ACE_INLINE int
-TAO_Transport::check_event_handler_i (const char *caller)
-{
- // if there's no associated event handler, then we act like a null
- // transport
- if (this->event_handler_i () == 0)
- {
- this->report_invalid_event_handler (caller);
- errno = ENOENT;
- return -1;
- }
- return 0;
-}
-
//********************************************************************
// codeset related methods
@@ -162,17 +145,17 @@ TAO_Transport::first_request_sent (void)
this->first_request_ = 0;
}
-
-
/*****************************************************/
+
ACE_INLINE
TAO_Transport_Refcount_Guard::TAO_Transport_Refcount_Guard (TAO_Transport *t)
- :tr_ (TAO_Transport::_duplicate (t))
+ : tr_ (t)
{
+ this->tr_->add_reference ();
}
ACE_INLINE
TAO_Transport_Refcount_Guard::~TAO_Transport_Refcount_Guard (void)
{
- TAO_Transport::release (this->tr_);
+ this->tr_->remove_reference ();
}
diff --git a/TAO/tao/Transport_Cache_Manager.cpp b/TAO/tao/Transport_Cache_Manager.cpp
index de48e770861..b6a4ccae4ab 100644
--- a/TAO/tao/Transport_Cache_Manager.cpp
+++ b/TAO/tao/Transport_Cache_Manager.cpp
@@ -13,12 +13,10 @@
# include "tao/Transport_Cache_Manager.inl"
#endif /* __ACE_INLINE__ */
-
ACE_RCSID (TAO,
Transport_Cache_Manager,
"$Id$")
-
TAO_Transport_Cache_Manager::TAO_Transport_Cache_Manager (TAO_ORB_Core &orb_core)
: percent_ (orb_core.resource_factory ()->purge_percentage ()),
purging_strategy_ (orb_core.resource_factory ()->create_purging_strategy ()),
@@ -98,8 +96,6 @@ TAO_Transport_Cache_Manager::bind_i (TAO_Cache_ExtId &ext_id,
// are holding our lock
this->purging_strategy_->update_item (int_id.transport ());
-
-
int retval = this->cache_map_.bind (ext_id,
int_id,
entry);
@@ -119,7 +115,6 @@ TAO_Transport_Cache_Manager::bind_i (TAO_Cache_ExtId &ext_id,
"Trying with a new index\n"));
}
-
// There was an entry like this before, so let us do some
// minor adjustments and rebind
retval = this->get_last_index_bind (ext_id,
@@ -195,8 +190,6 @@ TAO_Transport_Cache_Manager::find (const TAO_Cache_ExtId &key,
return status;
}
-
-
int
TAO_Transport_Cache_Manager::find_i (const TAO_Cache_ExtId &key,
TAO_Cache_IntId &value)
@@ -284,7 +277,6 @@ TAO_Transport_Cache_Manager::make_idle_i (HASH_MAP_ENTRY *&entry)
return 0;
}
-
int
TAO_Transport_Cache_Manager::update_entry (HASH_MAP_ENTRY *&entry)
{
@@ -307,8 +299,7 @@ TAO_Transport_Cache_Manager::update_entry (HASH_MAP_ENTRY *&entry)
}
int
-TAO_Transport_Cache_Manager::close_i (ACE_Handle_Set &reactor_registered,
- TAO_EventHandlerSet &unregistered)
+TAO_Transport_Cache_Manager::close_i (TAO_Connection_Handler_Set &handlers)
{
HASH_MAP_ITER end_iter =
this->cache_map_.end ();
@@ -322,10 +313,8 @@ TAO_Transport_Cache_Manager::close_i (ACE_Handle_Set &reactor_registered,
if ((*iter).int_id_.recycle_state () != ACE_RECYCLABLE_CLOSED)
{
- // Get the transport to fill its associated connection's handle in
- // the handle sets.
- (*iter).int_id_.transport ()->provide_handle (reactor_registered,
- unregistered);
+ // Get the transport to fill its associated connection's handler.
+ (*iter).int_id_.transport ()->provide_handler (handlers);
// Inform the transport that has a reference to the entry in the
// map that we are *gone* now. So, the transport should not use
// the reference to the entry that he has, to acces us *at any
@@ -463,12 +452,13 @@ TAO_Transport_Cache_Manager::purge (void)
int count = 0;
for(int i = 0; count < amount && i < sorted_size; i++)
{
- if (this->is_entry_idle(sorted_set[i]))
+ if (this->is_entry_idle (sorted_set[i]))
{
sorted_set[i]->int_id_.recycle_state (ACE_RECYCLABLE_BUSY);
TAO_Transport* transport = sorted_set[i]->int_id_.transport ();
- if (transports_to_be_closed.push (TAO_Transport::_duplicate(transport)) != 0)
+ transport->add_reference ();
+ if (transports_to_be_closed.push (transport) != 0)
{
ACE_DEBUG ((LM_INFO,
ACE_TEXT ("TAO (%P|%t) - ")
@@ -484,16 +474,6 @@ TAO_Transport_Cache_Manager::purge (void)
transport->id ()));
}
- // We need to save the cache_map_entry before we
- // set it to zero, so we can call purge_entry_i()
- // after we call close_connection_no_purge ().
- HASH_MAP_ENTRY* entry = transport->cache_map_entry ();
-
- // This is a bit ugly, but we must do this to
- // avoid taking and giving locks inside this loop.
- transport->cache_map_entry (0);
- this->purge_entry_i (entry);
-
// Count this as a successful purged entry
count++;
}
@@ -512,8 +492,10 @@ TAO_Transport_Cache_Manager::purge (void)
if (transports_to_be_closed.pop (transport) == 0)
{
if (transport)
- transport->close_connection_no_purge ();
- TAO_Transport::release (transport);
+ {
+ transport->close_connection ();
+ transport->remove_reference ();
+ }
}
}
diff --git a/TAO/tao/Transport_Cache_Manager.h b/TAO/tao/Transport_Cache_Manager.h
index b1a0e43cfe4..d5d16c8c4ff 100644
--- a/TAO/tao/Transport_Cache_Manager.h
+++ b/TAO/tao/Transport_Cache_Manager.h
@@ -17,20 +17,14 @@
#include "tao/Cache_Entries.h"
-
#if !defined (ACE_LACKS_PRAGMA_ONCE)
#define ACE_LACKS_PRAGMA_ONCE
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/Hash_Map_Manager_T.h"
#include "ace/Synch_T.h"
-// #include "tao/TAO_Export.h"
-// #include "tao/Cache_Entries.h"
-// #include "tao/Connection_Purging_Strategy.h"
-
-
class ACE_Handle_Set;
-class ACE_Event_Handler;
+class TAO_Connection_Handler;
class TAO_ORB_Core;
class TAO_Resource_Factory;
class TAO_Connection_Purging_Strategy;
@@ -39,9 +33,7 @@ template <class ACE_COND_MUTEX> class TAO_Condition;
template <class T> class ACE_Unbounded_Set;
template <class T> class ACE_Unbounded_Set_Iterator;
-typedef ACE_Unbounded_Set<ACE_Event_Handler*> TAO_EventHandlerSet;
-typedef ACE_Unbounded_Set_Iterator<ACE_Event_Handler*>
- TAO_EventHandlerSetIterator;
+typedef ACE_Unbounded_Set<TAO_Connection_Handler*> TAO_Connection_Handler_Set;
/**
* @class TAO_Transport_Cache_Manager
@@ -119,10 +111,9 @@ public:
/// strategy policy information.
int update_entry (HASH_MAP_ENTRY *&entry);
- /// Close the underlying hash map manager and return the handle set
- /// that have been registered with the reactor
- int close (ACE_Handle_Set &reactor_registered,
- TAO_EventHandlerSet &unregistered);
+ /// Close the underlying hash map manager and return any handlers
+ /// still registered
+ int close (TAO_Connection_Handler_Set &handlers);
/// Return the current size of the cache.
size_t current_size (void) const;
@@ -169,8 +160,7 @@ private:
int make_idle_i (HASH_MAP_ENTRY *&entry);
/// Non-locking version and actual implementation of close ()
- int close_i (ACE_Handle_Set &reactor_registered,
- TAO_EventHandlerSet &unregistered);
+ int close_i (TAO_Connection_Handler_Set &handlers);
/// Purge the entry from the Cache Map
int purge_entry_i (HASH_MAP_ENTRY *&entry);
diff --git a/TAO/tao/Transport_Cache_Manager.inl b/TAO/tao/Transport_Cache_Manager.inl
index edb29408083..9163ef1907d 100644
--- a/TAO/tao/Transport_Cache_Manager.inl
+++ b/TAO/tao/Transport_Cache_Manager.inl
@@ -108,8 +108,7 @@ TAO_Transport_Cache_Manager::make_idle (HASH_MAP_ENTRY *&entry)
ACE_INLINE int
-TAO_Transport_Cache_Manager::close (ACE_Handle_Set &reactor_registered,
- TAO_EventHandlerSet &unregistered)
+TAO_Transport_Cache_Manager::close (TAO_Connection_Handler_Set &handlers)
{
// The cache lock pointer should only be zero if
// Transport_Cache_Manager::open() was never called. Note that
@@ -123,7 +122,7 @@ TAO_Transport_Cache_Manager::close (ACE_Handle_Set &reactor_registered,
*this->cache_lock_,
-1));
- return this->close_i (reactor_registered, unregistered);
+ return this->close_i (handlers);
}
diff --git a/TAO/tao/Wait_On_Read.cpp b/TAO/tao/Wait_On_Read.cpp
index 572554525fb..36968e49e46 100644
--- a/TAO/tao/Wait_On_Read.cpp
+++ b/TAO/tao/Wait_On_Read.cpp
@@ -36,9 +36,9 @@ TAO_Wait_On_Read::wait (ACE_Time_Value * max_wait_time,
while (1)
{
retval =
- this->transport_->handle_input_i (rh,
- max_wait_time,
- 1);
+ this->transport_->handle_input (rh,
+ max_wait_time,
+ 1);
// If we got our reply, no need to run the loop any
// further.
diff --git a/TAO/tao/tao.mpc b/TAO/tao/tao.mpc
index 4fe533cb167..320491695e2 100644
--- a/TAO/tao/tao.mpc
+++ b/TAO/tao/tao.mpc
@@ -15,7 +15,6 @@ project(TAO) : acelib, taoversion, core, tao_output {
Transport_Connector.cpp
Transport.cpp
Incoming_Message_Queue.cpp
- Notify_Handler.cpp
Resume_Handle.cpp
Profile.cpp
Endpoint.cpp