diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index d30fb651505..c2bfb93afaa 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1238,6 +1238,9 @@ fdalloc(struct thread *td, int minfd, int *result) FILEDESC_LOCK_ASSERT(fdp, MA_OWNED); + if (fdp->fd_freefile > minfd) + minfd = fdp->fd_freefile; + PROC_LOCK(p); maxfd = min((int)lim_cur(p, RLIMIT_NOFILE), maxfilesperproc); PROC_UNLOCK(p); @@ -1267,7 +1270,6 @@ fdalloc(struct thread *td, int minfd, int *result) ("free descriptor isn't")); fdp->fd_ofileflags[fd] = 0; /* XXX needed? */ fdused(fdp, fd); - fdp->fd_freefile = fd_first_free(fdp, fd, fdp->fd_nfiles); *result = fd; return (0); }