From 8d2d6d8721658ccd02b8afcd7785c32b865bdade Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Fri, 31 Mar 2017 17:31:14 +0300 Subject: [PATCH] Join threads to prevent leaks --- server/core/test/testlogthrottling.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server/core/test/testlogthrottling.cc b/server/core/test/testlogthrottling.cc index de78bdff7..685d8ea7b 100644 --- a/server/core/test/testlogthrottling.cc +++ b/server/core/test/testlogthrottling.cc @@ -113,6 +113,7 @@ bool run(const MXS_LOG_THROTTLING& throttling, int priority, size_t n_generate, in.seekg(0, ios_base::end); THREAD_ARG args[N_THREADS]; + pthread_t tids[N_THREADS]; // Create the threads. for (size_t i = 0; i < N_THREADS; ++i) @@ -122,8 +123,7 @@ bool run(const MXS_LOG_THROTTLING& throttling, int priority, size_t n_generate, parg->n_generate = n_generate; parg->priority = priority; - pthread_t tid; - int rc = pthread_create(&tid, 0, thread_main, parg); + int rc = pthread_create(&tids[i], 0, thread_main, parg); ensure(rc == 0); } @@ -145,6 +145,12 @@ bool run(const MXS_LOG_THROTTLING& throttling, int priority, size_t n_generate, mxs_log_flush_sync(); + for (size_t i = 0; i < N_THREADS; ++i) + { + void* rv; + pthread_join(tids[i], &rv); + } + return check_messages(in, n_expect); }