diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_descrip.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 1fbf3e9..65f7124 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -874,6 +874,17 @@ do_dup(struct thread *td, int flags, int old, int new, KASSERT(fp == fdp->fd_ofiles[old], ("old fd has been modified")); KASSERT(old != new, ("new fd is same as old")); + delfp = fdp->fd_ofiles[new]; + + /* + * Duplicate the source descriptor. + */ + fdp->fd_ofiles[new] = fp; + fdp->fd_ofileflags[new] = fdp->fd_ofileflags[old] &~ UF_EXCLOSE; + if (new > fdp->fd_lastfile) + fdp->fd_lastfile = new; + *retval = new; + /* * Save info on the descriptor being overwritten. We cannot close * it without introducing an ownership race for the slot, since we @@ -881,7 +892,6 @@ do_dup(struct thread *td, int flags, int old, int new, * * XXX this duplicates parts of close(). */ - delfp = fdp->fd_ofiles[new]; holdleaders = 0; if (delfp != NULL && td->td_proc->p_fdtol != NULL) { /* @@ -893,15 +903,6 @@ do_dup(struct thread *td, int flags, int old, int new, } /* - * Duplicate the source descriptor. - */ - fdp->fd_ofiles[new] = fp; - fdp->fd_ofileflags[new] = fdp->fd_ofileflags[old] &~ UF_EXCLOSE; - if (new > fdp->fd_lastfile) - fdp->fd_lastfile = new; - *retval = new; - - /* * If we dup'd over a valid file, we now own the reference to it * and must dispose of it using closef() semantics (as if a * close() were performed on it). |