Use more intuitive pointer for fdinit() and fdcopy().
Change fdcopy() to take unlocked filedesc.
This commit is contained in:
parent
56dd3a6182
commit
598b7ec86b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=137384
@ -1494,8 +1494,6 @@ fdcopy(fdp)
|
||||
if (fdp == NULL)
|
||||
return (NULL);
|
||||
|
||||
FILEDESC_LOCK_ASSERT(fdp, MA_OWNED);
|
||||
FILEDESC_UNLOCK(fdp);
|
||||
newfdp = fdinit(fdp);
|
||||
FILEDESC_LOCK(fdp);
|
||||
while (fdp->fd_lastfile >= newfdp->fd_nfiles) {
|
||||
@ -1529,6 +1527,7 @@ fdcopy(fdp)
|
||||
if (newfdp->fd_freefile == -1)
|
||||
newfdp->fd_freefile = i;
|
||||
newfdp->fd_cmask = fdp->fd_cmask;
|
||||
FILEDESC_UNLOCK(fdp);
|
||||
return (newfdp);
|
||||
}
|
||||
|
||||
|
@ -469,8 +469,8 @@ do_execve(td, fname, argv, envv, mac_p)
|
||||
if (p->p_fd->fd_refcnt > 1) {
|
||||
struct filedesc *tmp;
|
||||
|
||||
tmp = fdcopy(td->td_proc->p_fd);
|
||||
FILEDESC_UNLOCK(p->p_fd);
|
||||
tmp = fdcopy(p->p_fd);
|
||||
fdfree(td);
|
||||
p->p_fd = tmp;
|
||||
} else
|
||||
|
@ -238,8 +238,8 @@ fork1(td, flags, pages, procp)
|
||||
if (p1->p_fd->fd_refcnt > 1) {
|
||||
struct filedesc *newfd;
|
||||
|
||||
newfd = fdcopy(td->td_proc->p_fd);
|
||||
FILEDESC_UNLOCK(p1->p_fd);
|
||||
newfd = fdcopy(p1->p_fd);
|
||||
fdfree(td);
|
||||
p1->p_fd = newfd;
|
||||
} else
|
||||
@ -421,12 +421,10 @@ fork1(td, flags, pages, procp)
|
||||
* Copy filedesc.
|
||||
*/
|
||||
if (flags & RFCFDG) {
|
||||
fd = fdinit(td->td_proc->p_fd);
|
||||
fd = fdinit(p1->p_fd);
|
||||
fdtol = NULL;
|
||||
} else if (flags & RFFDG) {
|
||||
FILEDESC_LOCK(p1->p_fd);
|
||||
fd = fdcopy(td->td_proc->p_fd);
|
||||
FILEDESC_UNLOCK(p1->p_fd);
|
||||
fd = fdcopy(p1->p_fd);
|
||||
fdtol = NULL;
|
||||
} else {
|
||||
fd = fdshare(p1->p_fd);
|
||||
|
Loading…
Reference in New Issue
Block a user