Index: src/Modules/socketmodule.c =================================================================== RCS file: /cvs/python/src/Modules/Attic/socketmodule.c,v retrieving revision 1.1.2.3.2.1 diff -u -r1.1.2.3.2.1 socketmodule.c --- src/Modules/socketmodule.c 8 Jun 2004 11:07:54 -0000 1.1.2.3.2.1 +++ src/Modules/socketmodule.c 10 Jun 2004 11:06:49 -0000 @@ -209,6 +209,12 @@ #include #include +#if defined(HAVE_POLL_H) +#include +#elif defined(HAVE_SYS_POLL_H) +#include +#endif + /* Generic socket object definitions and includes */ #define PySocket_BUILDING_SOCKET #include "socketmodule.h" @@ -594,8 +600,12 @@ static int internal_select(PySocketSockObject *s, int writing) { +#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) + struct pollfd pfd = {0}; +#else fd_set fds; struct timeval tv; +#endif /* HAVE_POLL && !HAVE_BROKEN_POLL */ int n; /* Nothing to do unless we're in timeout mode (not non-blocking) */ @@ -606,6 +616,19 @@ if (s->sock_fd < 0) return 0; + /* poll() is preferred over select() because + it supports filedescriptors > FD_SETSIZE */ +#if defined(HAVE_POLL) && !defined(HAVE_BROKEN_POLL) + /* Construct the arguments to poll */ + pfd.fd = s->sock_fd; + if (writing) + pfd.events = POLLOUT; + else + pfd.events = POLLIN; + + /* See if the socket is ready */ + n = poll(&pfd, 1, (int)(s->sock_timeout * 1000)); +#else /* Construct the arguments to select */ tv.tv_sec = (int)s->sock_timeout; tv.tv_usec = (int)((s->sock_timeout - tv.tv_sec) * 1e6); @@ -617,6 +640,7 @@ n = select(s->sock_fd+1, NULL, &fds, NULL, &tv); else n = select(s->sock_fd+1, &fds, NULL, NULL, &tv); +#endif /* HAVE_POLL && !HAVE_BROKEN_POLL */ if (n == 0) return 1; return 0;