0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-26 23:01:04 +08:00

Problem: test_shutdown_stress_tipc fails sometimes

Solution: create socket in the same thread where it is used
This commit is contained in:
Luca Boccassi 2020-04-26 14:53:22 +01:00
parent b56195e995
commit 727637082f

View File

@ -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++) {