summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Hurton <hurtonm@gmail.com>2012-03-22 06:46:04 +0100
committerMartin Sustrik <sustrik@250bpm.com>2012-03-24 09:21:08 +0100
commit13f5bf063e5680966a4c0cff5b34b121ec69a70e (patch)
tree5527fa8eae491446eca9652d0c9e935a4558345e
parent153eaae2dbc816c4edee49666202b3d1172f0b34 (diff)
Fix race condition in find_endpoint
-rw-r--r--src/ctx.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/ctx.cpp b/src/ctx.cpp
index 22c4908..21dec58 100644
--- a/src/ctx.cpp
+++ b/src/ctx.cpp
@@ -327,16 +327,16 @@ xs::endpoint_t xs::ctx_t::find_endpoint (const char *addr_)
endpoint_t empty = {NULL, options_t()};
return empty;
}
- endpoint_t *endpoint = &it->second;
+ endpoint_t endpoint = it->second;
// Increment the command sequence number of the peer so that it won't
// get deallocated until "bind" command is issued by the caller.
// The subsequent 'bind' has to be called with inc_seqnum parameter
// set to false, so that the seqnum isn't incremented twice.
- endpoint->socket->inc_seqnum ();
+ endpoint.socket->inc_seqnum ();
endpoints_sync.unlock ();
- return *endpoint;
+ return endpoint;
}
// The last used socket ID, or 0 if no socket was used so far. Note that this