libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit b44ee8055618e350032ba7a49c799d53dd551ee1
parent cb83913d0e1483c6e702b96047d073107be046e8
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Thu,  7 May 2015 17:04:22 +0000

Define and use system-independent wrapper macro for poll()

Diffstat:
Msrc/include/platform_interface.h | 9+++++++++
Msrc/microhttpd/daemon.c | 6+++---
Mw32/VS2013/MHD_config.h | 11++++++++++-
3 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/src/include/platform_interface.h b/src/include/platform_interface.h @@ -124,6 +124,15 @@ #define MHD_SYS_select_(n,r,w,e,t) select((int)0,(r),(w),(e),(t)) #endif +#if defined(HAVE_POLL) +/* MHD_sys_poll_ is wrapper macro for system poll() function */ +#if !defined(MHD_WINSOCK_SOCKETS) +#define MHD_sys_poll_ poll +#else /* MHD_WINSOCK_SOCKETS */ +#define MHD_sys_poll_ WSAPoll +#endif /* MHD_WINSOCK_SOCKETS */ +#endif /* HAVE_POLL */ + /* MHD_pipe_ create pipe (!MHD_DONT_USE_PIPES) / * create two connected sockets (MHD_DONT_USE_PIPES) */ #ifndef MHD_DONT_USE_PIPES diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -951,7 +951,7 @@ MHD_handle_connection (void *data) extra_slot = 1; } #endif - if (poll (p, + if (MHD_sys_poll_ (p, #if WINDOWS 1 + extra_slot, #else @@ -2445,7 +2445,7 @@ MHD_poll_all (struct MHD_Daemon *daemon, free(p); return MHD_YES; } - if (poll (p, poll_server + num_connections, timeout) < 0) + if (MHD_sys_poll_(p, poll_server + num_connections, timeout) < 0) { if (EINTR == MHD_socket_errno_) { @@ -2565,7 +2565,7 @@ MHD_poll_listen_socket (struct MHD_Daemon *daemon, timeout = -1; if (0 == poll_count) return MHD_YES; - if (poll (p, poll_count, timeout) < 0) + if (MHD_sys_poll_(p, poll_count, timeout) < 0) { if (EINTR == MHD_socket_errno_) return MHD_YES; diff --git a/w32/VS2013/MHD_config.h b/w32/VS2013/MHD_config.h @@ -9,7 +9,6 @@ /* Define if MS VC compiler is used */ #define MSVC 1 - /* *** MHD configuration *** */ /* Undef to disable feature */ @@ -40,6 +39,16 @@ /* define to use W32 threads */ #define MHD_USE_W32_THREADS 1 +#ifndef _WIN32_WINNT +/* MHD supports Windows XP and later W32 systems*/ +#define _WIN32_WINNT 0x0501 +#endif /* _WIN32_WINNT */ + +/* winsock poll is available only on Vista and later */ +#if _WIN32_WINNT >= 0x0600 +#define HAVE_POLL 1 +#endif /* _WIN32_WINNT >= 0x0600 */ + /* define to 0 to disable epoll support */ #define EPOLL_SUPPORT 0