From owner-freebsd-hackers@FreeBSD.ORG Mon Nov 10 09:41:13 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2CF7316A4CE for ; Mon, 10 Nov 2003 09:41:13 -0800 (PST) Received: from naughty.monkey.org (naughty.monkey.org [66.93.9.164]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7E69643FA3 for ; Mon, 10 Nov 2003 09:41:12 -0800 (PST) (envelope-from marius@naughty.monkey.org) Received: by naughty.monkey.org (Postfix, from userid 6) id 7C4AC1BA93E; Mon, 10 Nov 2003 12:41:09 -0500 (EST) Date: Mon, 10 Nov 2003 12:41:09 -0500 From: marius aamodt eriksen To: hackers@openbsd.org, tech-kern@netbsd.org, freebsd-hackers@freebsd.org Message-ID: <20031110174109.GA13852@monkey.org> Mail-Followup-To: hackers@openbsd.org, tech-kern@netbsd.org, freebsd-hackers@freebsd.org, Niels Provos Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.99i cc: Niels Provos Subject: kqueue, NOTE_EOF X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: marius@monkey.org List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Nov 2003 17:41:13 -0000 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