* poll.cc (poll): Peek sockets ready for read to see if there's
actually data.
This commit is contained in:
parent
edb983c141
commit
7382e593a0
@ -1,3 +1,9 @@
|
|||||||
|
2002-08-29 Boris Schaeling <boriss@web.de>
|
||||||
|
Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* poll.cc (poll): Peek sockets ready for read to see if there's
|
||||||
|
actually data.
|
||||||
|
|
||||||
2002-08-28 Christopher Faylor <cgf@redhat.com>
|
2002-08-28 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* cygthread.cc (hthreads): Remove unneeded global.
|
* cygthread.cc (hthreads): Remove unneeded global.
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#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 <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
@ -85,7 +86,27 @@ poll (struct pollfd *fds, unsigned int nfds, int timeout)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (FD_ISSET(fds[i].fd, read_fds))
|
if (FD_ISSET(fds[i].fd, read_fds))
|
||||||
fds[i].revents |= POLLIN;
|
{
|
||||||
|
char peek[1];
|
||||||
|
fhandler_socket *sock =
|
||||||
|
cygheap->fdtab[fds[i].fd]->is_socket ();
|
||||||
|
if (!sock)
|
||||||
|
fds[i].revents |= POLLIN;
|
||||||
|
else
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (FD_ISSET(fds[i].fd, write_fds))
|
if (FD_ISSET(fds[i].fd, write_fds))
|
||||||
fds[i].revents |= POLLOUT;
|
fds[i].revents |= POLLOUT;
|
||||||
if (FD_ISSET(fds[i].fd, except_fds))
|
if (FD_ISSET(fds[i].fd, except_fds))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user