From owner-p4-projects@FreeBSD.ORG Tue Sep 13 09:49:41 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0589616A421; Tue, 13 Sep 2005 09:49:41 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C512F16A41F for ; Tue, 13 Sep 2005 09:49:40 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 75D6F43D45 for ; Tue, 13 Sep 2005 09:49:40 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j8D9neQG037708 for ; Tue, 13 Sep 2005 09:49:40 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j8D9neZ5037705 for perforce@freebsd.org; Tue, 13 Sep 2005 09:49:40 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Tue, 13 Sep 2005 09:49:40 GMT Message-Id: <200509130949.j8D9neZ5037705@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Cc: Subject: PERFORCE change 83531 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Sep 2005 09:49:41 -0000 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); } }