Mercurial > hg > nginx
diff src/os/win32/ngx_socket.h @ 7444:4089b3d2cb59
Win32: added WSAPoll() support.
WSAPoll() is only available with Windows Vista and newer (and only
available during compilation if _WIN32_WINNT >= 0x0600). To make
sure the code works with Windows XP, we do not redefine _WIN32_WINNT,
but instead load WSAPoll() dynamically if it is not available during
compilation.
Also, sockets are not guaranteed to be small integers on Windows.
So an index array is used instead of NGX_USE_FD_EVENT to map
events to connections.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 24 Jan 2019 21:51:21 +0300 |
parents | 2a621245f4cf |
children | efd71d49bde0 |
line wrap: on
line diff
--- a/src/os/win32/ngx_socket.h +++ b/src/os/win32/ngx_socket.h @@ -200,6 +200,49 @@ extern LPFN_CONNECTEX ngx_co extern LPFN_DISCONNECTEX ngx_disconnectex; +#if (NGX_HAVE_POLL && !defined POLLIN) + +/* + * WSAPoll() is only available if _WIN32_WINNT >= 0x0600. + * If it is not available during compilation, we try to + * load it dynamically at runtime. + */ + +#define NGX_LOAD_WSAPOLL 1 + +#define POLLRDNORM 0x0100 +#define POLLRDBAND 0x0200 +#define POLLIN (POLLRDNORM | POLLRDBAND) +#define POLLPRI 0x0400 + +#define POLLWRNORM 0x0010 +#define POLLOUT (POLLWRNORM) +#define POLLWRBAND 0x0020 + +#define POLLERR 0x0001 +#define POLLHUP 0x0002 +#define POLLNVAL 0x0004 + +typedef struct pollfd { + + SOCKET fd; + SHORT events; + SHORT revents; + +} WSAPOLLFD, *PWSAPOLLFD, FAR *LPWSAPOLLFD; + +typedef int (WSAAPI *ngx_wsapoll_pt)( + LPWSAPOLLFD fdArray, + ULONG fds, + INT timeout + ); + +extern ngx_wsapoll_pt WSAPoll; +extern ngx_uint_t ngx_have_wsapoll; + +#endif + + int ngx_tcp_push(ngx_socket_t s); #define ngx_tcp_push_n "tcp_push()"