Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 25 Oct 2015 18:48:09 +0000 (UTC)
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r289941 - head/sys/kern
Message-ID:  <201510251848.t9PIm9kg047669@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pjd
Date: Sun Oct 25 18:48:09 2015
New Revision: 289941
URL: https://svnweb.freebsd.org/changeset/base/289941

Log:
  The aio_waitcomplete(2) syscall should not sleep when the given timeout
  is 0. Without this change it was sleeping for one tick. Maybe not a big
  deal, but it makes share/dtrace/blocking script to report that.
  
  Reviewed by:	jhb
  Differential Revision:	https://reviews.freebsd.org/D3814
  Sponsored by:	Wheel Systems, http://wheelsystems.com

Modified:
  head/sys/kern/vfs_aio.c

Modified: head/sys/kern/vfs_aio.c
==============================================================================
--- head/sys/kern/vfs_aio.c	Sun Oct 25 18:09:03 2015	(r289940)
+++ head/sys/kern/vfs_aio.c	Sun Oct 25 18:48:09 2015	(r289941)
@@ -2494,8 +2494,11 @@ kern_aio_waitcomplete(struct thread *td,
 
 	ops->store_aiocb(aiocbp, NULL);
 
-	timo = 0;
-	if (ts) {
+	if (ts == NULL) {
+		timo = 0;
+	} else if (ts->tv_sec == 0 && ts->tv_nsec == 0) {
+		timo = -1;
+	} else {
 		if ((ts->tv_nsec < 0) || (ts->tv_nsec >= 1000000000))
 			return (EINVAL);
 
@@ -2513,6 +2516,10 @@ kern_aio_waitcomplete(struct thread *td,
 	cb = NULL;
 	AIO_LOCK(ki);
 	while ((cb = TAILQ_FIRST(&ki->kaio_done)) == NULL) {
+		if (timo == -1) {
+			error = EWOULDBLOCK;
+			break;
+		}
 		ki->kaio_flags |= KAIO_WAKEUP;
 		error = msleep(&p->p_aioinfo, AIO_MTX(ki), PRIBIO | PCATCH,
 		    "aiowc", timo);



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