Date: Wed, 15 May 2013 13:34:58 +0100 From: Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> To: Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> Cc: freebsd-hackers@freebsd.org, Adrian Chadd <adrian@freebsd.org>, Eugen-Andrei Gavriloaie <shiretu@gmail.com> Subject: Re: Managing userland data pointers in kqueue/kevent Message-ID: <20130515133458.41f980e9@shy.leonerd.org.uk> In-Reply-To: <20130515132959.7f113255@shy.leonerd.org.uk> References: <CCE4FFC4-F846-4F81-85EE-776B753C63C6@gmail.com> <20130513185357.1c552be5@shy.leonerd.org.uk> <CAJ-VmomQmPjtUhUo2%2BK=0Ychw-=qgawrZt3hnYeCPNNhA9T50A@mail.gmail.com> <CAJ-VmonKC_7J=aNgRntub9DN%2BEfQxrhMjstXHSJ634%2BaFemcLg@mail.gmail.com> <20130513191513.786f4f02@shy.leonerd.org.uk> <8A02C28F-89CB-4AE3-A91A-89565F041FDE@gmail.com> <CAJ-VmonjOS7Axq18VxL6B53T4DVgAYdY3LaT8nd7afFj2dq3cA@mail.gmail.com> <20130513194411.5a2dfa2e@shy.leonerd.org.uk> <519327DF.6060002@freebsd.org> <20130515132959.7f113255@shy.leonerd.org.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
--Sig_/UsH7B7tp18EnNh7FXvjnxO9 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Wed, 15 May 2013 13:29:59 +0100 Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> wrote: > Is that not the exact thing I suggested? >=20 > The "extension to create register a kevent to catch these events" is > that you put the EV_DROPWATCH bit flag in the event at the time you > register it. >=20 > The "returned event [that] could have all the appropriate informaiton > for the event being dropped" is that you receive an event with > EV_DROPPED set on it. It being a real event includes of course the > udata pointer, so you can handle it. In fact, to requote the original PR I wrote[1] on the subject: --- I propose the addition of a new flag applicable to any kevent watch structure, documented thusly: The flags field can contain the following values: .. EV_DROPWATCH Requests that the kernel will send an EV_DROPPED event on this watch when it has finished watching it for any reason, including EV_DELETE, expiry because of EV_ONESHOT, or because the filehandle was closed by close(2). EV_DROPPED This flag is returned by the kernel if it is now about to drop the watch. After this flag has been received, no further events will occur on this watch. This flag then makes it trivial to build a generic wrapper for kqueue that can always manage its memory correctly. a) at EV_ADD time, simply set flags |=3D EV_DROPWATCH b) after an event has been processed that included the EV_DROPPED flag, free() the pointer given in the udata field. It is not required that these two flags have distinct values; since one is userland->kernel and the other kernel->userland, they could for neatness reuse the same bit field. --- [1]: http://www.freebsd.org/cgi/query-pr.cgi?pr=3D153254 --=20 Paul "LeoNerd" Evans leonerd@leonerd.org.uk ICQ# 4135350 | Registered Linux# 179460 http://www.leonerd.org.uk/ --Sig_/UsH7B7tp18EnNh7FXvjnxO9 Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlGTgPIACgkQvLS2TC8cBo0TCQCfc9fKd4ZmWUPbB47cuVU2ZTa7 kl0AniFkCNluZde1HWjJs+/DC+oouKX+ =YiE5 -----END PGP SIGNATURE----- --Sig_/UsH7B7tp18EnNh7FXvjnxO9--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130515133458.41f980e9>