diff --git a/ext/mysqlnd/mysqlnd_vio.c b/ext/mysqlnd/mysqlnd_vio.c index ef097c94611..043dcfeeef6 100644 --- a/ext/mysqlnd/mysqlnd_vio.c +++ b/ext/mysqlnd/mysqlnd_vio.c @@ -36,7 +36,7 @@ static int mysqlnd_set_sock_no_delay(php_stream * stream) { - int socketd = ((php_netstream_data_t*)stream->abstract)->socket; + php_socket_t socketd = ((php_netstream_data_t*)stream->abstract)->socket; int ret = SUCCESS; int flag = 1; int result = setsockopt(socketd, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int)); @@ -56,7 +56,7 @@ mysqlnd_set_sock_no_delay(php_stream * stream) static int mysqlnd_set_sock_keepalive(php_stream * stream) { - int socketd = ((php_netstream_data_t*)stream->abstract)->socket; + php_socket_t socketd = ((php_netstream_data_t*)stream->abstract)->socket; int ret = SUCCESS; int flag = 1; int result = setsockopt(socketd, SOL_SOCKET, SO_KEEPALIVE, (char *) &flag, sizeof(int)); diff --git a/win32/select.c b/win32/select.c index e3b66de9584..32826377723 100644 --- a/win32/select.c +++ b/win32/select.c @@ -34,18 +34,22 @@ * - Calling this with NULL sets as a portable way to sleep with sub-second * accuracy is not supported. * */ -PHPAPI int php_select(SOCKET 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]; - int handle_slot_to_fd[MAXIMUM_WAIT_OBJECTS]; - int n_handles = 0, i; + php_socket_t handle_slot_to_fd[MAXIMUM_WAIT_OBJECTS]; + php_socket_t n_handles = 0, i; fd_set sock_read, sock_write, sock_except; fd_set aread, awrite, aexcept; - int sock_max_fd = -1; + php_socket_t sock_max_fd = -1; struct timeval tvslice; int retcode; + if (max_fd < 0) { + return FAILURE; + } + #define SAFE_FD_ISSET(fd, set) (set != NULL && FD_ISSET(fd, set)) /* calculate how long we need to wait in milliseconds */ @@ -136,13 +140,13 @@ PHPAPI int php_select(SOCKET max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, s for (i = 0; i < n_handles; i++) { if (WAIT_OBJECT_0 == WaitForSingleObject(handles[i], 0)) { if (SAFE_FD_ISSET(handle_slot_to_fd[i], rfds)) { - FD_SET((uint32_t)handle_slot_to_fd[i], &aread); + FD_SET((php_socket_t) handle_slot_to_fd[i], &aread); } if (SAFE_FD_ISSET(handle_slot_to_fd[i], wfds)) { - FD_SET((uint32_t)handle_slot_to_fd[i], &awrite); + FD_SET((php_socket_t) handle_slot_to_fd[i], &awrite); } if (SAFE_FD_ISSET(handle_slot_to_fd[i], efds)) { - FD_SET((uint32_t)handle_slot_to_fd[i], &aexcept); + FD_SET((php_socket_t) handle_slot_to_fd[i], &aexcept); } retcode++; } diff --git a/win32/select.h b/win32/select.h index 81032e01666..ef91684363d 100644 --- a/win32/select.h +++ b/win32/select.h @@ -18,6 +18,6 @@ /* $Id$ */ -#include +#include "php_network.h" -PHPAPI int php_select(SOCKET 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);