svn commit: r318516 - head/cddl/contrib/opensolaris/lib/libzpool/common
Alexander Motin
mav at FreeBSD.org
Fri May 19 05:12:59 UTC 2017
Author: mav
Date: Fri May 19 05:12:58 2017
New Revision: 318516
URL: https://svnweb.freebsd.org/changeset/base/318516
Log:
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.
MFC after: 1 week
Modified:
head/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c
Modified: head/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c
==============================================================================
--- head/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c Fri May 19 04:59:12 2017 (r318515)
+++ head/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c Fri May 19 05:12:58 2017 (r318516)
@@ -368,7 +368,7 @@ cv_timedwait_hires(kcondvar_t *cv, kmute
int flag)
{
int error;
- timestruc_t ts;
+ timespec_t ts;
hrtime_t delta;
ASSERT(flag == 0 || flag == CALLOUT_FLAG_ABSOLUTE);
@@ -381,8 +381,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;
More information about the svn-src-head
mailing list