From dev-return-21010-apmail-apr-dev-archive=apr.apache.org@apr.apache.org Wed Aug 27 05:19:12 2008 Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 35888 invoked from network); 27 Aug 2008 05:19:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Aug 2008 05:19:12 -0000 Received: (qmail 24072 invoked by uid 500); 27 Aug 2008 05:19:09 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 24023 invoked by uid 500); 27 Aug 2008 05:19:09 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 24011 invoked by uid 99); 27 Aug 2008 05:19:09 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Aug 2008 22:19:09 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of justin.erenkrantz@gmail.com designates 74.125.44.28 as permitted sender) Received: from [74.125.44.28] (HELO yx-out-2324.google.com) (74.125.44.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Aug 2008 05:18:12 +0000 Received: by yx-out-2324.google.com with SMTP id 8so1177197yxb.13 for ; Tue, 26 Aug 2008 22:18:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:mime-version:content-type:content-transfer-encoding :content-disposition:x-google-sender-auth; bh=iMsz+9OM1a/KkQq5XKW4iT9dHZ8kUM8+gJr2QEYlmXg=; b=vO3RVMTqY9z9RSXukkvOOGcaZBO+x5RhuYOb5jqkgo80E8OWW+YeX4I3q7TnEKomsY YdhJIqg5e+LnIINqE8Uk61xAD20S/2fu16E0l39JDun+UtWb0k206b0JcCiSNtla4mCA mKwD/qLFNeDWYaEgeXFlH3OhPWt8B63hp8fpQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition:x-google-sender-auth; b=xw2D12+FoT0RvspRzdCHp6+0XoFbaGDHKL5K9pPr1ujes8iUcXTwV4DN9G+PmxbdVo ZDfaEVrlO5vzp/MsrP4jwMNyVV5RwneE/G+i4CmTNtc+xrGfJNbbZ78eOise/CGDLDRo x4N5kZQ2wkLU6lN+dPcDA58blr5/mi3I/GTa0= Received: by 10.150.136.6 with SMTP id j6mr817046ybd.78.1219814312161; Tue, 26 Aug 2008 22:18:32 -0700 (PDT) Received: by 10.151.79.21 with HTTP; Tue, 26 Aug 2008 22:18:32 -0700 (PDT) Message-ID: <5c902b9e0808262218o3140e5cax1d543355d19819da@mail.gmail.com> Date: Tue, 26 Aug 2008 22:18:32 -0700 From: "Justin Erenkrantz" Sender: justin.erenkrantz@gmail.com To: "APR Developer List" Subject: [PATCH] apr_pollset_poll() returns WSAEINVAL if no sockets are in the pollset MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Google-Sender-Auth: c177a92c33210f06 X-Virus-Checked: Checked by ClamAV on apache.org The patch below fixes a cosmetic problem seen with serf on Win32 if apr_pollset_poll is called without any sockets already in the pollset. select on Win32 will immediately return WSAEINVAL (730022) in this case. The MSDN docs for select() - http://msdn.microsoft.com/en-us/library/ms740141.aspx - says: --- Any two of the parameters, readfds, writefds, or exceptfds, can be given as null. At least one must be non-null, and any non-null descriptor set must contain at least one handle to a socket. --- Earlier in the doc, it says that select() ignores the first parameter (nfds), so it looks like while other OSes may have a short-circuit success on the 0 nfds case, Win32 will just return WSAEINVAL in this case. Instead of returning an error, I believe the right thing is for APR to hide this and return success. So, any objections to committing the following? (If we're going to do 1.3.5, I'd like to see this backported too.) Thanks! -- justin Index: poll/unix/select.c =================================================================== --- poll/unix/select.c (revision 689358) +++ poll/unix/select.c (working copy) @@ -453,6 +453,17 @@ APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pol fd_set readset, writeset, exceptset; apr_status_t rv = APR_SUCCESS; +#ifdef WIN32 + /* On Win32, select() must be presented with at least one socket to + * poll on, or select() will return WSAEINVAL. So, we'll just + * short-circuit and bail now. + */ + if (pollset->nelts == 0) { + (*num) = 0; + return APR_SUCCESS; + } +#endif + if (timeout < 0) { tvptr = NULL; }