[zeromq-dev] PUB ZMQ_SNDHWM doesn't work

余志昌 yuzhichang at gmail.com
Wed Jun 11 09:45:42 CEST 2014


I'm using ZeroMQ 3.2.3


2014-06-11 15:29 GMT+08:00 余志昌 <yuzhichang at gmail.com>:

> Hi,
>     I tried to set hwm to zero at both sides of pubsub in order to avoid dropping
> messages. (I'm  file 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));
> if(rc!=0)
>  printf("%s:%d zmq_setsockopt() errno %d!\n", __FILE__, __LINE__, errno);
> assert(rc==0);
>  sndhwm = -9;
> size_t s = sizeof(int);
> rc = zmq_getsockopt(publisher, ZMQ_SNDHWM, &sndhwm, &s);
>  if(rc!=0)
> printf("%s:%d zmq_getsockopt() errno %d!\n", __FILE__, __LINE__, errno);
>  printf("sndhwm: %d\n", sndhwm);
> assert(rc==0);
>  rc = zmq_bind(publisher, SWITCH_OUT);
> if(rc!=0)
>  cerr << __FILE__ << ":" << __LINE__ << " zmq_bind() errno " << errno <<
> endl;
>  assert(rc == 0);
>
> Here's gdb output(hwm is 1000. However I expect it to be zero according to
> ZMQ_SNDHWM option):
>
> (gdb) break pipe.cpp:157
> Breakpoint 2 at 0x7fdbad9a7f30: file ../../src/pipe.cpp, line 157.
> (gdb) c
> Continuing.
>
> Breakpoint 2, zmq::pipe_t::check_write (this=0x134c8c0) at
> ../../src/pipe.cpp:157
> 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/c4c0e41d/attachment.htm>


More information about the zeromq-dev mailing list