summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2018-05-24 23:02:50 +0200
committerPaweł Redman <pawel.redman@gmail.com>2018-05-24 23:02:50 +0200
commit4802048f85106d518e533967517edf642ec0cd70 (patch)
tree564ed051ac76423457ad99f394c5d002e89131e3
parent70e76da34037e3ba1d94104013ed2f04f1d8a9af (diff)
Fix some minor errors in the MT code.
-rw-r--r--turbowc.c6
1 files 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);