diff options
author | mav <mav@FreeBSD.org> | 2017-05-26 00:25:08 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2017-05-26 00:25:08 +0000 |
commit | 22b8a399d84c945d868df5c06a195bb1825388e0 (patch) | |
tree | eb1b48a243148d1d31f341a3d3560770e81ab356 /cddl/contrib | |
parent | 7a13da8481a35110d3d84b66b31cd02ed4d9908c (diff) | |
download | FreeBSD-src-22b8a399d84c945d868df5c06a195bb1825388e0.zip FreeBSD-src-22b8a399d84c945d868df5c06a195bb1825388e0.tar.gz |
MFC r318516: Fix time handling in cv_timedwait_hires().
pthread_cond_timedwait() receives absolute time, not relative. Passing
wrong time there caused two threads of zdb to spin in a tight loop.
Diffstat (limited to 'cddl/contrib')
-rw-r--r-- | cddl/contrib/opensolaris/lib/libzpool/common/kernel.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c b/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c index 56d7bf3..a7fc128 100644 --- a/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c +++ b/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c @@ -363,7 +363,7 @@ cv_timedwait_hires(kcondvar_t *cv, kmutex_t *mp, hrtime_t tim, hrtime_t res, int flag) { int error; - timestruc_t ts; + timespec_t ts; hrtime_t delta; ASSERT(flag == 0 || flag == CALLOUT_FLAG_ABSOLUTE); @@ -376,8 +376,13 @@ top: if (delta <= 0) return (-1); - ts.tv_sec = delta / NANOSEC; - ts.tv_nsec = delta % NANOSEC; + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += delta / NANOSEC; + ts.tv_nsec += delta % NANOSEC; + if (ts.tv_nsec >= NANOSEC) { + ts.tv_sec++; + ts.tv_nsec -= NANOSEC; + } ASSERT(mutex_owner(mp) == curthread); mp->m_owner = NULL; |