summaryrefslogtreecommitdiff
path: root/src/socket_base.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/socket_base.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/socket_base.cpp')
-rw-r--r--src/socket_base.cpp34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/socket_base.cpp b/src/socket_base.cpp
index f48b48b..5c21b8f 100644
--- a/src/socket_base.cpp
+++ b/src/socket_base.cpp
@@ -300,8 +300,10 @@ int zmq::socket_base_t::bind (const char *addr_)
if (rc != 0)
return -1;
- if (protocol == "inproc" || protocol == "sys")
- return register_endpoint (addr_, this);
+ if (protocol == "inproc" || protocol == "sys") {
+ endpoint_t endpoint = {this, options};
+ return register_endpoint (addr_, endpoint);
+ }
if (protocol == "tcp" || protocol == "ipc") {
@@ -361,24 +363,38 @@ int zmq::socket_base_t::connect (const char *addr_)
// as there's no 'reconnect' functionality implemented. Once that
// is in place we should follow generic pipe creation algorithm.
- // Find the peer socket.
- socket_base_t *peer = find_endpoint (addr_);
- if (!peer)
+ // Find the peer endpoint.
+ endpoint_t peer = find_endpoint (addr_);
+ if (!peer.socket)
return -1;
reader_t *inpipe_reader = NULL;
writer_t *inpipe_writer = NULL;
reader_t *outpipe_reader = NULL;
writer_t *outpipe_writer = NULL;
-
+
+ // The total HWM for an inproc connection should be the sum of
+ // the binder's HWM and the connector's HWM. (Similarly for the
+ // SWAP.)
+ int64_t hwm;
+ if (options.hwm == 0 || peer.options.hwm == 0)
+ hwm = 0;
+ else
+ hwm = options.hwm + peer.options.hwm;
+ int64_t swap;
+ if (options.swap == 0 && peer.options.swap == 0)
+ swap = 0;
+ else
+ swap = options.swap + peer.options.swap;
+
// Create inbound pipe, if required.
if (options.requires_in)
- create_pipe (this, peer, options.hwm, options.swap,
+ create_pipe (this, peer.socket, hwm, swap,
&inpipe_reader, &inpipe_writer);
// Create outbound pipe, if required.
if (options.requires_out)
- create_pipe (peer, this, options.hwm, options.swap,
+ create_pipe (peer.socket, this, hwm, swap,
&outpipe_reader, &outpipe_writer);
// Attach the pipes to this socket object.
@@ -387,7 +403,7 @@ int zmq::socket_base_t::connect (const char *addr_)
// Attach the pipes to the peer socket. Note that peer's seqnum
// was incremented in find_endpoint function. We don't need it
// increased here.
- send_bind (peer, outpipe_reader, inpipe_writer,
+ send_bind (peer.socket, outpipe_reader, inpipe_writer,
options.identity, false);
return 0;