delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/11/19/08:33:43

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: Tue, 19 Nov 2002 13:34:30 +0000
From: "Steven O'Brien" <steven DOT obrien2 AT ntlworld DOT com>
To: cygwin <cygwin AT cygwin DOT com>
Subject: bug report: poll() with listen sockets always gives POLLERR
Message-Id: <20021119133430.6cf25202.steven.obrien2@ntlworld.com>
Mime-Version: 1.0

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/

- Raw text -


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