diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2018-12-18 17:07:29 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2018-12-18 17:20:15 +0400 |
commit | b0fd06a6f27212cee770961171439a44626d8f14 (patch) | |
tree | ffd043e390f1e400f4d67ab52553a8a04e8805bc /unittest/mysys/thr_template.c | |
parent | 65525550ab8988a1a1a36d0403824ebaec160347 (diff) | |
download | mariadb-git-b0fd06a6f27212cee770961171439a44626d8f14.tar.gz |
MDEV-15670 - unit.my_atomic failed in buildbot with Signal 11 thrown
Workaround glibc bug: https://sourceware.org/bugzilla/show_bug.cgi?id=20116
by making unittest threads joinable. It makes code better anyway.
Diffstat (limited to 'unittest/mysys/thr_template.c')
-rw-r--r-- | unittest/mysys/thr_template.c | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/unittest/mysys/thr_template.c b/unittest/mysys/thr_template.c index 7304eb50955..d1bc0868ca0 100644 --- a/unittest/mysys/thr_template.c +++ b/unittest/mysys/thr_template.c @@ -20,35 +20,34 @@ #include <tap.h> volatile uint32 bad; -pthread_attr_t thr_attr; pthread_mutex_t mutex; -pthread_cond_t cond; -uint running_threads; void do_tests(); void test_concurrently(const char *test, pthread_handler handler, int n, int m) { - pthread_t t; + pthread_t *threads= malloc(n * sizeof(pthread_t)); + int i; ulonglong now= my_interval_timer(); + assert(threads); bad= 0; diag("Testing %s with %d threads, %d iterations... ", test, n, m); - for (running_threads= n ; n ; n--) + for (i= n; i; i--) { - if (pthread_create(&t, &thr_attr, handler, &m) != 0) + if (pthread_create(&threads[i], 0, handler, &m) != 0) { diag("Could not create thread"); abort(); } } - pthread_mutex_lock(&mutex); - while (running_threads) - pthread_cond_wait(&cond, &mutex); - pthread_mutex_unlock(&mutex); + + for (i= n; i; i--) + pthread_join(threads[i], 0); now= my_interval_timer() - now; + free(threads); ok(!bad, "tested %s in %g secs (%d)", test, ((double)now)/1e9, bad); } @@ -60,9 +59,6 @@ int main(int argc __attribute__((unused)), char **argv) DBUG_SET_INITIAL(argv[1]); pthread_mutex_init(&mutex, 0); - pthread_cond_init(&cond, 0); - pthread_attr_init(&thr_attr); - pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED); #ifdef MY_ATOMIC_MODE_RWLOCKS #if defined(HPUX11) || defined(__POWERPC__) /* showed to be very slow (scheduler-related) */ @@ -79,16 +75,7 @@ int main(int argc __attribute__((unused)), char **argv) do_tests(); - /* - workaround until we know why it crashes randomly on some machine - (BUG#22320). - */ -#ifdef NOT_USED - sleep(2); -#endif pthread_mutex_destroy(&mutex); - pthread_cond_destroy(&cond); - pthread_attr_destroy(&thr_attr); my_end(0); return exit_status(); } |