From 727637082f1427d239c389d8fcd330ef65fa8831 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Sun, 26 Apr 2020 14:53:22 +0100 Subject: [PATCH] Problem: test_shutdown_stress_tipc fails sometimes Solution: create socket in the same thread where it is used --- tests/test_shutdown_stress_tipc.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/test_shutdown_stress_tipc.cpp b/tests/test_shutdown_stress_tipc.cpp index abcd2b6c..9d91ff03 100644 --- a/tests/test_shutdown_stress_tipc.cpp +++ b/tests/test_shutdown_stress_tipc.cpp @@ -43,12 +43,13 @@ void tearDown () #define THREAD_COUNT 100 extern "C" { -static void *worker (void *s_) +static void *worker (void *ctx) { - TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (s_, "tipc://{5560,0}@0.0.0")); + void *s = zmq_socket (ctx, ZMQ_SUB); + TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (s, "tipc://{5560,0}@0.0.0")); // Start closing the socket while the connecting process is underway. - TEST_ASSERT_SUCCESS_ERRNO (zmq_close (s_)); + TEST_ASSERT_SUCCESS_ERRNO (zmq_close (s)); return NULL; } @@ -57,7 +58,6 @@ static void *worker (void *s_) void test_shutdown_stress_tipc () { void *s1; - void *s2; int i; int j; pthread_t threads[THREAD_COUNT]; @@ -72,9 +72,8 @@ void test_shutdown_stress_tipc () TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (s1, "tipc://{5560,0,0}")); for (i = 0; i != THREAD_COUNT; i++) { - s2 = zmq_socket (get_test_context (), ZMQ_SUB); TEST_ASSERT_SUCCESS_RAW_ERRNO ( - pthread_create (&threads[i], NULL, worker, s2)); + pthread_create (&threads[i], NULL, worker, get_test_context ())); } for (i = 0; i != THREAD_COUNT; i++) {