Remove emulated_poll on Windows
This commit is contained in:
parent
0fc37b64f6
commit
8df031d336
5 changed files with 2 additions and 131 deletions
|
@ -300,11 +300,6 @@ if (WIN32)
|
|||
list(APPEND HDR_PUBLIC
|
||||
${WIN32_HELPERS_PATH}/websock-w32.h
|
||||
)
|
||||
if (NOT MINGW)
|
||||
list(APPEND SOURCES
|
||||
${WIN32_HELPERS_PATH}/websock-w32.c
|
||||
)
|
||||
endif()
|
||||
include_directories(${WIN32_HELPERS_PATH})
|
||||
else(WIN32)
|
||||
# Unix.
|
||||
|
@ -566,7 +561,7 @@ if (NOT LWS_WITHOUT_TESTAPPS)
|
|||
if (NOT LWS_WITHOUT_TEST_SERVER_EXTPOLL)
|
||||
create_test_app(test-server-extpoll
|
||||
"test-server/test-server.c"
|
||||
"win32port/win32helpers/websock-w32.c"
|
||||
""
|
||||
"${WIN32_HELPERS_PATH}/netdb.h;${WIN32_HELPERS_PATH}/strings.h;${WIN32_HELPERS_PATH}/unistd.h;${WIN32_HELPERS_PATH}/websock-w32.h")
|
||||
# Set defines for this executable only.
|
||||
set_property(
|
||||
|
|
|
@ -47,14 +47,6 @@
|
|||
int openssl_websocket_private_data_index;
|
||||
#endif
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#include "../win32port/win32helpers/websock-w32.c"
|
||||
#else
|
||||
#ifdef __MINGW64__
|
||||
#include "../win32port/win32helpers/websock-w32.c"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LWS_BUILD_HASH
|
||||
#define LWS_BUILD_HASH "unknown-build-hash"
|
||||
#endif
|
||||
|
|
|
@ -34,14 +34,7 @@
|
|||
#ifdef WIN32
|
||||
|
||||
#ifdef EXTERNAL_POLL
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "websock-w32.h"
|
||||
#define poll WSAPoll
|
||||
#endif
|
||||
|
||||
#else // NOT WIN32
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
#define FD_SETSIZE 256
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#ifdef __MINGW64__
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <WinSock2.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "websock-w32.h"
|
||||
|
||||
PFNWSAPOLL poll = NULL;
|
||||
|
||||
INT WSAAPI emulated_poll(LPWSAPOLLFD fdarray, ULONG nfds, INT timeout)
|
||||
{
|
||||
fd_set readfds;
|
||||
fd_set writefds;
|
||||
struct timeval tv;
|
||||
struct timeval *ptv = &tv;
|
||||
SOCKET max_socket = 0;
|
||||
ULONG n = 0;
|
||||
int waiting;
|
||||
int pending = 0;
|
||||
WSAPOLLFD * poll_fd = fdarray;
|
||||
|
||||
if (NULL == fdarray) {
|
||||
WSASetLastError(WSAEFAULT);
|
||||
return -1;
|
||||
}
|
||||
|
||||
FD_ZERO(&readfds);
|
||||
FD_ZERO(&writefds);
|
||||
|
||||
tv.tv_sec = timeout / 1000;
|
||||
tv.tv_usec = (timeout % 1000) * 1000;
|
||||
|
||||
if (timeout < 0)
|
||||
ptv = NULL;
|
||||
|
||||
while (n < nfds) {
|
||||
|
||||
poll_fd->revents = 0;
|
||||
|
||||
if ((int)poll_fd->fd < 0 || !poll_fd->events)
|
||||
goto skip1;
|
||||
|
||||
if (max_socket < poll_fd->fd)
|
||||
max_socket = poll_fd->fd;
|
||||
|
||||
if (poll_fd->events & POLLIN)
|
||||
FD_SET(poll_fd->fd, &readfds);
|
||||
|
||||
if (poll_fd->events & POLLOUT)
|
||||
FD_SET(poll_fd->fd, &writefds);
|
||||
skip1:
|
||||
poll_fd++;
|
||||
n++;
|
||||
}
|
||||
|
||||
waiting = select((int)max_socket + 1, &readfds, &writefds, NULL, ptv);
|
||||
|
||||
if (waiting <= 0)
|
||||
return waiting;
|
||||
|
||||
poll_fd = fdarray;
|
||||
|
||||
while (waiting && nfds--) {
|
||||
|
||||
if (!poll_fd->events)
|
||||
goto skip2;
|
||||
|
||||
if (poll_fd->fd <= 0) {
|
||||
poll_fd->revents = POLLNVAL;
|
||||
goto skip2;
|
||||
}
|
||||
|
||||
if (FD_ISSET(poll_fd->fd, &readfds)) {
|
||||
|
||||
/* defer POLLHUP / error detect to false read attempt */
|
||||
|
||||
poll_fd->revents |= POLLIN;
|
||||
waiting--;
|
||||
}
|
||||
|
||||
if (FD_ISSET(poll_fd->fd, &writefds)) {
|
||||
|
||||
poll_fd->revents |= poll_fd->events & POLLOUT;
|
||||
waiting--;
|
||||
}
|
||||
|
||||
if (poll_fd->revents)
|
||||
pending++;
|
||||
|
||||
skip2:
|
||||
poll_fd++;
|
||||
}
|
||||
|
||||
return pending;
|
||||
}
|
|
@ -46,12 +46,6 @@ typedef struct pollfd {
|
|||
|
||||
#endif
|
||||
|
||||
typedef INT (WSAAPI *PFNWSAPOLL)(LPWSAPOLLFD fdarray, ULONG nfds, INT timeout);
|
||||
extern PFNWSAPOLL poll;
|
||||
|
||||
#ifndef __MINGW32__
|
||||
extern INT WSAAPI emulated_poll(LPWSAPOLLFD fdarray, ULONG nfds, INT timeout);
|
||||
#endif
|
||||
/* override configure because we are not using Makefiles */
|
||||
|
||||
#define LWS_NO_FORK
|
||||
|
|
Loading…
Add table
Reference in a new issue