diff options
| author | Mateusz Guzik <mjg@FreeBSD.org> | 2014-11-13 21:15:09 +0000 |
|---|---|---|
| committer | Mateusz Guzik <mjg@FreeBSD.org> | 2014-11-13 21:15:09 +0000 |
| commit | eb48fbd963c6e410ce54b03d94add98f4f5635fb (patch) | |
| tree | 82303ccef10d46e2dbf2dfc593bd24d90b929354 /sys | |
| parent | 14d4e1e25040f64d3f53f045f784ca952575dc1e (diff) | |
Notes
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/kern/init_main.c | 2 | ||||
| -rw-r--r-- | sys/kern/kern_descrip.c | 16 | ||||
| -rw-r--r-- | sys/kern/kern_fork.c | 4 |
3 files changed, 13 insertions, 9 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 9246904f1cf5..a065b75bfda0 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -527,7 +527,7 @@ proc0_init(void *dummy __unused) siginit(&proc0); /* Create the file descriptor table. */ - p->p_fd = fdinit(NULL); + p->p_fd = fdinit(NULL, false); p->p_fdtol = NULL; /* Create the limits structures. */ diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 36d03b5e0bea..227a531f34fd 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1797,7 +1797,7 @@ finstall(struct thread *td, struct file *fp, int *fd, int flags, * If fdp is not NULL, return with it shared locked. */ struct filedesc * -fdinit(struct filedesc *fdp) +fdinit(struct filedesc *fdp, bool prepfiles) { struct filedesc0 *newfdp0; struct filedesc *newfdp; @@ -1818,7 +1818,7 @@ fdinit(struct filedesc *fdp) if (fdp == NULL) return (newfdp); - if (fdp->fd_lastfile >= newfdp->fd_nfiles) + if (prepfiles && fdp->fd_lastfile >= newfdp->fd_nfiles) fdgrowtable(newfdp, fdp->fd_lastfile + 1); FILEDESC_SLOCK(fdp); @@ -1832,10 +1832,14 @@ fdinit(struct filedesc *fdp) if (newfdp->fd_jdir) VREF(newfdp->fd_jdir); - while (fdp->fd_lastfile >= newfdp->fd_nfiles) { + if (!prepfiles) { FILEDESC_SUNLOCK(fdp); - fdgrowtable(newfdp, fdp->fd_lastfile + 1); - FILEDESC_SLOCK(fdp); + } else { + while (fdp->fd_lastfile >= newfdp->fd_nfiles) { + FILEDESC_SUNLOCK(fdp); + fdgrowtable(newfdp, fdp->fd_lastfile + 1); + FILEDESC_SLOCK(fdp); + } } return (newfdp); @@ -1914,7 +1918,7 @@ fdcopy(struct filedesc *fdp) MPASS(fdp != NULL); - newfdp = fdinit(fdp); + newfdp = fdinit(fdp, true); /* copy all passable descriptors (i.e. not kqueue) */ newfdp->fd_freefile = -1; for (i = 0; i <= fdp->fd_lastfile; ++i) { diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 8135afba7e28..62f43ba743b2 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -333,7 +333,7 @@ fork_norfproc(struct thread *td, int flags) */ if (flags & RFCFDG) { struct filedesc *fdtmp; - fdtmp = fdinit(td->td_proc->p_fd); + fdtmp = fdinit(td->td_proc->p_fd, false); fdescfree(td); p1->p_fd = fdtmp; } @@ -418,7 +418,7 @@ do_fork(struct thread *td, int flags, struct proc *p2, struct thread *td2, * Copy filedesc. */ if (flags & RFCFDG) { - fd = fdinit(p1->p_fd); + fd = fdinit(p1->p_fd, false); fdtol = NULL; } else if (flags & RFFDG) { fd = fdcopy(p1->p_fd); |
