[zeromq-dev] PUB ZMQ_SNDHWM doesn't work

余志昌 yuzhichang at gmail.com
Wed Jun 11 09:18:43 CEST 2014

    I tried to set hwm to zero at both sides of pubsub in order to
avoid dropping
messages. (I'm  aware with possible memory overflow at this time.)
    However the PUB side ZMQ_SNDHWM customization doesn't work. Here's my
PUB side code piece:

// Socket to send messages to
void *publisher = zmq_socket(context, ZMQ_PUB);

// Raise the high water mark for outbound messages to unlimited.
int sndhwm = 0;
rc = zmq_setsockopt(publisher, ZMQ_SNDHWM, &sndhwm, sizeof(int));
printf("%s:%d zmq_setsockopt() errno %d!\n", __FILE__, __LINE__, errno);
sndhwm = -9;
size_t s = sizeof(int);
rc = zmq_getsockopt(publisher, ZMQ_SNDHWM, &sndhwm, &s);
printf("%s:%d zmq_getsockopt() errno %d!\n", __FILE__, __LINE__, errno);
printf("sndhwm: %d\n", sndhwm);
 rc = zmq_bind(publisher, SWITCH_OUT);
cerr << __FILE__ << ":" << __LINE__ << " zmq_bind() errno " << errno <<
assert(rc == 0);

Here's gdb output(hwm is 1000. This doesn't match my expectation):

(gdb) break pipe.cpp:157
Breakpoint 2 at 0x7fdbad9a7f30: file ../../src/pipe.cpp, line 157.
(gdb) c

Breakpoint 2, zmq::pipe_t::check_write (this=0x134c8c0) at
157 in ../../src/pipe.cpp
(gdb) bt
#0  zmq::pipe_t::check_write (this=0x134c8c0) at ../../src/pipe.cpp:157
#1  0x00007fdbad9a95a3 in zmq::pipe_t::write (this=0x134c8c0,
msg_=0x7fff1280abf0) at ../../src/pipe.cpp:166
#2  0x00007fdbad99be01 in zmq::dist_t::write (this=0x1302cb8,
pipe_=0x134c8c0, msg_=0x3e8) at ../../src/dist.cpp:181
#3  0x00007fdbad99bf93 in zmq::dist_t::distribute (this=0x1302cb8,
msg_=0x7fff1280abf0, flags_=<value optimized out>) at ../../src/dist.cpp:145
#4  0x00007fdbad99c17e in zmq::dist_t::send_to_matching (this=0x1302cb8,
msg_=0x7fff1280abf0, flags_=2) at ../../src/dist.cpp:118
#5  0x00007fdbad9bc2be in zmq::xpub_t::xsend (this=0x1302900,
msg_=0x7fff1280abf0, flags_=2) at ../../src/xpub.cpp:129
#6  0x00007fdbad9b02d0 in zmq::socket_base_t::send (this=0x1302900,
msg_=0x7fff1280abf0, flags_=2) at ../../src/socket_base.cpp:656
#7  0x00007fdbad9c365a in s_sendmsg (s_=0x1302900, msg_=0x7fff1280abf0,
flags_=2) at ../../src/zmq.cpp:337
#8  0x00007fdbad9c3c7e in zmq_send (s_=0x1302900, buf_=0x12f4110, len_=2,
flags_=2) at ../../src/zmq.cpp:362
#9  0x0000000000404810 in main (argc=<value optimized out>, argv=<value
optimized out>) at ../src/switch.cpp:395
(gdb) p hwm
$1 = 1000
(gdb) p lwm
$2 = 500
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140611/6b4989af/attachment.htm>

More information about the zeromq-dev mailing list