have to protect acct_process from acctwatch closing the vnode
authorJan-Simon Pendry <pendry@ucbvax.Berkeley.EDU>
Sun, 11 Dec 1994 03:25:16 +0000 (19:25 -0800)
committerJan-Simon Pendry <pendry@ucbvax.Berkeley.EDU>
Sun, 11 Dec 1994 03:25:16 +0000 (19:25 -0800)
SCCS-vsn: sys/kern/kern_acct.c 8.6

usr/src/sys/kern/kern_acct.c

index 8b91181..235c2e0 100644 (file)
@@ -149,23 +149,25 @@ acct_process(p)
        register struct rusage *ru;
        struct vnode *vp;
        struct timeval t, ut, st;
        register struct rusage *ru;
        struct vnode *vp;
        struct timeval t, ut, st;
-       int i, s;
+       int error, i, s;
        struct acct acctbuf;
        register struct acct *ap = &acctbuf;
 
        struct acct acctbuf;
        register struct acct *ap = &acctbuf;
 
-       if ((vp = acctp) == NULL)
+       s = splclock();
+       if ((vp = acctp) == NULL) {
+               splx(s);
                return (0);
                return (0);
+       }
        if (vp->v_type == VBAD) {
                (void) vn_close(vp, FWRITE, NOCRED, NULL);
                acctp = NULL;
        if (vp->v_type == VBAD) {
                (void) vn_close(vp, FWRITE, NOCRED, NULL);
                acctp = NULL;
+               splx(s);
                return (0);
        }
        bcopy(p->p_comm, ap->ac_comm, sizeof(ap->ac_comm));
        ru = &p->p_stats->p_ru;
        calcru(p, &ut, &st, NULL);
                return (0);
        }
        bcopy(p->p_comm, ap->ac_comm, sizeof(ap->ac_comm));
        ru = &p->p_stats->p_ru;
        calcru(p, &ut, &st, NULL);
-       s = splclock();
        t = time;
        t = time;
-       splx(s);
        ap->ac_utime = compress(ut.tv_sec, ut.tv_usec);
        ap->ac_stime = compress(st.tv_sec, st.tv_usec);
        timevalsub(&t, &p->p_stats->p_start);
        ap->ac_utime = compress(ut.tv_sec, ut.tv_usec);
        ap->ac_stime = compress(st.tv_sec, st.tv_usec);
        timevalsub(&t, &p->p_stats->p_start);
@@ -186,9 +188,11 @@ acct_process(p)
                ap->ac_tty = NODEV;
        ap->ac_flag = p->p_acflag;
        VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
                ap->ac_tty = NODEV;
        ap->ac_flag = p->p_acflag;
        VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
-       return (vn_rdwr(UIO_WRITE, vp, (caddr_t)ap, sizeof (acctbuf), (off_t)0,
+       error = vn_rdwr(UIO_WRITE, vp, (caddr_t)ap, sizeof (acctbuf), (off_t)0,
                UIO_SYSSPACE, IO_UNIT|IO_APPEND, p->p_ucred, (int *)0,
                UIO_SYSSPACE, IO_UNIT|IO_APPEND, p->p_ucred, (int *)0,
-               (struct proc *)0));
+               (struct proc *)0);
+       splx(s);
+       return (error);
 }
 
 /*
 }
 
 /*