This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

bug report: poll() with listen sockets always gives POLLERR


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]