From 5adcb83509af4b9701c985be153e9d038882a0d5 Mon Sep 17 00:00:00 2001 From: laplaceyang Date: Mon, 9 Jan 2017 12:34:40 +0800 Subject: [PATCH] Problem: set hwm after connect lead to infinite hwm --- src/pipe.cpp | 9 +++++++-- src/pipe.hpp | 3 +++ src/socket_base.cpp | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/pipe.cpp b/src/pipe.cpp index 22e7a959..0b4b1e1e 100644 --- a/src/pipe.cpp +++ b/src/pipe.cpp @@ -83,8 +83,8 @@ zmq::pipe_t::pipe_t (object_t *parent_, upipe_t *inpipe_, upipe_t *outpipe_, out_active (true), hwm (outhwm_), lwm (compute_lwm (inhwm_)), - inhwmboost(0), - outhwmboost(0), + inhwmboost(1), + outhwmboost(1), msgs_read (0), msgs_written (0), peers_msgs_read (0), @@ -522,6 +522,11 @@ void zmq::pipe_t::set_hwms (int inhwm_, int outhwm_) hwm = out; } +void zmq::pipe_t::set_peer_hwms (int inhwm_, int outhwm_) +{ + peer->set_hwms(inhwm_, outhwm_); +} + void zmq::pipe_t::set_hwms_boost(int inhwmboost_, int outhwmboost_) { inhwmboost = inhwmboost_; diff --git a/src/pipe.hpp b/src/pipe.hpp index cae54565..66123b14 100644 --- a/src/pipe.hpp +++ b/src/pipe.hpp @@ -133,6 +133,9 @@ namespace zmq // Set the high water marks. void set_hwms (int inhwm_, int outhwm_); + // Set the high water marks for peer. + void set_peer_hwms (int inhwm_, int outhwm_); + // Set the boost to high water marks, used by inproc sockets so total hwm are sum of connect and bind sockets watermarks void set_hwms_boost(int inhwmboost_, int outhwmboost_); diff --git a/src/socket_base.cpp b/src/socket_base.cpp index 7508f189..c8092dc8 100644 --- a/src/socket_base.cpp +++ b/src/socket_base.cpp @@ -1414,6 +1414,7 @@ void zmq::socket_base_t::update_pipe_options(int option_) for (pipes_t::size_type i = 0; i != pipes.size(); ++i) { pipes[i]->set_hwms(options.rcvhwm, options.sndhwm); + pipes[i]->set_peer_hwms(options.sndhwm, options.rcvhwm); } }