On Fri, May 6, 2011 at 4:28 AM, Eric van der Maarel <eric.vandermaa...@nedap.com> wrote: > On 05/05/2011 10:17 PM, Jeff Trawick wrote: >> >> On Thu, May 5, 2011 at 3:20 PM, Eric van der Maarel >> <eric.vandermaa...@nedap.com> wrote: >>> >>> Hi, >>> >>> Further investigation reveals a difference between running Tomcat on >>> Linux and Windows. From the Tomcat Poller thread the apr_pollset_poll() >>> is called. When a client in the pollset has disconnected, under Linux >>> this call returns (in the rtnevents member of the descriptors resultset) >>> 49 (=0x31, so that would be APR_POLLIN | APR_POLLERR | APR_POLLHUP), >>> while under Windows this always return >>> 1 (so APR_POLLIN) >>> >>> The poller in Tomcat reacts on the APR_POLLHUP result, so differently on >>> Windows than on Linux. I think the problem lies in the missing >>> APR_POLLHUP in the poll return result under Windows (from the >>> impl_pollset_poll implemented in select.c by the way). >>> >>> Anyone any idea why on Windows (select.c) the rtnevents does not have >>> the APR_POLLHUP flag up, while on Linux (no idea which poll provider >>> version is used ther :-) this flag is set when the client has >>> disconnected? >>> And how to fix? :-) >> >> select() has a simpler view of things; normally something needs to >> read from the readable socket, get connreset or equiv, and handle >> closed connection at that point >> >> select() on any platform can't set APR_POLLHUP as a return event >> >> maybe getsockopt(SOL_SOCKET/SO_ERROR) when socket is readable and >> APR_POLLHUP was requested would give the necessary info???? > > Change the apr client you mean to handle receiving APR_POLLIN, right? > > > > >> >> --/-- >> >> are you sure select() is being used? newer Windows should have >> WSApoll()????? > > Yes, select() is being used (added some logging to select.c that actually > shows up). We're running on Windows XP (SP3) which, as I understand it, > doesn't have WSAPoll(). > If XP does have WSAPoll(), how to enforce it? Is it determined buildtime or > runtime which poll/pollset provider is going to be used? > Can and should we use another provider than select on XP and how can that be > configured? Or, for this use case, shouldn't we use XP altogether and use > one of those server versions of Windows instead?
XP only has select() available. WSAPoll() is available with Vista/2008 Server and later. It should be used automatically by APR without rebuilding your code (via a run-time check for presence of the Windows API). As far as WSAPoll() and this issue... MS doc says "POLLHUP A stream-oriented connection was either disconnected or aborted." POLLHUP is mapped to APR_POLLHUP. (IOW, I didn't test but it looks promising.)