* - Calling this with NULL sets as a portable way to sleep with sub-second
* accuracy is not supported.
* */
-PHPAPI int php_select(int max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv)
+PHPAPI int php_select(php_socket_t max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv)
{
ULONGLONG ms_total, limit;
HANDLE handles[MAXIMUM_WAIT_OBJECTS];
FD_ZERO(&sock_except);
/* build an array of handles for non-sockets */
- for (i = 0; i < max_fd; i++) {
+ for (i = 0; i < INT_MAX && i < max_fd; i++) {
if (SAFE_FD_ISSET(i, rfds) || SAFE_FD_ISSET(i, wfds) || SAFE_FD_ISSET(i, efds)) {
handles[n_handles] = (HANDLE)(zend_uintptr_t)_get_osfhandle(i);
if (handles[n_handles] == INVALID_HANDLE_VALUE) {
if (n_handles == 0) {
/* plain sockets only - let winsock handle the whole thing */
- return select(max_fd, rfds, wfds, efds, tv);
+ return select(0, rfds, wfds, efds, tv);
}
/* mixture of handles and sockets; lets multiplex between
tvslice.tv_sec = 0;
tvslice.tv_usec = 100000;
- retcode = select(sock_max_fd+1, &aread, &awrite, &aexcept, &tvslice);
+ retcode = select(0, &aread, &awrite, &aexcept, &tvslice);
}
if (n_handles > 0) {
/* check handles */
/* $Id$ */
-PHPAPI int php_select(int max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv);
+#include "php_network.h"
+PHPAPI int php_select(php_socket_t max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv);