Move the code around a bit to move two parts of code duplicated from
kern_close() close together. Discussed with: kib Tested by: pho MFC after: 1 month
This commit is contained in:
parent
8b40793150
commit
d327cee241
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=236911
@ -874,23 +874,7 @@ 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"));
|
||||
|
||||
/*
|
||||
* 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) {
|
||||
/*
|
||||
* Ask fdfree() to sleep to ensure that all relevant
|
||||
* process leaders can be traversed in closef().
|
||||
*/
|
||||
fdp->fd_holdleaderscount++;
|
||||
holdleaders = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Duplicate the source descriptor.
|
||||
@ -901,6 +885,23 @@ do_dup(struct thread *td, int flags, int old, int new,
|
||||
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().
|
||||
*/
|
||||
holdleaders = 0;
|
||||
if (delfp != NULL && td->td_proc->p_fdtol != NULL) {
|
||||
/*
|
||||
* Ask fdfree() to sleep to ensure that all relevant
|
||||
* process leaders can be traversed in closef().
|
||||
*/
|
||||
fdp->fd_holdleaderscount++;
|
||||
holdleaders = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
|
Loading…
Reference in New Issue
Block a user