X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=t%2Fread-to-pipe-async.c;h=586e3c95bfd339c276974bc3e641e19837f486d7;hb=84106576cefbbd9f5dfa5ee33b245f77938d0269;hp=bc7986f7f6604e0cb0c7836f3e0e2cff96bf659c;hpb=a06aec04b3422d8ec63250e3ac56bbf526bc41b0;p=fio.git diff --git a/t/read-to-pipe-async.c b/t/read-to-pipe-async.c index bc7986f7..586e3c95 100644 --- a/t/read-to-pipe-async.c +++ b/t/read-to-pipe-async.c @@ -392,10 +392,13 @@ static void queue_work(struct reader_thread *rt, struct work_item *work) pthread_cond_signal(&rt->thread.cond); } else { int ret = pthread_create(&work->thread, NULL, reader_one_off, work); - if (ret) + if (ret) { fprintf(stderr, "pthread_create=%d\n", ret); - else - pthread_detach(work->thread); + } else { + ret = pthread_detach(work->thread); + if (ret) + fprintf(stderr, "pthread_detach=%d\n", ret); + } } } @@ -581,6 +584,7 @@ int main(int argc, char *argv[]) struct reader_thread *rt; struct writer_thread *wt; unsigned long rate; + uint64_t elapsed; struct stat sb; size_t bytes; off_t off; @@ -684,9 +688,11 @@ int main(int argc, char *argv[]) show_latencies(&wt->s, "WRITERS"); bytes /= 1024; - rate = (bytes * 1000UL * 1000UL) / utime_since(&s, &re); + elapsed = utime_since(&s, &re); + rate = elapsed ? (bytes * 1000UL * 1000UL) / elapsed : 0; fprintf(stderr, "Read rate (KiB/sec) : %lu\n", rate); - rate = (bytes * 1000UL * 1000UL) / utime_since(&s, &we); + elapsed = utime_since(&s, &we); + rate = elapsed ? (bytes * 1000UL * 1000UL) / elapsed : 0; fprintf(stderr, "Write rate (KiB/sec): %lu\n", rate); close(fd);