Since fdshare() and fdinit() only operate on filedescs, make them
take pointers to filedesc structures instead of threads. This makes it more clear that they do not do any voodoo with the thread/proc or anything other than the filedesc passed in or returned. Remove some XXX KSE's as this resolves the issue.
This commit is contained in:
parent
59c97598d3
commit
c7f1c11b20
@ -1202,14 +1202,14 @@ ffree(fp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Build a new filedesc structure.
|
* Build a new filedesc structure from another.
|
||||||
|
* Copy the current, root, and jail root vnode references.
|
||||||
*/
|
*/
|
||||||
struct filedesc *
|
struct filedesc *
|
||||||
fdinit(td)
|
fdinit(fdp)
|
||||||
struct thread *td;
|
struct filedesc *fdp;
|
||||||
{
|
{
|
||||||
register struct filedesc0 *newfdp;
|
register struct filedesc0 *newfdp;
|
||||||
register struct filedesc *fdp = td->td_proc->p_fd;
|
|
||||||
|
|
||||||
MALLOC(newfdp, struct filedesc0 *, sizeof(struct filedesc0),
|
MALLOC(newfdp, struct filedesc0 *, sizeof(struct filedesc0),
|
||||||
M_FILEDESC, M_WAITOK | M_ZERO);
|
M_FILEDESC, M_WAITOK | M_ZERO);
|
||||||
@ -1238,13 +1238,13 @@ fdinit(td)
|
|||||||
* Share a filedesc structure.
|
* Share a filedesc structure.
|
||||||
*/
|
*/
|
||||||
struct filedesc *
|
struct filedesc *
|
||||||
fdshare(p)
|
fdshare(fdp)
|
||||||
struct proc *p;
|
struct filedesc *fdp;
|
||||||
{
|
{
|
||||||
FILEDESC_LOCK(p->p_fd);
|
FILEDESC_LOCK(fdp);
|
||||||
p->p_fd->fd_refcnt++;
|
fdp->fd_refcnt++;
|
||||||
FILEDESC_UNLOCK(p->p_fd);
|
FILEDESC_UNLOCK(fdp);
|
||||||
return (p->p_fd);
|
return (fdp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -258,8 +258,8 @@ fork1(td, flags, pages, procp)
|
|||||||
*/
|
*/
|
||||||
if (flags & RFCFDG) {
|
if (flags & RFCFDG) {
|
||||||
struct filedesc *fdtmp;
|
struct filedesc *fdtmp;
|
||||||
fdtmp = fdinit(td); /* XXXKSE */
|
fdtmp = fdinit(td->td_proc->p_fd);
|
||||||
fdfree(td); /* XXXKSE */
|
fdfree(td);
|
||||||
p1->p_fd = fdtmp;
|
p1->p_fd = fdtmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,13 +445,13 @@ again:
|
|||||||
* arguments or something.
|
* arguments or something.
|
||||||
*/
|
*/
|
||||||
if (flags & RFCFDG)
|
if (flags & RFCFDG)
|
||||||
fd = fdinit(td);
|
fd = fdinit(td->td_proc->p_fd);
|
||||||
else if (flags & RFFDG) {
|
else if (flags & RFFDG) {
|
||||||
FILEDESC_LOCK(p1->p_fd);
|
FILEDESC_LOCK(p1->p_fd);
|
||||||
fd = fdcopy(td);
|
fd = fdcopy(td);
|
||||||
FILEDESC_UNLOCK(p1->p_fd);
|
FILEDESC_UNLOCK(p1->p_fd);
|
||||||
} else
|
} else
|
||||||
fd = fdshare(p1);
|
fd = fdshare(p1->p_fd);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make a proc table entry for the new process.
|
* Make a proc table entry for the new process.
|
||||||
|
@ -150,8 +150,8 @@ void fdcloseexec(struct thread *td);
|
|||||||
int fdcheckstd(struct thread *td);
|
int fdcheckstd(struct thread *td);
|
||||||
struct filedesc *fdcopy(struct thread *td);
|
struct filedesc *fdcopy(struct thread *td);
|
||||||
void fdfree(struct thread *td);
|
void fdfree(struct thread *td);
|
||||||
struct filedesc *fdinit(struct thread *td);
|
struct filedesc *fdinit(struct filedesc *fdp);
|
||||||
struct filedesc *fdshare(struct proc *p);
|
struct filedesc *fdshare(struct filedesc *fdp);
|
||||||
void ffree(struct file *fp);
|
void ffree(struct file *fp);
|
||||||
static __inline struct file * fget_locked(struct filedesc *fdp, int fd);
|
static __inline struct file * fget_locked(struct filedesc *fdp, int fd);
|
||||||
pid_t fgetown(struct sigio **sigiop);
|
pid_t fgetown(struct sigio **sigiop);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user