Date: Mon, 10 Nov 2003 12:41:09 -0500 From: marius aamodt eriksen <marius@monkey.org> To: hackers@openbsd.org, tech-kern@netbsd.org, freebsd-hackers@freebsd.org Cc: Niels Provos <provos@monkey.org> Subject: kqueue, NOTE_EOF Message-ID: <20031110174109.GA13852@monkey.org>
next in thread | raw e-mail | index | archive | help
hi - in order to be able to preserve consistent semantics across poll, select, and kqueue (EVFILT_READ), i propose the following change: on EVFILT_READ, add an fflag NOTE_EOF which will return when the file pointer *is* at the end of the file (effectively always returning on EVFILT_READ, but setting the NOTE_EOF flag when it is at the end). specifically, this allows libevent[1] to behave consistently across underlying polling infrastructures (this has become a practical issue). in openbsd, this was a trivial change in filt_ufsread(): kn->kn_data = ip->i_ffs_size - kn->kn_fp->f_offset; +if (kn->kn_data == 0 && kn->kn_sfflags & NOTE_EOF) { + kn->kn_fflags |= NOTE_EOF; + return (1); +} + return (kn->kn_data != 0); (and adding NOTE_EOF to event.h, of course) what do you think about this? can it be integrated into netbsd and freebsd as well? i have discussed this with provos@, and we seem to agree this is a viable solution. thanks, marius. [1] http://monkey.org/~provos/libevent -- > marius@monkey.org > http://monkey.org/~marius
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031110174109.GA13852>