* poll.cc (poll): Don't set POLLERR if a listening socket has a
pending connect. Don't use errno value from call to fhandler_socket::recvfrom().
This commit is contained in:
parent
ec97538aa2
commit
03b65245db
|
@ -1,3 +1,9 @@
|
||||||
|
2002-11-20 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* poll.cc (poll): Don't set POLLERR if a listening socket has a
|
||||||
|
pending connect. Don't use errno value from call to
|
||||||
|
fhandler_socket::recvfrom().
|
||||||
|
|
||||||
2002-11-19 Christopher Faylor <cgf@redhat.com>
|
2002-11-19 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* net.cc: Sprinkle sigframes throughout.
|
* net.cc: Sprinkle sigframes throughout.
|
||||||
|
|
|
@ -8,12 +8,16 @@
|
||||||
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
||||||
details. */
|
details. */
|
||||||
|
|
||||||
|
#define __INSIDE_CYGWIN_NET__
|
||||||
|
|
||||||
#include "winsup.h"
|
#include "winsup.h"
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/poll.h>
|
#include <sys/poll.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#define USE_SYS_TYPES_FD_SET
|
||||||
|
#include <winsock2.h>
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "fhandler.h"
|
#include "fhandler.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
@ -93,10 +97,22 @@ poll (struct pollfd *fds, unsigned int nfds, int timeout)
|
||||||
if (!sock)
|
if (!sock)
|
||||||
fds[i].revents |= POLLIN;
|
fds[i].revents |= POLLIN;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
/* The following action can change errno. We have to
|
||||||
|
reset it to it's old value. */
|
||||||
|
int old_errno = get_errno ();
|
||||||
switch (sock->recvfrom (peek, sizeof (peek), MSG_PEEK,
|
switch (sock->recvfrom (peek, sizeof (peek), MSG_PEEK,
|
||||||
NULL, NULL))
|
NULL, NULL))
|
||||||
{
|
{
|
||||||
case -1: /* Something weird happened */
|
case -1: /* Something weird happened */
|
||||||
|
/* When select returns that data is available,
|
||||||
|
that could mean that the socket is in
|
||||||
|
listen mode and a client tries to connect.
|
||||||
|
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. */
|
||||||
|
if (WSAGetLastError () != WSAENOTCONN)
|
||||||
fds[i].revents |= POLLERR;
|
fds[i].revents |= POLLERR;
|
||||||
break;
|
break;
|
||||||
case 0: /* Closed on the read side. */
|
case 0: /* Closed on the read side. */
|
||||||
|
@ -106,6 +122,8 @@ poll (struct pollfd *fds, unsigned int nfds, int timeout)
|
||||||
fds[i].revents |= POLLIN;
|
fds[i].revents |= POLLIN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
set_errno (old_errno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (FD_ISSET(fds[i].fd, write_fds))
|
if (FD_ISSET(fds[i].fd, write_fds))
|
||||||
fds[i].revents |= POLLOUT;
|
fds[i].revents |= POLLOUT;
|
||||||
|
|
Loading…
Reference in New Issue