• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
kevent and wait time?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

kevent and wait time?


  • Subject: kevent and wait time?
  • From: email@hidden
  • Date: Sun, 2 Apr 2006 21:42:33 -0700


Hello, all ...

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 ...

        int Test( int iLimit )
        {
            int iReturn = 0;

for ( int iIndex = 0; iIndex < iLimit; iIndex ++ )
{
struct kevent kLEvent;
struct timespec timeToWait = { 0 };
int iNev = kevent( iKQ, pkEvents, iNumberOfConnectionsCreated, &kLEvent, 1, NULL /*&timeToWait*/ );


                testModule.Process( kLEvent, iNev );
            }

            testModule.ReportTestResults();
            return iReturn;
        }

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?

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      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: kevent and wait time?
      • From: Dave Zarzycki <email@hidden>
  • Prev by Date: ok, dumb question, but ...
  • Next by Date: Re: ok, dumb question, but ...
  • Previous by thread: Re: ok, dumb question, but ...
  • Next by thread: Re: kevent and wait time?
  • Index(es):
    • Date
    • Thread