X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=t%2Fread-to-pipe-async.c;h=e8bdc85756daac7b7b3f1d4a2b9fec3358d03967;hb=922a5be82ca50f7c89a1f9c4b84757ba8636e2d1;hp=b56a990ca15a4542fcd953d6e730beb40ede4b03;hpb=28cacec42ffebeec281caae90065ee1af319dfa4;p=fio.git diff --git a/t/read-to-pipe-async.c b/t/read-to-pipe-async.c index b56a990c..e8bdc857 100644 --- a/t/read-to-pipe-async.c +++ b/t/read-to-pipe-async.c @@ -32,7 +32,6 @@ #include #include #include -#include #include "../flist.h" @@ -480,13 +479,14 @@ static void exit_thread(struct thread_data *thread, pthread_mutex_lock(&thread->done_lock); if (fn) { - struct timespec t; + struct timeval tv; + struct timespec ts; - clock_gettime(CLOCK_REALTIME, &t); - t.tv_sec++; + gettimeofday(&tv, NULL); + ts.tv_sec = tv.tv_sec + 1; + ts.tv_nsec = tv.tv_usec * 1000ULL; - - pthread_cond_timedwait(&thread->done_cond, &thread->done_lock, &t); + pthread_cond_timedwait(&thread->done_cond, &thread->done_lock, &ts); fn(wt); } else pthread_cond_wait(&thread->done_cond, &thread->done_lock); @@ -610,7 +610,8 @@ int main(int argc, char *argv[]) while (sb.st_size) { struct work_item *work; size_t this_len; - struct timespec t; + struct timespec ts; + struct timeval tv; prune_done_entries(wt); @@ -631,15 +632,17 @@ int main(int argc, char *argv[]) queue_work(rt, work); - clock_gettime(CLOCK_REALTIME, &t); - t.tv_nsec += max_us * 1000ULL; - if (t.tv_nsec >= 1000000000ULL) { - t.tv_nsec -= 1000000000ULL; - t.tv_sec++; + gettimeofday(&tv, NULL); + ts.tv_sec = tv.tv_sec; + ts.tv_nsec = tv.tv_usec * 1000ULL; + ts.tv_nsec += max_us * 1000ULL; + if (ts.tv_nsec >= 1000000000ULL) { + ts.tv_nsec -= 1000000000ULL; + ts.tv_sec++; } pthread_mutex_lock(&work->lock); - pthread_cond_timedwait(&work->cond, &work->lock, &t); + pthread_cond_timedwait(&work->cond, &work->lock, &ts); pthread_mutex_unlock(&work->lock); off += this_len;