libmicrohttpd

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

commit a6458cd3a9852b446b963e277e4269837a89a7df
parent d47eb38bf6002c363b7c4c1113fba124ba518d72
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Wed, 14 Sep 2016 18:51:12 +0000

HTTP Upgrade: portability corrections

Diffstat:
Mconfigure.ac | 3++-
Msrc/microhttpd/response.c | 8++++++--
Msrc/microhttpd/test_upgrade.c | 6+++---
Msrc/microhttpd/test_upgrade_common.c | 11+++++++++--
Msrc/microhttpd/test_upgrade_ssl.c | 8++++----
5 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/configure.ac b/configure.ac @@ -558,7 +558,8 @@ fi AC_CHECK_HEADERS([fcntl.h math.h errno.h limits.h stdio.h locale.h sys/stat.h sys/types.h],,AC_MSG_ERROR([Compiling libmicrohttpd requires standard UNIX headers files])) # Check for optional headers -AC_CHECK_HEADERS([sys/types.h sys/time.h sys/msg.h netdb.h netinet/in.h netinet/tcp.h time.h sys/socket.h sys/mman.h arpa/inet.h sys/select.h search.h \ +AC_CHECK_HEADERS([sys/types.h sys/time.h sys/msg.h time.h sys/mman.h search.h sys/ioctl.h \ + sys/socket.h sys/select.h netdb.h netinet/in.h netinet/ip.h netinet/tcp.h arpa/inet.h \ endian.h machine/endian.h sys/endian.h sys/param.h sys/machine.h sys/byteorder.h machine/param.h sys/isa_defs.h \ inttypes.h stddef.h unistd.h \ sockLib.h inetLib.h net/if.h]) diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c @@ -25,6 +25,11 @@ #define MHD_NO_DEPRECATION 1 +#include "mhd_options.h" +#ifdef HAVE_SYS_IOCTL_H +#include <sys/ioctl.h> +#endif /* HAVE_SYS_IOCTL_H */ + #include "internal.h" #include "response.h" #include "mhd_limits.h" @@ -33,7 +38,6 @@ #include "connection.h" #include "memorypool.h" -#include <sys/ioctl.h> #if defined(_WIN32) && defined(MHD_W32_MUTEX_) #ifndef WIN32_LEAN_AND_MEAN @@ -714,7 +718,7 @@ MHD_response_execute_upgrade_ (struct MHD_Response *response, struct MemoryPool *pool; size_t avail; char *buf; - int sv[2]; + MHD_socket sv[2]; if (! MHD_socket_pair_ (sv)) { diff --git a/src/microhttpd/test_upgrade.c b/src/microhttpd/test_upgrade.c @@ -35,10 +35,10 @@ #include <unistd.h> #endif -#include <sys/socket.h> -#include <netinet/in.h> -#include <netinet/ip.h> #include "mhd_sockets.h" +#ifdef HAVE_NETINET_IP_H +#include <netinet/ip.h> +#endif /* HAVE_NETINET_IP_H */ #include "test_upgrade_common.c" diff --git a/src/microhttpd/test_upgrade_common.c b/src/microhttpd/test_upgrade_common.c @@ -46,14 +46,15 @@ static pthread_t pt_client; static int done; /** - * Change itc FD options to be non-blocking. + * Change socket to non-blocking. * - * @param fd the FD to manipulate + * @param fd the socket to manipulate * @return non-zero if succeeded, zero otherwise */ static void make_blocking (MHD_socket fd) { +#if defined(MHD_POSIX_SOCKETS) int flags; flags = fcntl (fd, F_GETFL); @@ -62,6 +63,12 @@ make_blocking (MHD_socket fd) if ((flags & ~O_NONBLOCK) != flags) if (-1 == fcntl (fd, F_SETFL, flags & ~O_NONBLOCK)) abort (); +#elif defined(MHD_WINSOCK_SOCKETS) + unsigned long flags = 1; + + ioctlsocket (fd, FIONBIO, &flags); +#endif /* MHD_WINSOCK_SOCKETS */ + } diff --git a/src/microhttpd/test_upgrade_ssl.c b/src/microhttpd/test_upgrade_ssl.c @@ -34,12 +34,12 @@ #include <unistd.h> #endif -#include <sys/socket.h> -#include <sys/wait.h> -#include <netinet/in.h> -#include <netinet/ip.h> #include <pthread.h> #include "mhd_sockets.h" +#ifdef HAVE_NETINET_IP_H +#include <netinet/ip.h> +#endif /* HAVE_NETINET_IP_H */ +#include "mhd_sockets.h" #include "test_upgrade_common.c" #include "../testcurl/https/tls_test_keys.h"