httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@attglobal.net>
Subject Re: Spurious return from select()
Date Mon, 13 Aug 2001 18:56:15 GMT
Shail Bhatnagar <shbhatna@cisco.com> writes:

> Jeff, The recvfrom() does not take place until process_connection() hook
> is invoked. This is consistent with apache code, I think. So, one would
> think that vanilla httpd processes ( without my changes) encounter the
> same
> problem ?? After the mutex is turned off and before the read/recv is
> performed
> there is a window of opportunity when other process/processes will enter
> select()
> and it will immediately return a positive value, indicating the socket
> to be
> readable. One has to set the O_NDELAY flag in these descriptors to work
> around
> this problem. 
> 
> Comments ??

recvfrom() on your UDP socket is analogous to the accept() done on the
apache listening socket in a couple of respects, one of which is
locking requirements

you want to allow only one select() pop for a given datagram (the
mutex takes care of this) *AND* the thread for which select() popped
must call recvfrom() before releasing the mutex; otherwise, as soon as
you release the mutex select() can pop for another thread

you can teach the code to recover if a thread is awakened and doesn't
get a datagram, but performance will suffer due to extra dispatches

-- 
Jeff Trawick | trawick@attglobal.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...

Mime
View raw message