svn commit: r190997 - in stable/7/sys: . contrib/pf dev/ath/ath_hal
dev/cxgb kern
Robert Watson
rwatson at FreeBSD.org
Mon Apr 13 11:54:24 UTC 2009
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 <kurt @ intricatesoftware.com>
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;
More information about the svn-src-all
mailing list