From 7836ec752c87b74e380c9ecab0c0cf0291ea358c Mon Sep 17 00:00:00 2001 From: jean-airoldie <25088801+jean-airoldie@users.noreply.github.com> Date: Wed, 15 May 2019 05:32:45 -0400 Subject: [PATCH 1/2] Problem: Potentially unitialized variable in #3508 Solution: Initialized it --- tests/test_monitor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_monitor.cpp b/tests/test_monitor.cpp index c4447742..2bc11d6a 100644 --- a/tests/test_monitor.cpp +++ b/tests/test_monitor.cpp @@ -155,7 +155,7 @@ void test_monitor_versioned_typed_basic (bind_function_t bind_function_, server, "inproc://monitor-server", ZMQ_EVENT_ALL_V2, 2, type_)); // Choose the appropriate consumer socket type. - int mon_type; + int mon_type = ZMQ_PAIR; switch (type_) { case ZMQ_PAIR: mon_type = ZMQ_PAIR; From 8738ada00f3c52ec7b53c8feb30b6fbbfa1f1b50 Mon Sep 17 00:00:00 2001 From: jean-airoldie <25088801+jean-airoldie@users.noreply.github.com> Date: Wed, 15 May 2019 06:27:01 -0400 Subject: [PATCH 2/2] Problem: Endpoints are sometimes not unbound quick enough Solution: Create a unique endpoint for each fcn call. --- tests/test_monitor.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/tests/test_monitor.cpp b/tests/test_monitor.cpp index 2bc11d6a..b47e8a10 100644 --- a/tests/test_monitor.cpp +++ b/tests/test_monitor.cpp @@ -143,6 +143,15 @@ void test_monitor_versioned_typed_basic (bind_function_t bind_function_, int type_) { char server_endpoint[MAX_SOCKET_STRING]; + char client_mon_endpoint[MAX_SOCKET_STRING]; + char server_mon_endpoint[MAX_SOCKET_STRING]; + + // Create a unique endpoint for each call so we don't have + // to wait for the sockets to unbind. + snprintf (client_mon_endpoint, MAX_SOCKET_STRING, "inproc://client%s%d", + expected_prefix_, type_); + snprintf (server_mon_endpoint, MAX_SOCKET_STRING, "inproc://server%s%d", + expected_prefix_, type_); // We'll monitor these two sockets void *client = test_context_socket (ZMQ_DEALER); @@ -150,9 +159,9 @@ void test_monitor_versioned_typed_basic (bind_function_t bind_function_, // Monitor all events on client and server sockets TEST_ASSERT_SUCCESS_ERRNO (zmq_socket_monitor_versioned_typed ( - client, "inproc://monitor-client", ZMQ_EVENT_ALL_V2, 2, type_)); + client, client_mon_endpoint, ZMQ_EVENT_ALL_V2, 2, type_)); TEST_ASSERT_SUCCESS_ERRNO (zmq_socket_monitor_versioned_typed ( - server, "inproc://monitor-server", ZMQ_EVENT_ALL_V2, 2, type_)); + server, server_mon_endpoint, ZMQ_EVENT_ALL_V2, 2, type_)); // Choose the appropriate consumer socket type. int mon_type = ZMQ_PAIR; @@ -181,10 +190,8 @@ void test_monitor_versioned_typed_basic (bind_function_t bind_function_, } // Connect these to the inproc endpoints so they'll get events - TEST_ASSERT_SUCCESS_ERRNO ( - zmq_connect (client_mon, "inproc://monitor-client")); - TEST_ASSERT_SUCCESS_ERRNO ( - zmq_connect (server_mon, "inproc://monitor-server")); + TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (client_mon, client_mon_endpoint)); + TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (server_mon, server_mon_endpoint)); // Now do a basic ping test bind_function_ (server, server_endpoint, sizeof server_endpoint); @@ -255,10 +262,6 @@ void test_monitor_versioned_typed_basic (bind_function_t bind_function_, // TODO why does this use zero_linger? test_context_socket_close_zero_linger (client_mon); test_context_socket_close_zero_linger (server_mon); - - // Wait for the monitor socket's endpoint to be available - // for reuse. - msleep (SETTLE_TIME); } void test_monitor_versioned_basic_tcp_ipv4 ()