Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
kqueue + poll/select
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

kqueue + poll/select

I'm running the latest release of Panther. 10.3.3.

; uname -a
Darwin Scout.local 7.3.0 Darwin Kernel Version 7.3.0: Fri Mar 5 14:22:55 PST 2004; root:xnu/xnu-517.3.15.obj~4/RELEASE_PPC Power Macintosh powerpc

I have a program that makes use of kqueue for socket readiness notifications at its core. It has worked well for a long time on both 10.3 and FreeBSD 4/5. The system is modular and allows users to write plugins. One such plugin takes a file description and uses poll() to check to see if the FD is readable. It works like a champ on FreeBSD.

Under Darwin however, the following transpires:
kqueue created.
socket registered with kqueue for writability and exceptions
some logic happens and a decision is made in user code to _not_ write to the socket.
socket is disabled in kqueue()
socket is poll()ed with 0 timeout for readability -- using the builtin select()-based poll emulation
poll() times out.
socket is enabled again in kqueue for writability and excpetions
socket is written to
socket is read from (-1, EAGAIN)
socket is changed in kqueue it trigger on readability and exceptions
socket has data waiting.... kqueue never triggers.

It appears that the _use_ of a socket in select() under Darwin somehow breaks the monitoring under kqueue(). This behaviour is unexpected and undocumented. Anyone have any idea what is going on?

// Theo Schlossnagle
// Principal Engineer --
// Ecelerity: fastest MTA on Earth
darwin-development mailing list | email@hidden
Do not post admin requests to the list. They will be ignored.

Visit the Apple Store online or at retail locations.

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.