I seem to have found my problem with my kqueue / kevent code, but it
ends up perplexing me even more. The context is this: i'm seeing how
far kqueues can scale in comparison to select() regarding # of
active, simultaneous connections to a server -- C10K stuff,
basically. I've written some C++ code that tests the kqueue by
adding a specified number of descriptors to it, waiting for events
from those descriptors, and seeing how many events from how many
descriptors I can process in some configurable amount of time.
The thing is, my code only seems to work if I specify NULL for the
timeout to kevent() -- kevent() comes back when one of the
descriptors i've added to it indeed has something to tell me.
However, if I specify a timeout of 0 (as a timeval), then kevent()
comes back right away, telling me about some event on some descriptor
i've never heard of (and didn't add to the queue) -- the descriptor
is a really big number, which initially made me think "pointer bug",
but simply changing the timeout to NULL (indefinite), makes
everything work, which makes me thinkg "ok, so it's not a pointer bug."
The relevant piece of code follows -- it's really short :-)
// Test() tesks the kqueue by processing any notifications we get ...
I don't get it. The man page for kevent doesn't say anything about a
non-NULL timeout (well, it's 0, but it's not NULL) affecting how
kevent() works ... what am I doing wrong?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden