summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_descrip.c
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2012-06-12 10:25:11 +0000
committerpjd <pjd@FreeBSD.org>2012-06-12 10:25:11 +0000
commitbcf3f4263d67f83311b4d5db42c220f7fa151990 (patch)
tree141fa910ec0246100e6d8dac06d2d4a6819bb690 /sys/kern/kern_descrip.c
parent053897dbaf48d21fbe48ca84076487cbca1aee3b (diff)
downloadFreeBSD-src-bcf3f4263d67f83311b4d5db42c220f7fa151990.zip
FreeBSD-src-bcf3f4263d67f83311b4d5db42c220f7fa151990.tar.gz
Revert part of the r236935 for now, until I figure out why it doesn't
work properly. Reported by: davidxu
Diffstat (limited to 'sys/kern/kern_descrip.c')
-rw-r--r--sys/kern/kern_descrip.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 61e13c1..2648ba7 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -1480,10 +1480,12 @@ fdalloc(struct thread *td, int minfd, int *result)
* to grow the file table. Keep at it until we either get a file
* descriptor or run into process or system limits.
*/
- fd = fd_first_free(fdp, minfd, fdp->fd_nfiles);
- if (fd >= maxfd)
- return (EMFILE);
- if (fd >= fdp->fd_nfiles) {
+ for (;;) {
+ fd = fd_first_free(fdp, minfd, fdp->fd_nfiles);
+ if (fd >= maxfd)
+ return (EMFILE);
+ if (fd < fdp->fd_nfiles)
+ break;
#ifdef RACCT
PROC_LOCK(p);
error = racct_set(p, RACCT_NOFILE,
@@ -1493,10 +1495,6 @@ fdalloc(struct thread *td, int minfd, int *result)
return (EMFILE);
#endif
fdgrowtable(fdp, min(fdp->fd_nfiles * 2, maxfd));
- /* Retry... */
- fd = fd_first_free(fdp, minfd, fdp->fd_nfiles);
- if (fd >= maxfd)
- return (EMFILE);
}
/*
OpenPOWER on IntegriCloud