Date: Tue, 13 Sep 2005 09:49:40 GMT From: Robert Watson <rwatson@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 83531 for review Message-ID: <200509130949.j8D9neZ5037705@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=83531 Change 83531 by rwatson@rwatson_zoo on 2005/09/13 09:48:42 Revert if->while change, the comments were right: we don't want to guarantee the condition is the case, just that it has been the case. Affected files ... .. //depot/projects/netsmp/src/sys/fs/fifofs/fifo_vnops.c#10 edit Differences ... ==== //depot/projects/netsmp/src/sys/fs/fifofs/fifo_vnops.c#10 (text+ko) ==== @@ -176,12 +176,6 @@ struct file *fp; int error; - /* - * In theory, writes to vp->v_fifoinfo are serialized by the vnode - * lock, so there can't be a race between multiple simultaneous opens - * here. We assert there hasn't been at the end of the allocation, - * however, to be sure. - */ if ((fip = vp->v_fifoinfo) == NULL) { MALLOC(fip, struct fifoinfo *, sizeof(*fip), M_VNODE, M_WAITOK); error = socreate(AF_LOCAL, &rso, SOCK_STREAM, 0, cred, td); @@ -206,10 +200,6 @@ SOCKBUF_LOCK(&rso->so_rcv); rso->so_rcv.sb_state |= SBS_CANTRCVMORE; SOCKBUF_UNLOCK(&rso->so_rcv); - /* - * If the vnode lock is insufficiently serializing, we might - * have to detect a race here and recover. - */ KASSERT(vp->v_fifoinfo == NULL, ("fifo_open: v_fifoinfo race")); vp->v_fifoinfo = fip; @@ -255,7 +245,7 @@ } } if ((ap->a_mode & O_NONBLOCK) == 0) { - while ((ap->a_mode & FREAD) && fip->fi_writers == 0) { + if ((ap->a_mode & FREAD) && fip->fi_writers == 0) { VOP_UNLOCK(vp, 0, td); error = msleep(&fip->fi_readers, &fifo_mtx, PDROP | PCATCH | PSOCK, "fifoor", 0); @@ -269,8 +259,13 @@ return (error); } mtx_lock(&fifo_mtx); + /* + * We must have got woken up because we had a writer. + * That (and not still having one) is the condition + * that we must wait for. + */ } - while ((ap->a_mode & FWRITE) && fip->fi_readers == 0) { + if ((ap->a_mode & FWRITE) && fip->fi_readers == 0) { VOP_UNLOCK(vp, 0, td); error = msleep(&fip->fi_writers, &fifo_mtx, PDROP | PCATCH | PSOCK, "fifoow", 0); @@ -283,6 +278,11 @@ } return (error); } + /* + * We must have got woken up because we had + * a reader. That (and not still having one) + * is the condition that we must wait for. + */ mtx_lock(&fifo_mtx); } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200509130949.j8D9neZ5037705>