summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_descrip.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/kern_descrip.c')
-rw-r--r--sys/kern/kern_descrip.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 56ab05a..8482307 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -193,7 +193,7 @@ fd_last_used(struct filedesc *fdp, int low, int size)
for (minoff = NDSLOT(low); off >= minoff; --off)
if (map[off] != 0)
return (off * NDENTRIES + flsl(map[off]) - 1);
- return (size - 1);
+ return (low - 1);
}
static int
@@ -1257,6 +1257,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);
@@ -1286,7 +1289,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);
}
@@ -1420,6 +1422,7 @@ fdinit(struct filedesc *fdp)
newfdp->fd_fd.fd_ofileflags = newfdp->fd_dfileflags;
newfdp->fd_fd.fd_nfiles = NDFILE;
newfdp->fd_fd.fd_map = newfdp->fd_dmap;
+ newfdp->fd_fd.fd_lastfile = -1;
return (&newfdp->fd_fd);
}
OpenPOWER on IntegriCloud