delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/02/02/22:02:38

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Sun, 2 Feb 2003 22:03:07 -0500
From: Christopher Faylor <cgf AT redhat DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: 1.3.19-1:poll bug. Patch included.
Message-ID: <20030203030307.GA16149@redhat.com>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <7374AB6B-3720-11D7-B5F3-00306540AD5E AT rehley DOT net>
Mime-Version: 1.0
In-Reply-To: <7374AB6B-3720-11D7-B5F3-00306540AD5E@rehley.net>
User-Agent: Mutt/1.5.1i

On Sun, Feb 02, 2003 at 06:37:34PM -0800, Peter Rehley wrote:
>Hello,
>
>While working on another program (syslogd in inetutils) I found that 
>the poll function was returning POLLERR when something arrived on a UDP 
>socket; it should be return POLLIN.  Inside the poll function, recvfrom 
>was returning -1 with errno = EMSGSIZE, but the only error value being 
>check for in WSAENOTCONN.  However EMSGSIZE is a reasonable return 
>value since the buffer to recvfrom was only 1 byte while the actual 
>message size was larger than this.  Basically saying your buffer is too 
>small for the message, but since we are only peeking, this shouldn't be 
>returned as a POLLERR.
>
>The fix should be to add EMSGSIZE as part of the condition so this 
>error returns POLLIN.  I'm including the patch below and a changelog 
>following that.  Please review these changes and make sure that they 
>seem reasonable.  I've done tests on my system (windows XP) and have 
>verified that the change works.

Thanks for the patch.  Would you mind reworking it so that it doesn't set
errno at all in the case that you describe and then check against the correct
WSAGetLastError value?

cgf

>Patch
>-----------------------------------
>Index: winsup/cygwin/poll.cc
>===================================================================
>RCS file: /cvs/src/src/winsup/cygwin/poll.cc,v
>retrieving revision 1.34
>diff -u -p -r1.34 poll.cc
>--- winsup/cygwin/poll.cc	20 Nov 2002 11:00:15 -0000	1.34
>+++ winsup/cygwin/poll.cc	3 Feb 2003 01:52:10 -0000
>@@ -112,7 +112,8 @@ poll (struct pollfd *fds, unsigned int n
> 				 sense then.  It returns WSAENOTCONN in that
> 				 case.  Since that's not actually an error,
> 				 we must not set POLLERR but POLLIN. */
>-			      if (WSAGetLastError () != WSAENOTCONN)
>+			      if (WSAGetLastError () != WSAENOTCONN &&
>+				  errno!=EMSGSIZE)
> 				fds[i].revents |= POLLERR;
> 			      else
> 				fds[i].revents |= POLLIN;
>----------------------
>Changelog
>2003-02-02  Peter Rehley<peter AT rehley DOT net>
>
>* poll.cc: EMSGSIZE being ignore returning incorrect POLLERR on UDP 
>socket receive
> if recvfrom returns error, return POLLIN if errno = EMSGSIZE
>-----------------------
>
>Peter
>=====
>Infinity Softworks.  Making scientific, financial and realtor 
>calculators for Palm Pilots and other PDAs since 1997
>
>Visit them today at http://www.infinitysw.com
>
>
>--
>Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>Bug reporting:         http://cygwin.com/bugs.html
>Documentation:         http://cygwin.com/docs.html
>FAQ:                   http://cygwin.com/faq/

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019