summaryrefslogtreecommitdiff
path: root/ace/Strategies_T.cpp
diff options
context:
space:
mode:
authorirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-11-23 00:23:25 +0000
committerirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-11-23 00:23:25 +0000
commit3db36701a48c1ea6c171494236498afe31d185b5 (patch)
treefc8b106d85b88ed39b576db02f5d81ecc55aab78 /ace/Strategies_T.cpp
parent7c05b2e70e3a55cdf2200b29af72c57084e0fc63 (diff)
downloadATCD-3db36701a48c1ea6c171494236498afe31d185b5.tar.gz
ChangeLogTag: Mon Nov 22 18:02:19 1999 Irfan Pyarali <irfan@cs.wustl.edu>
Diffstat (limited to 'ace/Strategies_T.cpp')
-rw-r--r--ace/Strategies_T.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/ace/Strategies_T.cpp b/ace/Strategies_T.cpp
index d60ee48a2de..85c7241e4e6 100644
--- a/ace/Strategies_T.cpp
+++ b/ace/Strategies_T.cpp
@@ -620,13 +620,22 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::find_or_c
// Set the flag
found = 0;
+ // We need to use a temporary variable here since we are not
+ // allowed to change <sh> because other threads may use this
+ // when we let go of the lock during the OS level connect.
+ //
+ // Note that making a new svc_handler, connecting remotely,
+ // binding to the map, and assigning of the hint and recycler
+ // should be atomic to the outside world.
+ SVC_HANDLER *potential_handler = 0;
+
// Create a new svc_handler
- if (this->make_svc_handler (sh) == -1)
+ if (this->make_svc_handler (potential_handler) == -1)
return -1;
// Actively establish the connection. This is a timed blocking
// connect.
- if (this->new_connection (sh,
+ if (this->new_connection (potential_handler,
remote_addr,
timeout,
local_addr,
@@ -642,9 +651,8 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::find_or_c
if (errno == EWOULDBLOCK)
errno = ENOTSUP;
- // Close the svc handler and reset <sh>.
- sh->close (0);
- sh = 0;
+ // Close the svc handler.
+ potential_handler->close (0);
return -1;
}
@@ -652,16 +660,18 @@ ACE_Cached_Connect_Strategy<SVC_HANDLER, ACE_PEER_CONNECTOR_2, MUTEX>::find_or_c
{
// Insert the new SVC_HANDLER instance into the cache.
if (this->connection_map_.bind (search_addr,
- sh,
+ potential_handler,
entry) == -1)
{
- // Close the svc handler and reset <sh>.
- sh->close (0);
- sh = 0;
+ // Close the svc handler.
+ potential_handler->close (0);
return -1;
}
+ // Everything succeeded as planned. Assign <sh> to <potential_handler>.
+ sh = potential_handler;
+
// Set the recycler and the recycling act
this->assign_recycler (sh, this, entry);
}