Managing userland data pointers in kqueue/kevent

Paul LeoNerd Evans leonerd at leonerd.org.uk
Wed May 15 12:30:09 UTC 2013


On Wed, 15 May 2013 02:14:55 -0400
Julian Elischer <julian at freebsd.org> wrote:

> I would suggest that one answer would be to create an extension to 
> register a
> kevent to catch these events..
> 
> (the knote_drop())
> 
> The returned event could have all the appropriate information for the
> event being dropped..

Is that not the exact thing I suggested?

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.

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.

It's really simple to use:

 When you register,

    ev->flags |= EV_DROPWATCH


 When you receive an event, process it in the normal way, then

    if(ev->flags & EV_DROPPED)
      free(ev->udata);

and that is all there is to it.

-- 
Paul "LeoNerd" Evans

leonerd at leonerd.org.uk
ICQ# 4135350       |  Registered Linux# 179460
http://www.leonerd.org.uk/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20130515/5630dacc/attachment.sig>


More information about the freebsd-hackers mailing list