I think the example is broken; it needs a HWM large enough to handle the worst case scenario of most messages being queued.
I've made this change in the C version (ZMQ_SNDHWM set to 1M) and it works. -Pieter On Sun, May 12, 2013 at 5:29 AM, Oleg Vazhnev <[email protected]> wrote: > In > https://github.com/imatix/zguide/blob/master/examples/C%2B%2B/syncpub.cpp > example > it's very possible that client never receive "END" message (and so will > hang). > > This is because zeromq buffer is only 1000 items but we send much more > and it's pretty possible that "END" message will be lost. > > To avoid this it's enough to insert one extra "sleep" call before > sending "END". I.e. change this: > > // Now broadcast exactly 1M updates followed by END > int update_nbr; > for (update_nbr = 0; update_nbr < 1000000; update_nbr++) { > s_send (publisher, "Rhubarb"); > } > > s_send (publisher, "END"); > > sleep (1); // Give 0MQ time to flush output > > > to this: > > // Now broadcast exactly 1M updates followed by END > int update_nbr; > for (update_nbr = 0; update_nbr < 1000000; update_nbr++) { > s_send (publisher, "Rhubarb"); > } > > sleep (1); // Give 0MQ time to flush output > > s_send (publisher, "END"); > > sleep (1); // Give 0MQ time to flush output > > I don't know how can I contribute this change, also I can not test > exactly this code because i'm using Windows and in my code I changed > "sleep(1)" to "Sleep(1000)". > > Probably someone can commit this change if I'm correct. > > Thanks, > Oleg > > _______________________________________________ > zeromq-dev mailing list > [email protected] > http://lists.zeromq.org/mailman/listinfo/zeromq-dev _______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
