summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2003-03-24 11:03:42 +0000
committerbde <bde@FreeBSD.org>2003-03-24 11:03:42 +0000
commit3933bc0c416eeead665414164f54c01877496cac (patch)
tree62a1cd322e22719ff67d9f1899986106cd212f87
parent0c9bec33f5fb0fde17a650d723cb46a21560e7e5 (diff)
downloadFreeBSD-src-3933bc0c416eeead665414164f54c01877496cac.zip
FreeBSD-src-3933bc0c416eeead665414164f54c01877496cac.tar.gz
Better fix for the problem addressed by rev.1.79: don't loop in
fifo_open() waiting for another reader or writer if one arrived and departed while we were waiting (or a little earlier). Rev.1.79 broke blocking opens of fifos by making them time out after 1 second. This was bad for at least apsfilter. Tested by: "Simon 'corecode' Schubert" <corecode@corecode.ath.cx>, Alexander Leidinger <Alexander@leidinger.net>, phk MFC after: 4 weeks
-rw-r--r--sys/fs/fifofs/fifo_vnops.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/sys/fs/fifofs/fifo_vnops.c b/sys/fs/fifofs/fifo_vnops.c
index 441e9fd..a8e9e20 100644
--- a/sys/fs/fifofs/fifo_vnops.c
+++ b/sys/fs/fifofs/fifo_vnops.c
@@ -226,13 +226,18 @@ fifo_open(ap)
}
}
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(&fip->fi_readers,
PCATCH | PSOCK, "fifoor", 0);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
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.
+ */
}
}
if (ap->a_mode & FWRITE) {
@@ -242,18 +247,18 @@ fifo_open(ap)
goto bad;
}
} 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(&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.
+ */
}
}
}
OpenPOWER on IntegriCloud