commit a8f8a27bc027d4a0f565a6e4e579d64192f5b846
parent 7056c9e811352498bba2765a4c47893906a2bc19
Author: LRN <lrn1986@gmail.com>
Date: Fri, 2 Aug 2013 12:37:08 +0000
Fix compiling for systems without SOCK_NONBLOCK
Diffstat:
2 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/configure.ac b/configure.ac
@@ -232,6 +232,28 @@ AM_CONDITIONAL(USE_PRIVATE_PLIBC_H, test x$our_private_plibc_h = x1)
AC_CHECK_FUNCS_ONCE(memmem)
AC_CHECK_FUNCS_ONCE(accept4)
+AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [
+ #if defined HAVE_SYS_TYPES_H
+ # include <sys/types.h>
+ #endif
+ #if defined HAVE_SYS_SOCKET_H
+ # include <sys/socket.h>
+ #elif defined HAVE_WINSOCK2_H
+ # include <winsock2.h>
+ #endif],
+ [
+ #ifndef SOCK_NONBLOCK
+ # error do not have SOCK_NONBLOCK
+ #endif
+ ])
+ ],
+ [
+ AC_DEFINE([HAVE_SOCK_NONBLOCK], [1], [SOCK_NONBLOCK is defined in a socket header])
+ ])
+
+
AC_SEARCH_LIBS([clock_gettime], [rt], [
AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Have clock_gettime])
])
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
@@ -1329,7 +1329,11 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
memset (addr, 0, sizeof (addrstorage));
if (-1 == (fd = daemon->socket_fd))
return MHD_NO;
+#ifdef HAVE_SOCK_NONBLOCK
nonblock = SOCK_NONBLOCK;
+#else
+ nonblock = 0;
+#endif
#ifdef CYGWIN
if (0 == (daemon->options & MHD_USE_SSL))
nonblock = 0;