diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2018-05-08 09:03:59 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2018-05-08 09:03:59 +0000 |
commit | 6faf5e04ac771ee419ade4d3426a8fb812669559 (patch) | |
tree | b365a8fcfdacd5512f09a709b5c92b1a43916bea | |
parent | 7a3f425a437bf72f0ce1279c83be4acd0c57d50a (diff) |
Change fd_iterfile() to not return imature fps instead of skipping them
later.
ok bluhm@, visa@
-rw-r--r-- | sys/kern/kern_descrip.c | 4 | ||||
-rw-r--r-- | sys/kern/kern_sysctl.c | 6 |
2 files changed, 4 insertions, 6 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index fc971435284..1d0e4b73edf 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_descrip.c,v 1.157 2018/05/08 08:53:41 mpi Exp $ */ +/* $OpenBSD: kern_descrip.c,v 1.158 2018/05/08 09:03:58 mpi Exp $ */ /* $NetBSD: kern_descrip.c,v 1.42 1996/03/30 22:24:38 christos Exp $ */ /* @@ -190,7 +190,7 @@ fd_iterfile(struct file *fp, struct proc *p) nfp = LIST_NEXT(fp, f_list); /* don't FREF when f_count == 0 to avoid race in fdrop() */ - while (nfp != NULL && nfp->f_count == 0) + while (nfp != NULL && (nfp->f_count == 0 || !FILE_IS_USABLE(nfp))) nfp = LIST_NEXT(nfp, f_list); if (nfp != NULL) FREF(nfp); diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 3ac0efa3fdf..07d5e1f4c5e 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.334 2018/05/08 08:53:41 mpi Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.335 2018/05/08 09:03:58 mpi Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -1322,9 +1322,7 @@ sysctl_file(int *name, u_int namelen, char *where, size_t *sizep, } fp = NULL; while ((fp = fd_iterfile(fp, p)) != NULL) { - if (fp->f_count > 1 && /* 0, +1 for our FREF() */ - FILE_IS_USABLE(fp) && - (arg == 0 || fp->f_type == arg)) { + if ((arg == 0 || fp->f_type == arg)) { int af, skip = 0; if (arg == DTYPE_SOCKET && fp->f_type == arg) { af = ((struct socket *)fp->f_data)-> |