From owner-svn-src-all@FreeBSD.ORG Mon Apr 13 11:54:23 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 411DF1065674; Mon, 13 Apr 2009 11:54:23 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0F4FB8FC12; Mon, 13 Apr 2009 11:54:23 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n3DBsMHG071074; Mon, 13 Apr 2009 11:54:22 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n3DBsMI2071073; Mon, 13 Apr 2009 11:54:22 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200904131154.n3DBsMI2071073@svn.freebsd.org> From: Robert Watson Date: Mon, 13 Apr 2009 11:54:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190997 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Apr 2009 11:54:24 -0000 Author: rwatson Date: Mon Apr 13 11:54:22 2009 New Revision: 190997 URL: http://svn.freebsd.org/changeset/base/190997 Log: Merge r190996 from head to stable/7: When writing out updated pollfd records when returning from poll(), only copy out the revents field, not the whole pollfd structure. Otherwise, if the events field is updated concurrently by another thread, that update may be lost. This issue apparently causes problems for the JDK on FreeBSD, which expects the Linux behavior of not updating all fields (somewhat oddly, Solaris does not implement the required behavior, but presumably our adaptation of the JDK is based on the Linux port?). MFC after: 2 weeks PR: kern/130924 Submitted by: Kurt Miller Discussed with: kib Approved by: re (kib) Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/sys_generic.c Modified: stable/7/sys/kern/sys_generic.c ============================================================================== --- stable/7/sys/kern/sys_generic.c Mon Apr 13 10:41:41 2009 (r190996) +++ stable/7/sys/kern/sys_generic.c Mon Apr 13 11:54:22 2009 (r190997) @@ -73,6 +73,7 @@ static MALLOC_DEFINE(M_IOCTLOPS, "ioctlo static MALLOC_DEFINE(M_SELECT, "select", "select() buffer"); MALLOC_DEFINE(M_IOV, "iov", "large iov's"); +static int pollout(struct pollfd *, struct pollfd *, u_int); static int pollscan(struct thread *, struct pollfd *, u_int); static int selscan(struct thread *, fd_mask **, fd_mask **, int); static int dofileread(struct thread *, int, struct file *, struct uio *, @@ -992,7 +993,7 @@ done_nosellock: if (error == EWOULDBLOCK) error = 0; if (error == 0) { - error = copyout(bits, uap->fds, ni); + error = pollout(bits, uap->fds, nfds); if (error) goto out; } @@ -1004,6 +1005,26 @@ done2: } static int +pollout(fds, ufds, nfd) + struct pollfd *fds; + struct pollfd *ufds; + u_int nfd; +{ + int error = 0; + u_int i = 0; + + for (i = 0; i < nfd; i++) { + error = copyout(&fds->revents, &ufds->revents, + sizeof(ufds->revents)); + if (error) + return (error); + fds++; + ufds++; + } + return (0); +} + +static int pollscan(td, fds, nfd) struct thread *td; struct pollfd *fds;