summaryrefslogtreecommitdiff
path: root/ACE/ace/Connector.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/ace/Connector.cpp')
-rw-r--r--ACE/ace/Connector.cpp71
1 files changed, 15 insertions, 56 deletions
diff --git a/ACE/ace/Connector.cpp b/ACE/ace/Connector.cpp
index 0934ac62750..d3298942196 100644
--- a/ACE/ace/Connector.cpp
+++ b/ACE/ace/Connector.cpp
@@ -32,10 +32,7 @@ ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::ACE_NonBlocking_Connect_Handler
(ACE_Event_Handler::Reference_Counting_Policy::ENABLED);
if (this->svc_handler_ != 0)
- {
- // If reference counting is not enabled then this does nothing.
- this->svc_handler_->add_reference ();
- }
+ this->svc_handler_->add_reference ();
}
template <class SVC_HANDLER> SVC_HANDLER *
@@ -125,29 +122,18 @@ ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::handle_timeout
ACE_TRACE ("ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::handle_timeout");
SVC_HANDLER *svc_handler = 0;
- int const retval = this->close (svc_handler) ? 0 : -1;
-
- if (svc_handler != 0)
- {
- ACE_Event_Handler_var ref_count_guard;
+ int retval = this->close (svc_handler) ? 0 : -1;
- // We have to remove reference only when reference counting is enabled.
- // Otherwise doing remove_reference() can be unsafe as svc_handler can
- // be destroyed just before the point where we need to remove reference.
- if (svc_handler->reference_counting_policy ().value () ==
- ACE_Event_Handler::Reference_Counting_Policy::ENABLED)
- {
- ref_count_guard.reset (svc_handler);
- }
+ // Forward to the SVC_HANDLER the <arg> that was passed in as a
+ // magic cookie during ACE_Connector::connect(). This gives the
+ // SVC_HANDLER an opportunity to take corrective action (e.g., wait
+ // a few milliseconds and try to reconnect again.
+ if (svc_handler != 0 && svc_handler->handle_timeout (tv, arg) == -1)
+ svc_handler->handle_close (svc_handler->get_handle (),
+ ACE_Event_Handler::TIMER_MASK);
- // Forward to the SVC_HANDLER the <arg> that was passed in as a
- // magic cookie during ACE_Connector::connect(). This gives the
- // SVC_HANDLER an opportunity to take corrective action (e.g., wait
- // a few milliseconds and try to reconnect again.
- if (svc_handler->handle_timeout (tv, arg) == -1)
- svc_handler->handle_close (svc_handler->get_handle (),
- ACE_Event_Handler::TIMER_MASK);
- }
+ if (svc_handler != 0)
+ svc_handler->remove_reference ();
return retval;
}
@@ -166,18 +152,9 @@ ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::handle_input (ACE_HANDLE)
// Close Svc_Handler.
if (svc_handler != 0)
{
- ACE_Event_Handler_var ref_count_guard;
-
- // We have to remove reference only when reference counting is enabled.
- // Otherwise doing remove_reference() can be unsafe as svc_handler can
- // be destroyed just before the point where we need to remove reference.
- if (svc_handler->reference_counting_policy ().value () ==
- ACE_Event_Handler::Reference_Counting_Policy::ENABLED)
- {
- ref_count_guard.reset (svc_handler);
- }
-
svc_handler->close (NORMAL_CLOSE_OPERATION);
+
+ svc_handler->remove_reference ();
}
return retval;
@@ -196,18 +173,9 @@ ACE_NonBlocking_Connect_Handler<SVC_HANDLER>::handle_output (ACE_HANDLE handle)
if (svc_handler != 0)
{
- ACE_Event_Handler_var ref_count_guard;
-
- // We have to remove reference only when reference counting is enabled.
- // Otherwise doing remove_reference() can be unsafe as svc_handler can
- // be destroyed just before the point where we need to remove reference.
- if (svc_handler->reference_counting_policy ().value () ==
- ACE_Event_Handler::Reference_Counting_Policy::ENABLED)
- {
- ref_count_guard.reset (svc_handler);
- }
-
connector.initialize_svc_handler (handle, svc_handler);
+
+ svc_handler->remove_reference ();
}
return retval;
@@ -736,15 +704,6 @@ ACE_Connector<SVC_HANDLER, ACE_PEER_CONNECTOR_2>::close (void)
}
SVC_HANDLER *svc_handler = nbch->svc_handler ();
- // Since nbch holds a reference to svc_handler we have to
- // free it here as there will be no other chance to do it.
- ACE_Event_Handler_var ref_count_guard;
- if (svc_handler->reference_counting_policy ().value () ==
- ACE_Event_Handler::Reference_Counting_Policy::ENABLED)
- {
- ref_count_guard.reset (svc_handler);
- }
-
// Cancel the non-blocking connection.
this->cancel (svc_handler);