From owner-svn-src-head@freebsd.org Thu Jul 14 23:28:54 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 571A2B993E2; Thu, 14 Jul 2016 23:28:54 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0F6641B5E; Thu, 14 Jul 2016 23:28:53 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6ENSrCK042876; Thu, 14 Jul 2016 23:28:53 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6ENSrTw042875; Thu, 14 Jul 2016 23:28:53 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201607142328.u6ENSrTw042875@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 14 Jul 2016 23:28:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302860 - head/lib/librt X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 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: Thu, 14 Jul 2016 23:28:54 -0000 Author: jhb Date: Thu Jul 14 23:28:53 2016 New Revision: 302860 URL: https://svnweb.freebsd.org/changeset/base/302860 Log: Fix aio system call wrappers in librt. - Update aio_return/waitcomplete wrappers for the ssize_t return type. - Fix the aio_return() wrapper to fail with EINVAL on a pending job. This matches the semantics of the in-kernel system call. Also, aio_return() returns errors via errno, not via the return value. Reviewed by: kib (earlier version) MFC after: 1 week Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D7120 Modified: head/lib/librt/aio.c Modified: head/lib/librt/aio.c ============================================================================== --- head/lib/librt/aio.c Thu Jul 14 23:20:05 2016 (r302859) +++ head/lib/librt/aio.c Thu Jul 14 23:28:53 2016 (r302860) @@ -54,8 +54,8 @@ typedef void (*aio_func)(union sigval va extern int __sys_aio_read(struct aiocb *iocb); extern int __sys_aio_write(struct aiocb *iocb); -extern int __sys_aio_waitcomplete(struct aiocb **iocbp, struct timespec *timeout); -extern int __sys_aio_return(struct aiocb *iocb); +extern ssize_t __sys_aio_waitcomplete(struct aiocb **iocbp, struct timespec *timeout); +extern ssize_t __sys_aio_return(struct aiocb *iocb); extern int __sys_aio_error(struct aiocb *iocb); extern int __sys_aio_fsync(int op, struct aiocb *iocb); @@ -136,12 +136,13 @@ __aio_write(struct aiocb *iocb) return aio_io(iocb, &__sys_aio_write); } -int +ssize_t __aio_waitcomplete(struct aiocb **iocbp, struct timespec *timeout) { + ssize_t ret; int err; - int ret = __sys_aio_waitcomplete(iocbp, timeout); + ret = __sys_aio_waitcomplete(iocbp, timeout); if (*iocbp) { if ((*iocbp)->aio_sigevent.sigev_notify == SIGEV_THREAD) { err = errno; @@ -155,13 +156,20 @@ __aio_waitcomplete(struct aiocb **iocbp, return (ret); } -int +ssize_t __aio_return(struct aiocb *iocb) { if (iocb->aio_sigevent.sigev_notify == SIGEV_THREAD) { - if (__sys_aio_error(iocb) == EINPROGRESS) - return (EINPROGRESS); + if (__sys_aio_error(iocb) == EINPROGRESS) { + /* + * Fail with EINVAL to match the semantics of + * __sys_aio_return() for an in-progress + * request. + */ + errno = EINVAL; + return (-1); + } __sigev_list_lock(); __sigev_delete(SI_ASYNCIO, (sigev_id_t)iocb); __sigev_list_unlock();