Index: kern_descrip.c =================================================================== --- kern_descrip.c (wersja 236851) +++ kern_descrip.c (kopia robocza) @@ -886,14 +886,23 @@ } 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 * need to drop the filedesc lock to call closef(). * * XXX this duplicates parts of close(). */ - delfp = fdp->fd_ofiles[new]; holdleaders = 0; if (delfp != NULL && td->td_proc->p_fdtol != NULL) { /* @@ -905,15 +914,6 @@ } /* - * 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).