Join threads to prevent leaks
This commit is contained in:
parent
815780aa4a
commit
8d2d6d8721
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user