From 4802048f85106d518e533967517edf642ec0cd70 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Thu, 24 May 2018 23:02:50 +0200 Subject: Fix some minor errors in the MT code. --- turbowc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/turbowc.c b/turbowc.c index 02bfe53..0756549 100644 --- a/turbowc.c +++ b/turbowc.c @@ -168,13 +168,15 @@ static int turbowc(const char *path, size_t num_threads) } } - for (i = 0; i < num_threads; i++) { + for (i = 0; i < num_threads - 1; i++) { int rv; rv = pthread_create(threads + i, NULL, thread_f, NULL); if (rv) { size_t j; + perror("pthread_create"); + for (j = 0; j < i; j++) pthread_cancel(threads[j]); @@ -184,7 +186,7 @@ static int turbowc(const char *path, size_t num_threads) thread_f(NULL); - for (i = 0; i < num_threads; i++) + for (i = 0; i < num_threads - 1; i++) pthread_join(threads[i], NULL); data_pool.total += count_newlines(data_pool.cursor, data_pool.left); -- cgit