From owner-freebsd-current Sun Feb 9 9:41: 2 2003 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C232037B401; Sun, 9 Feb 2003 09:40:59 -0800 (PST) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id ECC1743F3F; Sun, 9 Feb 2003 09:40:57 -0800 (PST) (envelope-from bde@zeta.org.au) Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id EAA07114; Mon, 10 Feb 2003 04:40:31 +1100 Date: Mon, 10 Feb 2003 04:40:34 +1100 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Alexander Leidinger Cc: current@FreeBSD.ORG, Subject: Re: Do we still have a FIFO / named pipe problem? In-Reply-To: <20030209170616.2e4e3635.Alexander@Leidinger.net> Message-ID: <20030210033714.O1731-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, 9 Feb 2003, Alexander Leidinger wrote: > ports/mail/gensig has a problem. It is supposed to create a named pipe > (~/.signature) and wait for an application to read from the pipe. It > allows to have a random signature on every mail. On 4.x and on 5-current > from last year it works as expected. But since the end of the last year > or the begin of this year it doesn't anymore. gensig daemonizes itself > fills the named pipe and then terminates. The content of the named pipe > stays the same for every mail (no wonder, gensig is gone). Blocking opens of named pipes for writing were broken in: % RCS file: /home/ncvs/src/sys/fs/fifofs/fifo_vnops.c,v % Working file: fifo_vnops.c % head: 1.81 % ... % ---------------------------- % revision 1.79 % date: 2002/12/29 10:32:16; author: phk; state: Exp; lines: +6 -1 % There is some sort of race/deadlock which I have not identified % here. It manifests itself by sendmail hanging in "fifoow" during % boot on a diskless machine with sendmail disabled. % % Giving the sleep a 1sec timout breaks the deadlock, but does not solve % the underlying problem. % % XXX comment applied. % ---------------------------- This change makes such opens bogusly time out after 1 second (unless there is already a writer). There seems to be a race in fifo_open(): opens for read don't terminate the wait if the reader goes away before the opener looks. It is not clear if sendmail is affected by this race or one of its own. Untested fix for this and rev.1.79, and for a similar race in blocking opens of named pipes for reading: %%% Index: fifo_vnops.c =================================================================== RCS file: /home/ncvs/src/sys/fs/fifofs/fifo_vnops.c,v retrieving revision 1.81 diff -u -2 -r1.81 fifo_vnops.c --- fifo_vnops.c 13 Jan 2003 00:28:57 -0000 1.81 +++ fifo_vnops.c 9 Feb 2003 17:32:16 -0000 @@ -227,5 +227,5 @@ } if ((ap->a_mode & FREAD) && (ap->a_mode & O_NONBLOCK) == 0) { - while (fip->fi_writers == 0) { + if (fip->fi_writers == 0) { VOP_UNLOCK(vp, 0, td); error = tsleep((caddr_t)&fip->fi_readers, @@ -234,4 +234,9 @@ if (error) goto bad; + /* + * 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. + */ } } @@ -243,16 +248,16 @@ } } else { - while (fip->fi_readers == 0) { + if (fip->fi_readers == 0) { VOP_UNLOCK(vp, 0, td); - /* - * XXX: Some race I havn't located is solved - * by timing out after a sec. Race seen when - * sendmail hangs here during boot /phk - */ error = tsleep((caddr_t)&fip->fi_writers, - PCATCH | PSOCK, "fifoow", hz); + PCATCH | PSOCK, "fifoow", 0); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if (error) goto bad; + /* + * 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. + */ } } %%% Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message