apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Pane <bri...@apache.org>
Subject Re: apr_pollset multithread semantics?
Date Mon, 18 Jul 2005 15:42:45 GMT
On Jul 18, 2005, at 5:41 AM, Joe Orton wrote:

> On Sun, Jul 17, 2005 at 07:20:10PM -0700, Brian Pane wrote:
>> For implementations of apr_pollset that support the
>> APR_POLLSET_THREADSAFE option to apr_pollset_create(), what's  
>> supposed
>> to happen if thread T1 adds a descriptor to a pollset while thread T2
>> is blocked in a call to apr_pollset_poll() for the same pollset?
> I had actually presumed it would be OK to leave the behaviour as not
> explicitly defined, but I can see it would certainly be useful to be
> able to rely on your (A) case below if that can actually be  
> guaranteed.

Yes indeed, (A) or even (B) can be very useful when designing, say,
httpd MPMs. :-)

>> Because the comments in apr_poll.h don't specify the semantics in  
>> this
>> scenario, an implementation could potentially work in any of the
>> following ways:
>>   A. The current apr_pollset_poll() call automatically includes the
>> newly added descriptor in the set of descriptors it's watching?
>>   B. The current apr_pollset_poll() call returns immediately with
>> something like EINTR.
>>   C. The current apr_pollset_poll() call ignores the newly added
>> descriptor.  Only on the next call to apr_pollset_poll() is the
>> descriptor actually included in the polling operation.
>> I just wrote a test program to determine that the kqueue-based
>> implementation of apr_pollset uses option A...at least on Darwin 8.x.
> epoll also appears to behave like (A).  (testing the FC3 2.6.11-based
> kernel)


>> If both the kqueue and epoll implementations match option A or B, I
>> propose making this a documented part of the semantics of
>> apr_pollset_*, at least for the thread-safe implementations.
> Sounds good, though the (B) behaviour would be a little surprising.

Yeah, the only thing I know of that definitely implements (B) is
java.nio.channels.Selector, which allows one thread to interrupt
another's blocking poll.  It's not as efficient as (A), but it yields  
same important result: file descriptors won't get "lost" if they're
added to a pollset that's currently being polled.


View raw message