aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2016-10-11 15:20:50 +0000
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2016-10-11 15:20:50 +0000
commitb6ae5bf9b70c867664daced6f24b6ba28ebc6c82 (patch)
treec00d1deea1e973ec182cf9e0233b6121cd57012b
parent992b827ada904941972fe455c795f7b60853c33e (diff)
downloadlibmicrohttpd-b6ae5bf9b70c867664daced6f24b6ba28ebc6c82.tar.gz
libmicrohttpd-b6ae5bf9b70c867664daced6f24b6ba28ebc6c82.zip
Add 'configure' parameter to control ITC type
-rw-r--r--configure.ac136
-rw-r--r--src/microhttpd/daemon.c2
-rw-r--r--src/microhttpd/mhd_itc.c11
-rw-r--r--src/microhttpd/mhd_itc.h24
-rw-r--r--w32/common/MHD_config.h4
5 files changed, 119 insertions, 58 deletions
diff --git a/configure.ac b/configure.ac
index 8600f18c..545c525b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,7 @@
20# Process this file with autoconf to produce a configure script. 20# Process this file with autoconf to produce a configure script.
21# 21#
22# 22#
23AC_PREREQ([2.60]) 23AC_PREREQ([2.64])
24LT_PREREQ([2.4.0]) 24LT_PREREQ([2.4.0])
25AC_INIT([GNU Libmicrohttpd],[0.9.51],[libmicrohttpd@gnu.org]) 25AC_INIT([GNU Libmicrohttpd],[0.9.51],[libmicrohttpd@gnu.org])
26AM_INIT_AUTOMAKE([silent-rules] [subdir-objects]) 26AM_INIT_AUTOMAKE([silent-rules] [subdir-objects])
@@ -562,7 +562,7 @@ AC_CHECK_HEADERS([sys/types.h sys/time.h sys/msg.h time.h sys/mman.h search.h sy
562 sys/socket.h sys/select.h netdb.h netinet/in.h netinet/ip.h netinet/tcp.h arpa/inet.h \ 562 sys/socket.h sys/select.h netdb.h netinet/in.h netinet/ip.h netinet/tcp.h arpa/inet.h \
563 endian.h machine/endian.h sys/endian.h sys/param.h sys/machine.h sys/byteorder.h machine/param.h sys/isa_defs.h \ 563 endian.h machine/endian.h sys/endian.h sys/param.h sys/machine.h sys/byteorder.h machine/param.h sys/isa_defs.h \
564 inttypes.h stddef.h unistd.h \ 564 inttypes.h stddef.h unistd.h \
565 sockLib.h inetLib.h net/if.h sys/eventfd.h], [], [], [AC_INCLUDES_DEFAULT]) 565 sockLib.h inetLib.h net/if.h], [], [], [AC_INCLUDES_DEFAULT])
566AM_CONDITIONAL([HAVE_TSEARCH], [test "x$ac_cv_header_search_h" = "xyes"]) 566AM_CONDITIONAL([HAVE_TSEARCH], [test "x$ac_cv_header_search_h" = "xyes"])
567 567
568# Check for generic functions 568# Check for generic functions
@@ -585,47 +585,112 @@ AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
585 ]) 585 ])
586 586
587 587
588# Check for pipe/socketpair signaling 588# Check for inter-thread signaling type
589AC_MSG_CHECKING([[whether to enable signaling by socketpair]]) 589AC_ARG_ENABLE([[itc]],
590 [AS_HELP_STRING([[--enable-itc=TYPE]], [use TYPE of inter-thread communication (pipe, socketpair, eventfd) [auto]])], [],
591 [[enable_itc='auto']]
592)
593
594AS_CASE([[$enable_itc]],
595 [[pipe]], [[:]],
596 [[socketpair]], [[:]],
597 [[eventfd]], [[:]],
598 [[auto]], [AS_VAR_IF([[os_is_windows]], [["yes"]], [[enable_itc='socketpair']])],
599 [[eventFD]], [[enable_itc='eventfd']],
600 [[socket]], [[enable_itc='socketpair']],
601 [[no]], [AC_MSG_ERROR([[inter-thread communication cannot be disabled]])],
602 [AC_MSG_ERROR([[unrecognized type "$enable_itc" of inter-thread communication specified by "--enable-itc=$enable_itc"]])]
603)
604# AS_UNSET([[use_itc]])
605
606AS_IF([[test "x$enable_itc" = "xeventfd" || test "x$enable_itc" = "xauto"]], [
607 AS_VAR_IF([[os_is_native_w32]], [["yes"]], [], [
608 AC_CHECK_HEADERS([[sys/eventfd.h]], [], [], [AC_INCLUDES_DEFAULT])
609 AS_VAR_IF([[ac_cv_header_sys_eventfd_h]], [["yes"]], [
610 AC_CACHE_CHECK([whether eventfd(2) is usable], [[mhd_cv_eventfd_usable]], [
611 AC_LINK_IFELSE([
612 AC_LANG_PROGRAM([[
613#include <sys/eventfd.h>
614 ]], [[int ef = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK)
615 ]])
616 ], [[mhd_cv_eventfd_usable='yes']], [[mhd_cv_eventfd_usable='no']])
617 ])
618 ])
619 ])
620 AS_VAR_IF([[mhd_cv_eventfd_usable]], [["yes"]], [
621 use_itc='eventfd'
622 enable_itc="$use_itc"
623 AC_DEFINE([[_MHD_ITC_EVENTFD]], [[1]], [Define to use eventFD for inter-thread communication])
624 ], [
625 AS_VAR_IF([[enable_itc]], [["eventfd"]], [AC_MSG_ERROR([[eventfd(2) is not usable, consider using other type of inter-thread communication]])])
626 ])
627])
590 628
591AC_ARG_ENABLE([[socketpair]], 629AS_IF([[test "x$enable_itc" = "xpipe" || test "x$enable_itc" = "xauto"]], [
592 [AS_HELP_STRING([[--enable-socketpair[=ARG]]], [disable internal singalling by pipes and use socket pair instead (yes, no, try) [no]])], , 630 AS_VAR_IF([[os_is_native_w32]], [["yes"]], [], [
593 [AS_IF([[test "x$os_is_windows" = "xyes"]], [enable_socketpair=yes], [enable_socketpair=no])] 631 AC_CACHE_CHECK([[whether pipe(3) is usable]], [[mhd_cv_pipe_usable]], [
594 ) 632 AC_LINK_IFELSE([
633 AC_LANG_PROGRAM([
634AC_INCLUDES_DEFAULT
635#ifdef HAVE_UNISTD_H
636#include <unistd.h>
637#endif
638 ], [[
639 int arr[2];
640 int res;
641 res = pipe(arr)
642 ]])
643 ], [[mhd_cv_pipe_usable='yes']], [[mhd_cv_pipe_usable='no']])
644 ])
645 ])
646 AS_VAR_IF([[mhd_cv_pipe_usable]], [["yes"]], [
647 use_itc='pipe'
648 enable_itc="$use_itc"
649 AC_DEFINE([[_MHD_ITC_PIPE]], [[1]], [Define to use pipe for inter-thread communication])
650 ], [
651 AS_VAR_IF([[enable_itc]], [["pipe"]], [AC_MSG_ERROR([[pipe(3) is not usable, consider using other type of inter-thread communication]])])
652 ])
653])
595 654
596AS_IF( 655AS_IF([[test "x$enable_itc" = "xsocketpair" || test "x$enable_itc" = "xauto"]], [
597 [[test "x$enable_socketpair" != "xno"]], 656 AS_VAR_IF([[os_is_native_w32]], [["yes"]], [[mhd_cv_socketpair_usable='yes']], [
598 [AS_IF([[test "x$os_is_windows" = "xyes"]], 657 AC_CACHE_CHECK([[whether socketpair(3) is usable]], [[mhd_cv_socketpair_usable]], [
599 [ AC_MSG_RESULT([[yes, forced on W32]]) ], 658 AC_LINK_IFELSE([
600 [ AC_LINK_IFELSE( 659 AC_LANG_PROGRAM([
601 [ AC_LANG_PROGRAM([[ 660AC_INCLUDES_DEFAULT
602#ifdef HAVE_SYS_TYPES_H 661#ifdef HAVE_SYS_TYPES_H
603#include <sys/types.h> 662#include <sys/types.h>
604#endif 663#endif
605#ifdef HAVE_SYS_SOCKET_H 664#ifdef HAVE_SYS_SOCKET_H
606#include <sys/socket.h> 665#include <sys/socket.h>
607#endif 666#endif
608 ]],[[ 667 ], [[
609 int sv[2]; 668 int arr[2];
610 if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) != 0) return 1 669 int res;
611 ]]) 670#if defined(AF_LOCAL)
612 ], 671 res = socketpair(AF_LOCAL, SOCK_STREAM, 0, arr);
613 [ AC_MSG_RESULT([[yes, socketpair in available]]) ], 672#elif defined(AF_UNIX)
614 [ AC_MSG_RESULT([[no, socketpair in not available]]) 673 res = socketpair(AF_UNIX, SOCK_STREAM, 0, arr);
615 AS_IF([[test "x$enable_socketpair" = "xyes"]], [ AC_MSG_ERROR([[socketpair signalling cannot be enabled.]]) ]) 674#else
616 ] 675#error AF_LOCAL and AF_UNIX are both undefined
617 ) 676 choke me now;
618 ] 677#endif
619 ) 678 if (res != 0) return 1
620 ], 679 ]])
621 [ 680 ], [[mhd_cv_socketpair_usable='yes']], [[mhd_cv_socketpair_usable='no']])
622 AC_MSG_RESULT([[no]]) 681 ])
623 AS_IF([[test "x$os_is_windows" = "xyes"]], [ AC_MSG_ERROR([[socketpair must be enabled on W32]]) ]) 682 ])
624 ] 683 AS_VAR_IF([[mhd_cv_socketpair_usable]], [["yes"]], [
625 ) 684 use_itc='socketpair'
626if test "x$enable_socketpair" = "xyes"; then 685 enable_itc="$use_itc"
627 AC_DEFINE([[MHD_DONT_USE_PIPES]], [[1]], [Define to use pair of sockets instead of pipes for signaling]) 686 AC_DEFINE([[_MHD_ITC_SOCKETPAIR]], [[1]], [Define to use socketpair for inter-thread communication])
628fi 687 ], [
688 AS_VAR_IF([[enable_itc]], [["socketpair"]], [AC_MSG_ERROR([[socketpair(3) is not usable, consider using other type of inter-thread communication]])])
689 ])
690])
691
692AS_IF([[test -z "$use_itc"]], [AC_MSG_ERROR([[cannot find useable type of inter-thread communication]])])
693
629 694
630AC_CHECK_FUNCS_ONCE([accept4 gmtime_r memmem snprintf]) 695AC_CHECK_FUNCS_ONCE([accept4 gmtime_r memmem snprintf])
631AC_CHECK_DECL([gmtime_s], 696AC_CHECK_DECL([gmtime_s],
@@ -1116,6 +1181,7 @@ AC_MSG_NOTICE([libmicrohttpd ${PACKAGE_VERSION} Configuration Summary:
1116 Operating System: ${host_os} 1181 Operating System: ${host_os}
1117 Threading lib: ${USE_THREADS} 1182 Threading lib: ${USE_THREADS}
1118 Use thread names: ${enable_thread_names} 1183 Use thread names: ${enable_thread_names}
1184 Inter-thread comm: ${use_itc}
1119 libcurl (testing): ${MSG_CURL} 1185 libcurl (testing): ${MSG_CURL}
1120 Target directory: ${prefix} 1186 Target directory: ${prefix}
1121 Messages: ${enable_messages} 1187 Messages: ${enable_messages}
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index ce1b5939..3f316368 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -5576,7 +5576,7 @@ MHD_is_feature_supported(enum MHD_FEATURE feature)
5576 return MHD_NO; 5576 return MHD_NO;
5577#endif 5577#endif
5578 case MHD_FEATURE_SOCKETPAIR: 5578 case MHD_FEATURE_SOCKETPAIR:
5579#ifdef MHD_DONT_USE_PIPES 5579#ifdef _MHD_ITC_SOCKETPAIR
5580 return MHD_YES; 5580 return MHD_YES;
5581#else 5581#else
5582 return MHD_NO; 5582 return MHD_NO;
diff --git a/src/microhttpd/mhd_itc.c b/src/microhttpd/mhd_itc.c
index 5d90144f..e6cbd875 100644
--- a/src/microhttpd/mhd_itc.c
+++ b/src/microhttpd/mhd_itc.c
@@ -33,7 +33,7 @@
33#include "internal.h" 33#include "internal.h"
34 34
35 35
36#ifdef HAVE_SYS_EVENTFD_H 36#ifdef _MHD_ITC_EVENTFD
37 37
38int 38int
39MHD_pipe_write_ (struct MHD_Pipe pip, 39MHD_pipe_write_ (struct MHD_Pipe pip,
@@ -49,9 +49,9 @@ MHD_pipe_write_ (struct MHD_Pipe pip,
49 return sz; 49 return sz;
50} 50}
51 51
52#else 52#endif /* _MHD_ITC_EVENTFD */
53 53
54#ifndef MHD_DONT_USE_PIPES 54#if defined(_MHD_ITC_PIPE)
55#if !defined(_WIN32) || defined(__CYGWIN__) 55#if !defined(_WIN32) || defined(__CYGWIN__)
56 56
57 57
@@ -83,6 +83,5 @@ MHD_itc_nonblocking_ (struct MHD_Pipe pip)
83 } 83 }
84 return !0; 84 return !0;
85} 85}
86#endif /* _WIN32 && ! __CYGWIN__ */ 86#endif /* !_WIN32 || __CYGWIN__ */
87#endif /* ! MHD_DONT_USE_PIPES */ 87#endif /* _MHD_ITC_EVENTFD || _MHD_ITC_PIPE */
88#endif /* ! HAVE_SYS_EVENTFD_H */
diff --git a/src/microhttpd/mhd_itc.h b/src/microhttpd/mhd_itc.h
index 163a4d5f..49909516 100644
--- a/src/microhttpd/mhd_itc.h
+++ b/src/microhttpd/mhd_itc.h
@@ -34,14 +34,19 @@
34#define MHD_ITC_H 1 34#define MHD_ITC_H 1
35#include "mhd_options.h" 35#include "mhd_options.h"
36 36
37/* Force socketpair on native W32 */
38#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(_MHD_ITC_SOCKETPAIR)
39#error _MHD_ITC_SOCKETPAIR is not defined on naitive W32 platform
40#endif /* _WIN32 && !__CYGWIN__ && !_MHD_ITC_SOCKETPAIR */
41
37#ifdef HAVE_UNISTD_H 42#ifdef HAVE_UNISTD_H
38#include <unistd.h> 43#include <unistd.h>
39#endif /* HAVE_UNISTD_H */ 44#endif /* HAVE_UNISTD_H */
40#include <fcntl.h> 45#include <fcntl.h>
41 46
42#ifdef HAVE_SYS_EVENTFD_H 47#if defined(_MHD_ITC_EVENTFD)
43
44#include <sys/eventfd.h> 48#include <sys/eventfd.h>
49
45/* **************** Optimized eventfd PIPE implementation ********** */ 50/* **************** Optimized eventfd PIPE implementation ********** */
46 51
47/** 52/**
@@ -114,14 +119,7 @@ MHD_pipe_write_ (struct MHD_Pipe pip,
114#define MHD_itc_nonblocking_(pip) (!0) 119#define MHD_itc_nonblocking_(pip) (!0)
115 120
116 121
117#else 122#elif defined(_MHD_ITC_PIPE)
118
119/* Force don't use pipes on W32 */
120#if defined(_WIN32) && !defined(MHD_DONT_USE_PIPES)
121#define MHD_DONT_USE_PIPES 1
122#endif /* defined(_WIN32) && !defined(MHD_DONT_USE_PIPES) */
123
124#ifndef MHD_DONT_USE_PIPES
125 123
126/* **************** STANDARD UNIX PIPE implementation ********** */ 124/* **************** STANDARD UNIX PIPE implementation ********** */
127 125
@@ -201,7 +199,7 @@ MHD_itc_nonblocking_ (struct MHD_Pipe fd);
201 199
202/* **************** END OF STANDARD UNIX PIPE implementation ********** */ 200/* **************** END OF STANDARD UNIX PIPE implementation ********** */
203 201
204#else /* MHD_DONT_USE_PIPES */ 202#elif defined(_MHD_ITC_SOCKETPAIR)
205 203
206/* **************** PIPE EMULATION by socket pairs ********** */ 204/* **************** PIPE EMULATION by socket pairs ********** */
207 205
@@ -266,8 +264,6 @@ struct MHD_Pipe
266 264
267/* **************** END OF PIPE EMULATION by socket pairs ********** */ 265/* **************** END OF PIPE EMULATION by socket pairs ********** */
268 266
269#endif /* MHD_DONT_USE_PIPES */ 267#endif /* _MHD_ITC_SOCKETPAIR */
270
271#endif /* HAVE_SYS_EVENTFD_H */
272 268
273#endif /* MHD_ITC_H */ 269#endif /* MHD_ITC_H */
diff --git a/w32/common/MHD_config.h b/w32/common/MHD_config.h
index 72b157ac..548f6a69 100644
--- a/w32/common/MHD_config.h
+++ b/w32/common/MHD_config.h
@@ -44,8 +44,8 @@
44/* Provides IPv6 headers */ 44/* Provides IPv6 headers */
45#define HAVE_INET6 1 45#define HAVE_INET6 1
46 46
47/* Define to use pair of sockets instead of pipes for signaling */ 47/* Define to use socketpair for inter-thread communication */
48#define MHD_DONT_USE_PIPES 1 48#define _MHD_ITC_SOCKETPAIR 1
49 49
50/* define to use W32 threads */ 50/* define to use W32 threads */
51#define MHD_USE_W32_THREADS 1 51#define MHD_USE_W32_THREADS 1