Date: 19 Feb 2000 03:49:55 -0000 From: kenji.rikitake@acm.org To: FreeBSD-gnats-submit@freebsd.org Subject: kern/16816: vop_stdpoll() in /sys/kern/vfs_default.c does not handle POLLIN/POLLOUT flags Message-ID: <20000219034955.75315.qmail@k2r.org>
next in thread | raw e-mail | index | archive | help
>Number: 16816
>Category: kern
>Synopsis: vop_stdpoll() in /sys/kern/vfs_default.c does not handle POLLIN/POLLOUT
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Fri Feb 18 19:50:01 PST 2000
>Closed-Date:
>Last-Modified:
>Originator: Kenji Rikitake
>Release: FreeBSD 3.4-RELEASE i386
>Organization:
K2 Research
>Environment:
FreeBSD 3.4-RELEASE
>Description:
When monitoring stdin using poll() with event POLLIN,
it works when stdin is redirected to a pipe,
but it does not when stdin is redirected to a local system file (vfs).
I think this behavior is weird because POLLIN seems to work for
all the other devices/socket/pipe/file-systems buf vfs.
>How-To-Repeat:
cc -o poll-sample poll-sample.c
echo "127.0.0.1" > foo
cat ./foo | ./poll-sample
retval = 1, revents=17
./poll-sample < ~/.foo
retval = 0, revents=0 (after waiting 10 seconds)
when using POLLRDNORM for the value of x[0].events, the file redirection
works as:
retval = 1, revents=64
/* poll-sample.c */
#include <stdio.h>
#include <poll.h>
#include <sys/types.h>
main()
{
struct pollfd x[1];
int i;
x[0].fd = 0;
x[0].events = POLLIN;
i = poll(x, 1, 10000);
printf("retval = %d, revents=%d\n", i, x[0].revents);
}
/* end of poll-sample.c */
>Fix:
This hasn't been tested yet, but I think changing the implementation
of vop_stdpoll() in /sys/kern/vfs_default.c will solve this
inconsistent behavior, by applying the following patch.
--- /sys/kern/vfs_default.c Wed Jan 20 23:48:49 1999
+++ vfs_default.c Sat Feb 19 12:44:43 2000
@@ -285,7 +285,8 @@
} */ *ap;
{
if ((ap->a_events & ~POLLSTANDARD) == 0)
- return (ap->a_events & (POLLRDNORM|POLLWRNORM));
+ return (ap->a_events &
+ (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM));
return (vn_pollrecord(ap->a_vp, ap->a_p, ap->a_events));
}
I would also like FreeBSD Development Team to clarify the difference
of semantics between POLLIN and POLLRDNORM, or POLLOUT and POLLWRNORM,
and put the definition clearly on poll(2).
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000219034955.75315.qmail>
