Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 May 2017 00:25:08 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r318909 - stable/11/cddl/contrib/opensolaris/lib/libzpool/common
Message-ID:  <201705260025.v4Q0P8DU004702@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Fri May 26 00:25:08 2017
New Revision: 318909
URL: https://svnweb.freebsd.org/changeset/base/318909

Log:
  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.

Modified:
  stable/11/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c
==============================================================================
--- stable/11/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c	Fri May 26 00:19:50 2017	(r318908)
+++ stable/11/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c	Fri May 26 00:25:08 2017	(r318909)
@@ -363,7 +363,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);
@@ -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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705260025.v4Q0P8DU004702>