summaryrefslogtreecommitdiffstats
path: root/sys/fs
diff options
context:
space:
mode:
authoralfred <alfred@FreeBSD.org>2002-04-18 14:47:34 +0000
committeralfred <alfred@FreeBSD.org>2002-04-18 14:47:34 +0000
commitd7f3109480a2d4dda0bd2bef498c4b784ab2c248 (patch)
tree07de1ff510021a0830867856333f727fb7164daa /sys/fs
parent8620a542520a67453e8e8f5d9a81c1bcc8544c32 (diff)
downloadFreeBSD-src-d7f3109480a2d4dda0bd2bef498c4b784ab2c248.zip
FreeBSD-src-d7f3109480a2d4dda0bd2bef498c4b784ab2c248.tar.gz
Cleanup of logic, flow and comments.
Submitted by: bde
Diffstat (limited to 'sys/fs')
-rw-r--r--sys/fs/fifofs/fifo_vnops.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/sys/fs/fifofs/fifo_vnops.c b/sys/fs/fifofs/fifo_vnops.c
index c47f822..6765d0c 100644
--- a/sys/fs/fifofs/fifo_vnops.c
+++ b/sys/fs/fifofs/fifo_vnops.c
@@ -340,27 +340,24 @@ fifo_ioctl(ap)
struct thread *a_td;
} */ *ap;
{
- struct file filetmp;
- int error = 0;
+ struct file filetmp; /* Local, so need not be locked. */
+ int error;
if (ap->a_command == FIONBIO)
return (0);
if (ap->a_fflag & FREAD) {
- /* filetmp is local, hence not need be locked. */
filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_readsock;
error = soo_ioctl(&filetmp, ap->a_command, ap->a_data, ap->a_td);
if (error)
- goto err;
+ return (error);
}
if (ap->a_fflag & FWRITE) {
- /* filetmp is local, hence not need be locked. */
filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_writesock;
error = soo_ioctl(&filetmp, ap->a_command, ap->a_data, ap->a_td);
if (error)
- goto err;
+ return (error);
}
-err:
- return (error);
+ return (0);
}
/* ARGSUSED */
@@ -463,27 +460,28 @@ fifo_poll(ap)
(POLLIN | POLLINIGNEOF | POLLPRI | POLLRDNORM | POLLRDBAND);
if (events) {
/*
- * Tell socket poll to ignore EOF so that we block if
- * there is no writer (and no data).
+ * If POLLIN or POLLRDNORM is requested and POLLINIGNEOF is
+ * not, then convert the first two to the last one. This
+ * tells the socket poll function to ignore EOF so that we
+ * block if there is no writer (and no data). Callers can
+ * set POLLINIGNEOF to get non-blocking behavior.
*/
- if (events & (POLLIN | POLLRDNORM)) {
+ if (events & (POLLIN | POLLRDNORM) &&
+ !(events & POLLINIGNEOF)) {
events &= ~(POLLIN | POLLRDNORM);
events |= POLLINIGNEOF;
}
+
filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_readsock;
if (filetmp.f_data)
revents |= soo_poll(&filetmp, events, ap->a_cred,
ap->a_td);
- /*
- * If POLLIN or POLLRDNORM was requested and POLLINIGNEOF was
- * not then convert POLLINIGNEOF back to POLLIN.
- */
- events = ap->a_events & (POLLIN | POLLRDNORM | POLLINIGNEOF);
- if ((events & (POLLIN | POLLRDNORM)) &&
- !(events & POLLINIGNEOF) &&
- (revents & POLLINIGNEOF)) {
+
+ /* Reverse the above conversion. */
+ if ((revents & POLLINIGNEOF) &&
+ !(ap->a_events & POLLINIGNEOF)) {
+ revents |= (ap->a_events & (POLLIN | POLLRDNORM));
revents &= ~POLLINIGNEOF;
- revents |= (events & (POLLIN | POLLRDNORM));
}
}
events = ap->a_events & (POLLOUT | POLLWRNORM | POLLWRBAND);
OpenPOWER on IntegriCloud