diff --git a/tests/test_monitor.cpp b/tests/test_monitor.cpp index 82433d7a..b9309e6d 100644 --- a/tests/test_monitor.cpp +++ b/tests/test_monitor.cpp @@ -116,6 +116,12 @@ void test_monitor_basic () if (event != ZMQ_EVENT_DISCONNECTED) { TEST_ASSERT_EQUAL_INT (ZMQ_EVENT_MONITOR_STOPPED, event); } + // TODO: When not waiting until the monitor stopped, the I/O thread runs + // into some deadlock. This must be fixed, but until it is fixed, we wait + // here in order to have more reliable test execution. + while (event != ZMQ_EVENT_MONITOR_STOPPED) { + event = get_monitor_event (server_mon, NULL, NULL); + } // Close down the sockets // TODO why does this use zero_linger? @@ -255,6 +261,12 @@ void test_monitor_versioned_basic (bind_function_t bind_function_, if (event != ZMQ_EVENT_DISCONNECTED) { TEST_ASSERT_EQUAL_INT (ZMQ_EVENT_MONITOR_STOPPED, event); } + // TODO: When not waiting until the monitor stopped, the I/O thread runs + // into some deadlock. This must be fixed, but until it is fixed, we wait + // here in order to have more reliable test execution. + while (event != ZMQ_EVENT_MONITOR_STOPPED) { + event = get_monitor_event_v2 (server_mon, NULL, NULL, NULL); + } free (client_local_address); free (client_remote_address); diff --git a/tests/testutil_security.cpp b/tests/testutil_security.cpp index ab70046b..95f0ea12 100644 --- a/tests/testutil_security.cpp +++ b/tests/testutil_security.cpp @@ -346,6 +346,7 @@ void shutdown_context_and_server_side (void *zap_thread_, zmq_unbind (zap_control_, "inproc://handler-control")); } test_context_socket_close (zap_control_); + zmq_socket_monitor (server_, NULL, 0); test_context_socket_close (server_mon_); test_context_socket_close (server_);