summaryrefslogtreecommitdiff
path: root/src/ctx.cpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-01-10 13:53:30 +0100
committerMartin Sustrik <sustrik@250bpm.com>2011-01-10 13:53:30 +0100
commitbd0ba6e89a709cc8afbd5a7c3c4f9f533c428249 (patch)
tree4b63b8e4f9d222dfcdc66cf0e20859fa17826610 /src/ctx.cpp
parentbabdf48aacc585d57457da8dec1fb6ce262bf719 (diff)
Size of inproc hwm and swap is sum of peers' hwms and swaps
The meat of the patch was contributed by Douglas Creager. Martin Sustrik implemented storing peer options in inproc endpoint repository. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/ctx.cpp')
-rw-r--r--src/ctx.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/ctx.cpp b/src/ctx.cpp
index 59ba2db..3849497 100644
--- a/src/ctx.cpp
+++ b/src/ctx.cpp
@@ -242,13 +242,12 @@ zmq::io_thread_t *zmq::ctx_t::choose_io_thread (uint64_t affinity_)
return io_threads [result];
}
-int zmq::ctx_t::register_endpoint (const char *addr_,
- socket_base_t *socket_)
+int zmq::ctx_t::register_endpoint (const char *addr_, endpoint_t &endpoint_)
{
endpoints_sync.lock ();
bool inserted = endpoints.insert (endpoints_t::value_type (
- std::string (addr_), socket_)).second;
+ std::string (addr_), endpoint_)).second;
if (!inserted) {
errno = EADDRINUSE;
endpoints_sync.unlock ();
@@ -265,7 +264,7 @@ void zmq::ctx_t::unregister_endpoints (socket_base_t *socket_)
endpoints_t::iterator it = endpoints.begin ();
while (it != endpoints.end ()) {
- if (it->second == socket_) {
+ if (it->second.socket == socket_) {
endpoints_t::iterator to_erase = it;
it++;
endpoints.erase (to_erase);
@@ -277,7 +276,7 @@ void zmq::ctx_t::unregister_endpoints (socket_base_t *socket_)
endpoints_sync.unlock ();
}
-zmq::socket_base_t *zmq::ctx_t::find_endpoint (const char *addr_)
+zmq::endpoint_t zmq::ctx_t::find_endpoint (const char *addr_)
{
endpoints_sync.lock ();
@@ -285,18 +284,19 @@ zmq::socket_base_t *zmq::ctx_t::find_endpoint (const char *addr_)
if (it == endpoints.end ()) {
endpoints_sync.unlock ();
errno = ECONNREFUSED;
- return NULL;
+ endpoint_t empty = {NULL, options_t()};
+ return empty;
}
- socket_base_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->inc_seqnum ();
+ endpoint->socket->inc_seqnum ();
endpoints_sync.unlock ();
- return endpoint;
+ return *endpoint;
}
void zmq::ctx_t::log (zmq_msg_t *msg_)