Re: kevent and wait time?
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com kqueue is not select/poll. davez On Apr 2, 2006, at 9:42 PM, jmzorko@mac.com wrote: Hello, all ... The relevant piece of code follows -- it's really short :-) int Test( int iLimit ) { int iReturn = 0; testModule.Process( kLEvent, iNev ); } testModule.ReportTestResults(); return iReturn; } Regards, John Falling You - exploring the beauty of voice and sound http://www.fallingyou.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/zarzycki%40apple.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... To better understand what I mean by that, consider calling kevent() once per FD you allocate and only use kevent() to add to the kqueue. Then, as a part of your event loop, only fetch one event with kevent() and process it. 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." // Test() tesks the kqueue by processing any notifications we get ... for ( int iIndex = 0; iIndex < iLimit; iIndex ++ ) { struct kevent kLEvent; struct timespec timeToWait = { 0 }; int iNev = kevent( iKQ, pkEvents, iNumberOfConnectionsCreated, &kLEvent, 1, NULL /*&timeToWait*/ ); 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? This email sent to zarzycki@apple.com This email sent to site_archiver@lists.apple.com
participants (1)
-
Dave Zarzycki