From: Julian Stecklina
Subject: kqueues in SBCL
Date: 
Message-ID: <86sm96xws1.fsf@goldenaxe.localnet>
Hello,

I have whipped up a small interface to FreeBSD's kernel queues (a
nice, fast and simple replacement for select). Works fine via
SBCL. But I have a design question:

The kqueue depends on events that get registered using kevent. To see
what happened with the file descriptors (or timers) you registered you
call kevent again and get a list of event structures back. In an ideal
world one would use the udata (user data) field of these structures to
store a callback function to be called. But for now I am stuck with
either using the ident field (the file descriptor) or the user data
initialised to some random non-repeating value to index a hash
table. The problem is that when a file descriptor gets closed, all
registered events are discarded by the kernel. So my hash table keeps
unused handlers around, unless I wrap everything that could close a
file-descriptor (I think socket-close should be enough?).

Is there any elegant way around this? Can I test whether a file
descriptor is open (has not been closed), so I may scan the hash table
now and then to remove any non-existent file descriptors?

Ideas welcome.

Regards,
-- 
                    ____________________________
 Julian Stecklina  /  _________________________/
  ________________/  /
  \_________________/  LISP - truly beautiful