[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r38107 - in libmicrohttpd: . src/microhttpd w32/common
From: |
gnunet |
Subject: |
[GNUnet-SVN] r38107 - in libmicrohttpd: . src/microhttpd w32/common |
Date: |
Tue, 11 Oct 2016 17:20:50 +0200 |
Author: Karlson2k
Date: 2016-10-11 17:20:50 +0200 (Tue, 11 Oct 2016)
New Revision: 38107
Modified:
libmicrohttpd/configure.ac
libmicrohttpd/src/microhttpd/daemon.c
libmicrohttpd/src/microhttpd/mhd_itc.c
libmicrohttpd/src/microhttpd/mhd_itc.h
libmicrohttpd/w32/common/MHD_config.h
Log:
Add 'configure' parameter to control ITC type
Modified: libmicrohttpd/configure.ac
===================================================================
--- libmicrohttpd/configure.ac 2016-10-11 15:20:47 UTC (rev 38106)
+++ libmicrohttpd/configure.ac 2016-10-11 15:20:50 UTC (rev 38107)
@@ -20,7 +20,7 @@
# Process this file with autoconf to produce a configure script.
#
#
-AC_PREREQ([2.60])
+AC_PREREQ([2.64])
LT_PREREQ([2.4.0])
AC_INIT([GNU Libmicrohttpd],[0.9.51],address@hidden)
AM_INIT_AUTOMAKE([silent-rules] [subdir-objects])
@@ -562,7 +562,7 @@
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 sys/eventfd.h], [], [], [AC_INCLUDES_DEFAULT])
+ sockLib.h inetLib.h net/if.h], [], [], [AC_INCLUDES_DEFAULT])
AM_CONDITIONAL([HAVE_TSEARCH], [test "x$ac_cv_header_search_h" = "xyes"])
# Check for generic functions
@@ -585,20 +585,79 @@
])
-# Check for pipe/socketpair signaling
-AC_MSG_CHECKING([[whether to enable signaling by socketpair]])
+# Check for inter-thread signaling type
+AC_ARG_ENABLE([[itc]],
+ [AS_HELP_STRING([[--enable-itc=TYPE]], [use TYPE of inter-thread
communication (pipe, socketpair, eventfd) [auto]])], [],
+ [[enable_itc='auto']]
+)
-AC_ARG_ENABLE([[socketpair]],
- [AS_HELP_STRING([[--enable-socketpair[=ARG]]], [disable internal
singalling by pipes and use socket pair instead (yes, no, try) [no]])], ,
- [AS_IF([[test "x$os_is_windows" = "xyes"]], [enable_socketpair=yes],
[enable_socketpair=no])]
- )
+AS_CASE([[$enable_itc]],
+ [[pipe]], [[:]],
+ [[socketpair]], [[:]],
+ [[eventfd]], [[:]],
+ [[auto]], [AS_VAR_IF([[os_is_windows]], [["yes"]],
[[enable_itc='socketpair']])],
+ [[eventFD]], [[enable_itc='eventfd']],
+ [[socket]], [[enable_itc='socketpair']],
+ [[no]], [AC_MSG_ERROR([[inter-thread communication cannot be disabled]])],
+ [AC_MSG_ERROR([[unrecognized type "$enable_itc" of inter-thread
communication specified by "--enable-itc=$enable_itc"]])]
+)
+# AS_UNSET([[use_itc]])
-AS_IF(
- [[test "x$enable_socketpair" != "xno"]],
- [AS_IF([[test "x$os_is_windows" = "xyes"]],
- [ AC_MSG_RESULT([[yes, forced on W32]]) ],
- [ AC_LINK_IFELSE(
- [ AC_LANG_PROGRAM([[
+AS_IF([[test "x$enable_itc" = "xeventfd" || test "x$enable_itc" = "xauto"]], [
+ AS_VAR_IF([[os_is_native_w32]], [["yes"]], [], [
+ AC_CHECK_HEADERS([[sys/eventfd.h]], [], [], [AC_INCLUDES_DEFAULT])
+ AS_VAR_IF([[ac_cv_header_sys_eventfd_h]], [["yes"]], [
+ AC_CACHE_CHECK([whether eventfd(2) is usable],
[[mhd_cv_eventfd_usable]], [
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([[
+#include <sys/eventfd.h>
+ ]], [[int ef = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK)
+ ]])
+ ], [[mhd_cv_eventfd_usable='yes']], [[mhd_cv_eventfd_usable='no']])
+ ])
+ ])
+ ])
+ AS_VAR_IF([[mhd_cv_eventfd_usable]], [["yes"]], [
+ use_itc='eventfd'
+ enable_itc="$use_itc"
+ AC_DEFINE([[_MHD_ITC_EVENTFD]], [[1]], [Define to use eventFD for
inter-thread communication])
+ ], [
+ AS_VAR_IF([[enable_itc]], [["eventfd"]], [AC_MSG_ERROR([[eventfd(2) is not
usable, consider using other type of inter-thread communication]])])
+ ])
+])
+
+AS_IF([[test "x$enable_itc" = "xpipe" || test "x$enable_itc" = "xauto"]], [
+ AS_VAR_IF([[os_is_native_w32]], [["yes"]], [], [
+ AC_CACHE_CHECK([[whether pipe(3) is usable]], [[mhd_cv_pipe_usable]], [
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([
+AC_INCLUDES_DEFAULT
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+ ], [[
+ int arr[2];
+ int res;
+ res = pipe(arr)
+ ]])
+ ], [[mhd_cv_pipe_usable='yes']], [[mhd_cv_pipe_usable='no']])
+ ])
+ ])
+ AS_VAR_IF([[mhd_cv_pipe_usable]], [["yes"]], [
+ use_itc='pipe'
+ enable_itc="$use_itc"
+ AC_DEFINE([[_MHD_ITC_PIPE]], [[1]], [Define to use pipe for inter-thread
communication])
+ ], [
+ AS_VAR_IF([[enable_itc]], [["pipe"]], [AC_MSG_ERROR([[pipe(3) is not
usable, consider using other type of inter-thread communication]])])
+ ])
+])
+
+AS_IF([[test "x$enable_itc" = "xsocketpair" || test "x$enable_itc" =
"xauto"]], [
+ AS_VAR_IF([[os_is_native_w32]], [["yes"]],
[[mhd_cv_socketpair_usable='yes']], [
+ AC_CACHE_CHECK([[whether socketpair(3) is usable]],
[[mhd_cv_socketpair_usable]], [
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([
+AC_INCLUDES_DEFAULT
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
@@ -605,28 +664,34 @@
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
- ]],[[
- int sv[2];
- if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv)
!= 0) return 1
- ]])
- ],
- [ AC_MSG_RESULT([[yes, socketpair in available]]) ],
- [ AC_MSG_RESULT([[no, socketpair in not available]])
- AS_IF([[test "x$enable_socketpair" = "xyes"]], [
AC_MSG_ERROR([[socketpair signalling cannot be enabled.]]) ])
- ]
- )
- ]
- )
- ],
- [
- AC_MSG_RESULT([[no]])
- AS_IF([[test "x$os_is_windows" = "xyes"]], [ AC_MSG_ERROR([[socketpair
must be enabled on W32]]) ])
- ]
- )
-if test "x$enable_socketpair" = "xyes"; then
- AC_DEFINE([[MHD_DONT_USE_PIPES]], [[1]], [Define to use pair of sockets
instead of pipes for signaling])
-fi
+ ], [[
+ int arr[2];
+ int res;
+#if defined(AF_LOCAL)
+ res = socketpair(AF_LOCAL, SOCK_STREAM, 0, arr);
+#elif defined(AF_UNIX)
+ res = socketpair(AF_UNIX, SOCK_STREAM, 0, arr);
+#else
+#error AF_LOCAL and AF_UNIX are both undefined
+ choke me now;
+#endif
+ if (res != 0) return 1
+ ]])
+ ], [[mhd_cv_socketpair_usable='yes']], [[mhd_cv_socketpair_usable='no']])
+ ])
+ ])
+ AS_VAR_IF([[mhd_cv_socketpair_usable]], [["yes"]], [
+ use_itc='socketpair'
+ enable_itc="$use_itc"
+ AC_DEFINE([[_MHD_ITC_SOCKETPAIR]], [[1]], [Define to use socketpair for
inter-thread communication])
+ ], [
+ AS_VAR_IF([[enable_itc]], [["socketpair"]], [AC_MSG_ERROR([[socketpair(3)
is not usable, consider using other type of inter-thread communication]])])
+ ])
+])
+AS_IF([[test -z "$use_itc"]], [AC_MSG_ERROR([[cannot find useable type of
inter-thread communication]])])
+
+
AC_CHECK_FUNCS_ONCE([accept4 gmtime_r memmem snprintf])
AC_CHECK_DECL([gmtime_s],
[
@@ -1116,6 +1181,7 @@
Operating System: ${host_os}
Threading lib: ${USE_THREADS}
Use thread names: ${enable_thread_names}
+ Inter-thread comm: ${use_itc}
libcurl (testing): ${MSG_CURL}
Target directory: ${prefix}
Messages: ${enable_messages}
Modified: libmicrohttpd/src/microhttpd/daemon.c
===================================================================
--- libmicrohttpd/src/microhttpd/daemon.c 2016-10-11 15:20:47 UTC (rev
38106)
+++ libmicrohttpd/src/microhttpd/daemon.c 2016-10-11 15:20:50 UTC (rev
38107)
@@ -5576,7 +5576,7 @@
return MHD_NO;
#endif
case MHD_FEATURE_SOCKETPAIR:
-#ifdef MHD_DONT_USE_PIPES
+#ifdef _MHD_ITC_SOCKETPAIR
return MHD_YES;
#else
return MHD_NO;
Modified: libmicrohttpd/src/microhttpd/mhd_itc.c
===================================================================
--- libmicrohttpd/src/microhttpd/mhd_itc.c 2016-10-11 15:20:47 UTC (rev
38106)
+++ libmicrohttpd/src/microhttpd/mhd_itc.c 2016-10-11 15:20:50 UTC (rev
38107)
@@ -33,7 +33,7 @@
#include "internal.h"
-#ifdef HAVE_SYS_EVENTFD_H
+#ifdef _MHD_ITC_EVENTFD
int
MHD_pipe_write_ (struct MHD_Pipe pip,
@@ -49,9 +49,9 @@
return sz;
}
-#else
+#endif /* _MHD_ITC_EVENTFD */
-#ifndef MHD_DONT_USE_PIPES
+#if defined(_MHD_ITC_PIPE)
#if !defined(_WIN32) || defined(__CYGWIN__)
@@ -83,6 +83,5 @@
}
return !0;
}
-#endif /* _WIN32 && ! __CYGWIN__ */
-#endif /* ! MHD_DONT_USE_PIPES */
-#endif /* ! HAVE_SYS_EVENTFD_H */
+#endif /* !_WIN32 || __CYGWIN__ */
+#endif /* _MHD_ITC_EVENTFD || _MHD_ITC_PIPE */
Modified: libmicrohttpd/src/microhttpd/mhd_itc.h
===================================================================
--- libmicrohttpd/src/microhttpd/mhd_itc.h 2016-10-11 15:20:47 UTC (rev
38106)
+++ libmicrohttpd/src/microhttpd/mhd_itc.h 2016-10-11 15:20:50 UTC (rev
38107)
@@ -34,14 +34,19 @@
#define MHD_ITC_H 1
#include "mhd_options.h"
+/* Force socketpair on native W32 */
+#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(_MHD_ITC_SOCKETPAIR)
+#error _MHD_ITC_SOCKETPAIR is not defined on naitive W32 platform
+#endif /* _WIN32 && !__CYGWIN__ && !_MHD_ITC_SOCKETPAIR */
+
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
#include <fcntl.h>
-#ifdef HAVE_SYS_EVENTFD_H
+#if defined(_MHD_ITC_EVENTFD)
+#include <sys/eventfd.h>
-#include <sys/eventfd.h>
/* **************** Optimized eventfd PIPE implementation ********** */
/**
@@ -114,15 +119,8 @@
#define MHD_itc_nonblocking_(pip) (!0)
-#else
+#elif defined(_MHD_ITC_PIPE)
-/* Force don't use pipes on W32 */
-#if defined(_WIN32) && !defined(MHD_DONT_USE_PIPES)
-#define MHD_DONT_USE_PIPES 1
-#endif /* defined(_WIN32) && !defined(MHD_DONT_USE_PIPES) */
-
-#ifndef MHD_DONT_USE_PIPES
-
/* **************** STANDARD UNIX PIPE implementation ********** */
# ifdef HAVE_STRING_H
@@ -201,7 +199,7 @@
/* **************** END OF STANDARD UNIX PIPE implementation ********** */
-#else /* MHD_DONT_USE_PIPES */
+#elif defined(_MHD_ITC_SOCKETPAIR)
/* **************** PIPE EMULATION by socket pairs ********** */
@@ -266,8 +264,6 @@
/* **************** END OF PIPE EMULATION by socket pairs ********** */
-#endif /* MHD_DONT_USE_PIPES */
+#endif /* _MHD_ITC_SOCKETPAIR */
-#endif /* HAVE_SYS_EVENTFD_H */
-
#endif /* MHD_ITC_H */
Modified: libmicrohttpd/w32/common/MHD_config.h
===================================================================
--- libmicrohttpd/w32/common/MHD_config.h 2016-10-11 15:20:47 UTC (rev
38106)
+++ libmicrohttpd/w32/common/MHD_config.h 2016-10-11 15:20:50 UTC (rev
38107)
@@ -44,8 +44,8 @@
/* Provides IPv6 headers */
#define HAVE_INET6 1
-/* Define to use pair of sockets instead of pipes for signaling */
-#define MHD_DONT_USE_PIPES 1
+/* Define to use socketpair for inter-thread communication */
+#define _MHD_ITC_SOCKETPAIR 1
/* define to use W32 threads */
#define MHD_USE_W32_THREADS 1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r38107 - in libmicrohttpd: . src/microhttpd w32/common,
gnunet <=