From owner-svn-src-head@FreeBSD.ORG Sun Feb 19 10:52:24 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 00373106566C; Sun, 19 Feb 2012 10:52:23 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail07.syd.optusnet.com.au (mail07.syd.optusnet.com.au [211.29.132.188]) by mx1.freebsd.org (Postfix) with ESMTP id 4CB668FC15; Sun, 19 Feb 2012 10:52:22 +0000 (UTC) Received: from c211-30-171-136.carlnfd1.nsw.optusnet.com.au (c211-30-171-136.carlnfd1.nsw.optusnet.com.au [211.30.171.136]) by mail07.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q1JAqJQl024658 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 19 Feb 2012 21:52:20 +1100 Date: Sun, 19 Feb 2012 21:52:19 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: David Xu In-Reply-To: <201202190817.q1J8HEm1071390@svn.freebsd.org> Message-ID: <20120219214118.G1461@besplex.bde.org> References: <201202190817.q1J8HEm1071390@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r231906 - head/lib/libthr/thread X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Feb 2012 10:52:24 -0000 On Sun, 19 Feb 2012, David Xu wrote: > Log: > Check both seconds and nanoseconds are zero, only checking nanoseconds > is zero may trigger timeout too early. It seems a copy&paste bug. > > Modified: > head/lib/libthr/thread/thr_umtx.c > > Modified: head/lib/libthr/thread/thr_umtx.c > ============================================================================== > --- head/lib/libthr/thread/thr_umtx.c Sun Feb 19 07:44:38 2012 (r231905) > +++ head/lib/libthr/thread/thr_umtx.c Sun Feb 19 08:17:14 2012 (r231906) > @@ -205,7 +205,7 @@ _thr_umtx_timedwait_uint(volatile u_int > if (abstime != NULL) { > clock_gettime(clockid, &ts); > TIMESPEC_SUB(&ts2, abstime, &ts); > - if (ts2.tv_sec < 0 || ts2.tv_nsec <= 0) > + if (ts2.tv_sec < 0 || (ts2.tv_sec == 0 && ts2.tv_nsec <= 0)) > return (ETIMEDOUT); > tsp = &ts2; > } else { > Use timespeccmp()? It is even likely to be faster, since it can do the comparison in parallel, while the above has to wait for TIMESPEC_SUB() before doing the comparison, unless the compiler is very smart. However, I seem to have done too good a job of keeping kernel time* APIs out of userland, so timespeccmp() is only available in the kernel, and there are uglier but more correct unsafe macros like TIMESPEC_SUB() macros in userland, and various kernel APIs escaped anyway, starting with the NetBSD timeval ones, which escaped 10-15 years after timevals should have gone away because they were superseded by timespecs. Bruce