mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-13 10:52:56 +01:00
Problem: text_xpub_nodrop sometimes fails
Solution: use XPUB and wait for the subscription message rather than using a sleep which might or might not be enough
This commit is contained in:
parent
2f5c2f4a48
commit
0bbd38f5d4
@ -43,7 +43,7 @@ void tearDown ()
|
|||||||
void test ()
|
void test ()
|
||||||
{
|
{
|
||||||
// Create a publisher
|
// Create a publisher
|
||||||
void *pub = test_context_socket (ZMQ_PUB);
|
void *pub = test_context_socket (ZMQ_XPUB);
|
||||||
|
|
||||||
int hwm = 2000;
|
int hwm = 2000;
|
||||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt (pub, ZMQ_SNDHWM, &hwm, 4));
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt (pub, ZMQ_SNDHWM, &hwm, 4));
|
||||||
@ -61,10 +61,9 @@ void test ()
|
|||||||
// Subscribe for all messages.
|
// Subscribe for all messages.
|
||||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt (sub, ZMQ_SUBSCRIBE, "", 0));
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt (sub, ZMQ_SUBSCRIBE, "", 0));
|
||||||
|
|
||||||
// we must wait for the subscription to be processed here, so we just
|
// we must wait for the subscription to be processed here, otherwise some
|
||||||
// hope SETTLE_TIME suffices; otherwise some or all published messages
|
// or all published messages might be lost
|
||||||
// might be lost
|
recv_string_expect_success (pub, "\1", 0);
|
||||||
msleep (SETTLE_TIME);
|
|
||||||
|
|
||||||
int hwmlimit = hwm - 1;
|
int hwmlimit = hwm - 1;
|
||||||
int send_count = 0;
|
int send_count = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user