On Nov 22, 2009, at 6:43 PM, Howard Chu wrote:
bduncan@apple.com wrote:
On Sep 22, 2009, at 1:02 PM, Quanah Gibson-Mount wrote: =20
--On Tuesday, September 22, 2009 7:23 PM +0000 bduncan@apple.com wrote: =20
Subject should have been: "PATCH - Added kqueue support to slapd" =
to
make clear this ITS tracks a patch that has been submitted.
=20 What OS(es) has this kqueue support been tested with? For example, the last time I looked at kqueue on OSX 10.5, it was very marginal, and missing most of the important pieces, which meant it wouldn't work for OpenLDAP or Postfix, etc.
=20 It was tested on OS X 10.6. Should work on all BSDs; nothing OSX- specific about the kqueue usage in the patch. As far as kqueue support in OS X 10.5, from what I see, most everything is there. Certainly all of the kqueue features in this patch are supported in =
OS
X 10.5.
=20 To expand on this: there are a lot of comments around the web that =
kqueue was fairly broken at least up to 10.5. E.g. this:
=20 http://lists.schmorp.de/pipermail/libev/2008q4/000523.html
Perhaps I missed something in that thread, but the only specific = complaint was regarding kqueue and stdin. And it's true that OS X's = kqueue didn't support EVFILT_{READ|WRITE} on *devices* (stdin, tty's, = /dev/* ) until 10.6. I don't believe OpenLDAP actually needs that = feature, though.
=20 Since we also use a pipe for the wake_sds[] in our event loop, if =
kqueue only supports sockets, then it cannot be used reliably in slapd.
The OS X kqueue has *always* supported EVFILT_{READ|WRITE} on sockets, = pipes, fifos, files. Same for kqueue in the BSDs. (FWIW, I believe the = BSDs have always supported devices in kqueue.)
I think everything OpenLDAP needs from kqueue has been, and is, = supported by OS X and the BSDs. If there is a specific kqueue filter or = fd type that OpenLDAP needs and isn't supported, please let me know.
Although I don't think it's necessary, you could add a test to the = configure script to ensure kqueue supports the types of fd's OpenLDAP = needs by doing something like this:
int fd; /* or int fds[2]; */ /* do something to create an fd here: open(2), pipe(2), socket(2), = etc. */ struct kevent ev; EV_SET(&ev, fd, EVFILT_READ, EV_ADD, 0, 0, 0); int kq =3D kqueue(); if (kq < 0) { ac_have_kqueue =3D false; } else { struct timespec to =3D {0,1}; /* anything so that kevent will = return */ int ret =3D kevent(kq, &ev, 1, &ev, 1, &to); close(kq); ac_have_kqueue =3D (ret >=3D 0); }
If the fd isn't supported 'ret' should be -1 and errno should be = ENOTSUP.
-- Bryan Duncan