Unverified Commit a6cfbca3 authored by Luca Boccassi's avatar Luca Boccassi Committed by GitHub

Merge pull request #3128 from sigiesec/fix-test-inproc-connect

Problem: test_context_socket is not thread-safe
parents 01395829 64f2b100
...@@ -43,7 +43,8 @@ void tearDown () ...@@ -43,7 +43,8 @@ void tearDown ()
static void pusher (void * /*unused*/) static void pusher (void * /*unused*/)
{ {
// Connect first // Connect first
void *connectSocket = test_context_socket (ZMQ_PAIR); // do not use test_context_socket here, as it is not thread-safe
void *connectSocket = zmq_socket (get_test_context (), ZMQ_PAIR);
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (connectSocket, "inproc://sink")); TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (connectSocket, "inproc://sink"));
...@@ -51,7 +52,7 @@ static void pusher (void * /*unused*/) ...@@ -51,7 +52,7 @@ static void pusher (void * /*unused*/)
send_string_expect_success (connectSocket, "foobar", 0); send_string_expect_success (connectSocket, "foobar", 0);
// Cleanup // Cleanup
test_context_socket_close (connectSocket); TEST_ASSERT_SUCCESS_ERRNO (zmq_close (connectSocket));
} }
static void simult_conn (void *endpt_) static void simult_conn (void *endpt_)
...@@ -60,11 +61,12 @@ static void simult_conn (void *endpt_) ...@@ -60,11 +61,12 @@ static void simult_conn (void *endpt_)
const char *endpt = static_cast<const char *> (endpt_); const char *endpt = static_cast<const char *> (endpt_);
// Connect // Connect
void *connectSocket = test_context_socket (ZMQ_SUB); // do not use test_context_socket here, as it is not thread-safe
void *connectSocket = zmq_socket (get_test_context (), ZMQ_SUB);
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (connectSocket, endpt)); TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (connectSocket, endpt));
// Cleanup // Cleanup
test_context_socket_close (connectSocket); TEST_ASSERT_SUCCESS_ERRNO (zmq_close (connectSocket));
} }
static void simult_bind (void *endpt_) static void simult_bind (void *endpt_)
...@@ -73,11 +75,12 @@ static void simult_bind (void *endpt_) ...@@ -73,11 +75,12 @@ static void simult_bind (void *endpt_)
const char *endpt = static_cast<const char *> (endpt_); const char *endpt = static_cast<const char *> (endpt_);
// Bind // Bind
void *bindSocket = test_context_socket (ZMQ_PUB); // do not use test_context_socket here, as it is not thread-safe
void *bindSocket = zmq_socket (get_test_context (), ZMQ_PUB);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (bindSocket, endpt)); TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (bindSocket, endpt));
// Cleanup // Cleanup
test_context_socket_close (bindSocket); TEST_ASSERT_SUCCESS_ERRNO (zmq_close (bindSocket));
} }
void test_bind_before_connect () void test_bind_before_connect ()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment