Remove the leaderp variable and just access p_leader directly. The

p_leader field is not protected by the proc lock but is only set during
fork1() by the parent process and never changes.
This commit is contained in:
John Baldwin 2002-10-15 00:03:40 +00:00
parent 63e30378bc
commit 60a6965a88

View File

@ -258,7 +258,6 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
struct flock *flp; struct flock *flp;
int tmp, error = 0, flg = F_POSIX; int tmp, error = 0, flg = F_POSIX;
u_int newmin; u_int newmin;
struct proc *leaderp;
mtx_lock(&Giant); mtx_lock(&Giant);
@ -379,9 +378,8 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
} }
PROC_LOCK(p); PROC_LOCK(p);
p->p_flag |= P_ADVLOCK; p->p_flag |= P_ADVLOCK;
leaderp = p->p_leader;
PROC_UNLOCK(p); PROC_UNLOCK(p);
error = VOP_ADVLOCK(vp, (caddr_t)leaderp, F_SETLK, error = VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_SETLK,
flp, flg); flp, flg);
break; break;
case F_WRLCK: case F_WRLCK:
@ -389,18 +387,11 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
error = EBADF; error = EBADF;
break; break;
} }
PROC_LOCK(p); error = VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_SETLK, flp,
p->p_flag |= P_ADVLOCK;
leaderp = p->p_leader;
PROC_UNLOCK(p);
error = VOP_ADVLOCK(vp, (caddr_t)leaderp, F_SETLK, flp,
flg); flg);
break; break;
case F_UNLCK: case F_UNLCK:
PROC_LOCK(p); error = VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_UNLCK, flp,
leaderp = p->p_leader;
PROC_UNLOCK(p);
error = VOP_ADVLOCK(vp, (caddr_t)leaderp, F_UNLCK, flp,
F_POSIX); F_POSIX);
break; break;
default: default: