filedesc: lock filedesc lock in fdcloseexec only when needed

This commit is contained in:
Mateusz Guzik 2014-11-02 01:13:11 +00:00
parent 7bd12696d7
commit d3f3e12a4f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=273956

View File

@ -2160,19 +2160,17 @@ fdcloseexec(struct thread *td)
fdp = td->td_proc->p_fd;
KASSERT(fdp->fd_refcnt == 1, ("the fdtable should not be shared"));
FILEDESC_XLOCK(fdp);
for (i = 0; i <= fdp->fd_lastfile; i++) {
fde = &fdp->fd_ofiles[i];
fp = fde->fde_file;
if (fp != NULL && (fp->f_type == DTYPE_MQUEUE ||
(fde->fde_flags & UF_EXCLOSE))) {
FILEDESC_XLOCK(fdp);
fdfree(fdp, i);
(void) closefp(fdp, i, fp, td, 0);
/* closefp() drops the FILEDESC lock. */
FILEDESC_XLOCK(fdp);
}
}
FILEDESC_XUNLOCK(fdp);
}
/*