From owner-freebsd-bugs Mon May 14 4:10:11 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 91BAF37B423 for ; Mon, 14 May 2001 04:10:05 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id f4EBA5708618; Mon, 14 May 2001 04:10:05 -0700 (PDT) (envelope-from gnats) Date: Mon, 14 May 2001 04:10:05 -0700 (PDT) Message-Id: <200105141110.f4EBA5708618@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Bruce Evans Subject: Re: kern/27287: poll(2) returns 0 when POLLIN-ing ordinary files Reply-To: Bruce Evans Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR kern/27287; it has been noted by GNATS. From: Bruce Evans To: clemensF Cc: Jonathan Lemon , freebsd-gnats-submit@FreeBSD.ORG, Bruce Guenter Subject: Re: kern/27287: poll(2) returns 0 when POLLIN-ing ordinary files Date: Mon, 14 May 2001 21:08:01 +1000 (EST) On Mon, 14 May 2001, clemensF wrote: > > Jonathan Lemon: > > > > x.fd = open("trypoll.c",O_RDONLY); > > > if (x.fd == -1) _exit(111); > > > x.events = POLLIN; > > > if (poll(&x,1,10) == -1) _exit(1); > > > if (x.revents != POLLIN) _exit(1); > > > > > > If you change "POLLIN" to "POLLRDNORM", then this will work as > > you expect. Hoever, it's fairly pointless to poll() on a file, > > since it will always return true, no matter what, so the code > > above is fairly pointless. > > > > If you really want to poll a file for readability, use kqueue. > > the code snippet is part of "trypoll.c", which tests for a working poll(2) to > autoconfigure a software-package. and it doesn't seem that pointless, > because, as stated in the original PR, freebsd's poll(2) *does not* return > true on an existing (local) file; it returns zero both as it's return- value > and in x.revents, which is *wrong*. > > said package recognizes the deficiency, throws in it's workaround and > proceeds (cvm-0.6). note that i'm not the author, which is bruce guenter > , but he build the programs on a linux system. i was the one > who discovered the bug within freebsd 4. Untested fix for -current, including style fixes. Index: vfs_default.c =================================================================== RCS file: /home/ncvs/src/sys/kern/vfs_default.c,v retrieving revision 1.50 diff -c -2 -r1.50 vfs_default.c *** vfs_default.c 2001/05/06 17:40:22 1.50 --- vfs_default.c 2001/05/12 18:46:44 *************** *** 331,337 **** } */ *ap; { ! if ((ap->a_events & ~POLLSTANDARD) == 0) ! return (ap->a_events & (POLLRDNORM|POLLWRNORM)); ! return (vn_pollrecord(ap->a_vp, ap->a_p, ap->a_events)); } --- 331,339 ---- } */ *ap; { ! ! if (ap->a_events & ~POLLSTANDARD) ! return (vn_pollrecord(ap->a_vp, ap->a_p, ap->a_events)); ! /* PR27287: */ ! return (ap->a_events & (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)); } Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message