summaryrefslogtreecommitdiff
path: root/tests/shutdown_stress.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/shutdown_stress.cpp')
-rw-r--r--tests/shutdown_stress.cpp32
1 files changed, 8 insertions, 24 deletions
diff --git a/tests/shutdown_stress.cpp b/tests/shutdown_stress.cpp
index 2e6b4d5..976c658 100644
--- a/tests/shutdown_stress.cpp
+++ b/tests/shutdown_stress.cpp
@@ -21,32 +21,20 @@
#include "testutil.hpp"
-#if defined XS_HAVE_WINDOWS
-int XS_TEST_MAIN ()
-{
- return 0;
-}
-#else
-
-#include <pthread.h>
-#include <stddef.h>
-
#define THREAD_COUNT 100
extern "C"
{
- static void *worker (void *s)
+ static void shutdown_stress_worker (void *s_)
{
int rc;
- rc = xs_connect (s, "tcp://127.0.0.1:5560");
+ rc = xs_connect (s_, "tcp://127.0.0.1:5560");
assert (rc == 0);
// Start closing the socket while the connecting process is underway.
- rc = xs_close (s);
+ rc = xs_close (s_);
assert (rc == 0);
-
- return NULL;
}
}
@@ -58,7 +46,7 @@ int XS_TEST_MAIN ()
int i;
int j;
int rc;
- pthread_t threads [THREAD_COUNT];
+ void *threads [THREAD_COUNT];
fprintf (stderr, "shutdown_stress test running...\n");
@@ -77,14 +65,12 @@ int XS_TEST_MAIN ()
for (i = 0; i != THREAD_COUNT; i++) {
s2 = xs_socket (ctx, XS_SUB);
assert (s2);
- rc = pthread_create (&threads [i], NULL, worker, s2);
- assert (rc == 0);
+ threads [i] = xs_thread_create (shutdown_stress_worker, s2);
+ assert (threads [i]);
}
- for (i = 0; i != THREAD_COUNT; i++) {
- rc = pthread_join (threads [i], NULL);
- assert (rc == 0);
- }
+ for (i = 0; i != THREAD_COUNT; i++)
+ xs_thread_join (threads [i]);
rc = xs_close (s1);
assert (rc == 0);
@@ -95,5 +81,3 @@ int XS_TEST_MAIN ()
return 0;
}
-
-#endif \ No newline at end of file