summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-06-23 23:54:14 +0000
committerirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-06-23 23:54:14 +0000
commit32bff203f4d8fbcf3adf3f3b791fba946d67a453 (patch)
tree6670f24ca84edd8a7e7e97ca288ac9e05c6f6692
parent226b23a815d31c56386e0e437d4302fe100078f2 (diff)
downloadATCD-32bff203f4d8fbcf3adf3f3b791fba946d67a453.tar.gz
ChangeLogTag: Mon Jun 23 19:52:58 2003 Irfan Pyarali <irfan@oomworks.com>
-rw-r--r--TAO/tao/Connector_Impl.cpp6
-rw-r--r--TAO/tao/IIOP_Connector.cpp36
2 files changed, 26 insertions, 16 deletions
diff --git a/TAO/tao/Connector_Impl.cpp b/TAO/tao/Connector_Impl.cpp
index 99026fa52eb..311902f6560 100644
--- a/TAO/tao/Connector_Impl.cpp
+++ b/TAO/tao/Connector_Impl.cpp
@@ -39,6 +39,12 @@ TAO_Connect_Creation_Strategy<SVC_HANDLER>::make_svc_handler (SVC_HANDLER *&sh)
this->arg_),
-1);
+ // We add to the #REFCOUNT# since the Connector needs this. See
+ // Connector::make_connection() for details.
+ svc_handler->add_reference ();
+
+ // At this point, the #REFCOUNT# is two.
+
return 0;
}
diff --git a/TAO/tao/IIOP_Connector.cpp b/TAO/tao/IIOP_Connector.cpp
index af0a9817102..6eae7458051 100644
--- a/TAO/tao/IIOP_Connector.cpp
+++ b/TAO/tao/IIOP_Connector.cpp
@@ -165,22 +165,27 @@ TAO_IIOP_Connector::make_connection (TAO_GIOP_Invocation *invocation,
remote_address,
synch_options);
- // This call creates the service handler. There are three
- // possibilities: (a) connection succeeds immediately - in this
- // case, the #REFCOUNT# on the handler is one; (b) connection
- // completion is pending - in this case, the #REFCOUNT# on the
- // handler is also one; (c) connection fails immediately - in this
- // case, the #REFCOUNT# on the handler is zero since close() gets
- // called on the handler;
+ // 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)
{
- // We add to the #REFCOUNT# since we are going to wait on a
- // variable in the handler to changes, signifying success or
- // failure.
- svc_handler->add_reference ();
-
if (TAO_debug_level > 2)
ACE_DEBUG ((LM_DEBUG,
"TAO (%P|%t) - IIOP_Connector::make_connection, "
@@ -205,10 +210,6 @@ TAO_IIOP_Connector::make_connection (TAO_GIOP_Invocation *invocation,
int closed =
svc_handler->is_finalized ();
- // Irrespective of success or failure, remove the #REFCOUNT#
- // added for waiting.
- svc_handler->remove_reference ();
-
// In case of failure, check if the connection has been closed.
if (result == -1)
{
@@ -222,6 +223,9 @@ TAO_IIOP_Connector::make_connection (TAO_GIOP_Invocation *invocation,
}
}
+ // Irrespective of success or failure, remove the extra #REFCOUNT#.
+ svc_handler->remove_reference ();
+
// In case of errors.
if (result == -1)
{