* bug report: poll() with listen sockets always gives POLLERR
@ 2002-11-19 7:26 Steven O'Brien
2002-11-20 1:39 ` Corinna Vinschen
0 siblings, 1 reply; 4+ messages in thread
From: Steven O'Brien @ 2002-11-19 7:26 UTC (permalink / raw)
To: cygwin
Hi
The current implementation of poll() does not behave correctly with
listen sockets. It always gives a POLLERR revent when a connection
request is received. I believe the error is in poll.cc lines 96-108:
switch (sock->recvfrom (peek, sizeof (peek), MSG_PEEK,
NULL, NULL))
{
case -1: /* Something weird happened */
fds[i].revents |= POLLERR;
break;
case 0: /* Closed on the read side. */
fds[i].revents |= POLLHUP;
break;
default:
fds[i].revents |= POLLIN;
break;
}
the recvfrom call always returns -1 for a listen socket, and so we
always get POLLERR. I could not see an easy way of detecting a listen
socket at this point in the code, since the fhandler_socket class
records listen and connected sockets as the same thing (type ==
CONNECTED).
Because glib uses poll() to detect connection requests in a server, all
glib-based servers now fail in cygwin. I guess most cygwin ported
servers must be using select() rather than poll() as this behaviour
first appeared in cygwin 1.3.13-1 but has not been reported to the list
until now.
My apologies for not providing a patch, but hopefully someone with
better knowledge of cygwin internals will be able to detect a listen
socket in the above code and provide a special case for it.
Regards,
Steven
--
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/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: bug report: poll() with listen sockets always gives POLLERR
2002-11-19 7:26 bug report: poll() with listen sockets always gives POLLERR Steven O'Brien
@ 2002-11-20 1:39 ` Corinna Vinschen
0 siblings, 0 replies; 4+ messages in thread
From: Corinna Vinschen @ 2002-11-20 1:39 UTC (permalink / raw)
To: cygwin
On Tue, Nov 19, 2002 at 01:34:30PM +0000, Steven O'Brien wrote:
> Hi
>
> The current implementation of poll() does not behave correctly with
> listen sockets. It always gives a POLLERR revent when a connection
> request is received. I believe the error is in poll.cc lines 96-108:
> [...]
Thanks for the report. I've checked in a patch. Please try the
next developers snapshot.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Developer mailto:cygwin@cygwin.com
Red Hat, Inc.
--
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/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: bug report: poll() with listen sockets always gives POLLERR
2002-11-20 1:48 Steven O'Brien
@ 2002-11-20 3:12 ` Corinna Vinschen
0 siblings, 0 replies; 4+ messages in thread
From: Corinna Vinschen @ 2002-11-20 3:12 UTC (permalink / raw)
To: cygwin
On Wed, Nov 20, 2002 at 09:07:30AM +0000, Steven O'Brien wrote:
> Corinna Vinschen wrote:
>
> > On Tue, Nov 19, 2002 at 01:34:30PM +0000, Steven O'Brien wrote:
> > > Hi
> > >
> > > The current implementation of poll() does not behave correctly with
> > > listen sockets. It always gives a POLLERR revent when a connection
> > > request is received. I believe the error is in poll.cc lines 96-108:
> > > [...]
>
> > Thanks for the report. I've checked in a patch. Please try the
> > next developers snapshot.
>
> > Corinna
>
> Thanks Corinna, but its still not quite right. poll() needs to set
> POLLIN
Oops, sure. Thanks, I've applied the patch.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Developer mailto:cygwin@cygwin.com
Red Hat, Inc.
--
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/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: bug report: poll() with listen sockets always gives POLLERR
@ 2002-11-20 1:48 Steven O'Brien
2002-11-20 3:12 ` Corinna Vinschen
0 siblings, 1 reply; 4+ messages in thread
From: Steven O'Brien @ 2002-11-20 1:48 UTC (permalink / raw)
To: cygwin
Corinna Vinschen wrote:
> On Tue, Nov 19, 2002 at 01:34:30PM +0000, Steven O'Brien wrote:
> > Hi
> >
> > The current implementation of poll() does not behave correctly with
> > listen sockets. It always gives a POLLERR revent when a connection
> > request is received. I believe the error is in poll.cc lines 96-108:
> > [...]
> Thanks for the report. I've checked in a patch. Please try the
> next developers snapshot.
> Corinna
Thanks Corinna, but its still not quite right. poll() needs to set
POLLIN
when a connection request is received on a listen socket. The following
patch completes the job:
--- poll.cc 2002-11-20 08:57:03.000000000 +0000
+++ poll.cc-fix 2002-11-20 09:01:21.000000000 +0000
@@ -111,9 +111,12 @@ poll (struct pollfd *fds, unsigned int n
Unfortunately, recvfrom() doesn't make much
sense then. It returns WSAENOTCONN in that
case. Since that's not actually an error,
- we must not set POLLERR. */
+ we must not set POLLERR, but POLLIN to
+ indicate the request. */
if (WSAGetLastError () != WSAENOTCONN)
fds[i].revents |= POLLERR;
+ else
+ fds[i].revents |= POLLIN;
break;
case 0: /* Closed on the read side. */
fds[i].revents |= POLLHUP;
Regards,
Steven
--
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/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-11-20 11:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-19 7:26 bug report: poll() with listen sockets always gives POLLERR Steven O'Brien
2002-11-20 1:39 ` Corinna Vinschen
2002-11-20 1:48 Steven O'Brien
2002-11-20 3:12 ` Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).