kqueue, NOTE_EOF

marius aamodt eriksen <[email protected]> Mon, 10 Nov 2003 17:02:29 -0500
Newsgroups gmane.os.bsd.api.general
Message-ID <[email protected]>
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?  i have discussed this with niels
provos, and we seem to agree this is a viable solution.

thanks,

marius.

[1] http://monkey.org/~provos/libevent

-- 
> [email protected] > http://monkey.org/~marius

---------------------------------------------------------------------
The BSD APIs Discussion Mailing List
To unsubscribe:
send "unsubscribe bsd-api-discuss" to majordomo-of7zbby7T3pWk0Htik3J/[email protected]