Skip to content

Commit b7ae750

Browse files
authored
Simplify management of libmicrohttpd dependency (etr#223)
Removes compilation options to manage usage of select/poll/epoll. The code now makes use of MHD_USE_AUTO flag internally which automatically decides the best dispatch method.
1 parent a099841 commit b7ae750

File tree

5 files changed

+26
-115
lines changed

5 files changed

+26
-115
lines changed

AUTHORS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ bcsgh (Github: https://github.com/bcsgh)
4242
- Management of large uploads
4343
Walter Landry <wlandry@caltech.edu>
4444
Jagat <pellucide@yahoo.com>
45+
46+
- Simplification of microhttpd dependency management
47+
Christian Grothoff <grothoff@gnu.org>

ChangeLog

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1+
Thu Feb 25 20:27:12 2021 -0800
2+
Simplified dependency management for libmicrohttpd
3+
14
Sat Nov 21 07:20:00 2020 -0800
2-
Added support on build for CodeQL security checks.
3-
Moved builds to travis.com
4-
Added IWYU checks as part of build and cleaned-up accordingly.
5-
Introduced dual-stack support.
6-
Added OS specific tips, and cleaned up some compiler warnings.
7-
Updates to readme and documentation.
8-
Slight performances improvement by allowing to skip a copy in
9-
string_response constructor.
10-
Moved windows builds to AppVeyor.
11-
Made the library compatible with libmicrohttpd v0.9.71 and above.
5+
Added support on build for CodeQL security checks.
6+
Moved builds to travis.com
7+
Added IWYU checks as part of build and cleaned-up accordingly.
8+
Introduced dual-stack support.
9+
Added OS specific tips, and cleaned up some compiler warnings.
10+
Updates to readme and documentation.
11+
Slight performances improvement by allowing to skip a copy in
12+
string_response constructor.
13+
Moved windows builds to AppVeyor.
14+
Made the library compatible with libmicrohttpd v0.9.71 and above.
1215

1316
Sat Jun 6 10:21:05 2020 -0800
14-
Prevent use of regex in http_endpoint outside of registration which could
15-
allow DOS attacks.
17+
Prevent use of regex in http_endpoint outside of registration which could
18+
allow DOS attacks.
1619

1720
Sat May 16 07:20:00 2020 -0800
1821
General performance improvements (reduced use of regex, lazy-building of

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ libhttpserver can be used without any dependencies aside from libmicrohttpd.
7979

8080
The minimum versions required are:
8181
* g++ >= 5.5.0 or clang-3.6
82-
* libmicrohttpd >= 0.9.52
82+
* libmicrohttpd >= 0.9.53
8383
* [Optionally]: for TLS (HTTPS) support, you'll need [libgnutls](http://www.gnutls.org/).
8484
* [Optionally]: to compile the code-reference, you'll need [doxygen](http://www.doxygen.nl/).
8585

configure.ac

Lines changed: 5 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
AC_PREREQ(2.57)
2323
m4_define([libhttpserver_MAJOR_VERSION],[0])dnl
2424
m4_define([libhttpserver_MINOR_VERSION],[18])dnl
25-
m4_define([libhttpserver_REVISION],[1])dnl
25+
m4_define([libhttpserver_REVISION],[2])dnl
2626
m4_define([libhttpserver_PKG_VERSION],[libhttpserver_MAJOR_VERSION.libhttpserver_MINOR_VERSION.libhttpserver_REVISION])dnl
2727
m4_define([libhttpserver_LDF_VERSION],[libhttpserver_MAJOR_VERSION:libhttpserver_MINOR_VERSION:libhttpserver_REVISION])dnl
2828
AC_INIT([libhttpserver], libhttpserver_PKG_VERSION, [electrictwister2000@gmail.com])
@@ -97,17 +97,17 @@ AC_CHECK_HEADER([gnutls/gnutls.h],[have_gnutls="yes"],[AC_MSG_WARN("gnutls/gnutl
9797
if test x"$host" = x"$build"; then
9898
AC_CHECK_HEADER([microhttpd.h],
9999
AC_CHECK_LIB([microhttpd], [MHD_get_fdset2],
100-
[AC_MSG_CHECKING([for libmicrohttpd >= 0.9.52])
100+
[AC_MSG_CHECKING([for libmicrohttpd >= 0.9.53])
101101
AC_COMPILE_IFELSE(
102102
[AC_LANG_SOURCE([
103103
#include <microhttpd.h>
104-
#if (MHD_VERSION < 0x00095102)
105-
#error needs at least version 0.9.52
104+
#if (MHD_VERSION < 0x00095300)
105+
#error needs at least version 0.9.53
106106
#endif
107107
int main () { return 0; }
108108
])],
109109
[],
110-
[AC_MSG_ERROR("libmicrohttpd is too old - install libmicrohttpd >= 0.9.52")]
110+
[AC_MSG_ERROR("libmicrohttpd is too old - install libmicrohttpd >= 0.9.53")]
111111
)
112112
],
113113
[AC_MSG_ERROR(["libmicrohttpd not found"])]
@@ -157,83 +157,6 @@ if test x"$fastopen" = x"yes"; then
157157
fi
158158
fi
159159

160-
AC_ARG_ENABLE([[poll]],
161-
[AS_HELP_STRING([[--enable-poll[=ARG]]], [enable poll support (yes, no, auto) [auto]])],
162-
[enable_poll=${enableval}],
163-
[enable_poll='auto']
164-
)
165-
166-
if test "$enable_poll" != "no"; then
167-
if test "$os_is_native_w32" != "yes"; then
168-
AC_CHECK_HEADERS([poll.h],
169-
[
170-
AC_CHECK_FUNCS([poll], [have_poll='yes'], [have_poll='no'])
171-
], [], [AC_INCLUDES_DEFAULT])
172-
else
173-
AC_MSG_CHECKING([for WSAPoll()])
174-
AC_LINK_IFELSE([
175-
AC_LANG_PROGRAM([[
176-
#include <winsock2.h>
177-
]], [[
178-
WSAPOLLFD fda[2];
179-
WSAPoll(fda, 2, 0);]])],
180-
[
181-
have_poll='yes'
182-
AC_DEFINE([HAVE_POLL],[1])
183-
], [have_poll='no'])
184-
AC_MSG_RESULT([$have_poll])
185-
fi
186-
if test "$enable_poll" = "yes" && test "$have_poll" != "yes"; then
187-
AC_MSG_ERROR([[Support for poll was explicitly requested but cannot be enabled on this platform.]])
188-
fi
189-
enable_poll="$have_poll"
190-
fi
191-
192-
if test x"$enable_poll" = x"yes"; then
193-
AM_CXXFLAGS="$AM_CXXFLAGS -DENABLE_POLL"
194-
AM_CFLAGS="$AM_CXXFLAGS -DENABLE_POLL"
195-
fi
196-
197-
AC_ARG_ENABLE([[epoll]],
198-
[AS_HELP_STRING([[--enable-epoll[=ARG]]], [enable epoll support (yes, no, auto) [auto]])],
199-
[enable_epoll=${enableval}],
200-
[enable_epoll='auto']
201-
)
202-
203-
if test "$enable_epoll" != "no"; then
204-
AX_HAVE_EPOLL
205-
if test "${ax_cv_have_epoll}" = "yes"; then
206-
AC_DEFINE([[EPOLL_SUPPORT]],[[1]],[Define to 1 to enable epoll support])
207-
enable_epoll='yes'
208-
else
209-
if test "$enable_epoll" = "yes"; then
210-
AC_MSG_ERROR([[Support for epoll was explicitly requested but cannot be enabled on this platform.]])
211-
fi
212-
enable_epoll='no'
213-
fi
214-
fi
215-
216-
AM_CONDITIONAL([MHD_HAVE_EPOLL], [[test "x$enable_epoll" = xyes]])
217-
218-
if test "x$enable_epoll" = "xyes"; then
219-
AC_CACHE_CHECK([for epoll_create1()], [mhd_cv_have_epoll_create1], [
220-
AC_LINK_IFELSE([
221-
AC_LANG_PROGRAM([[
222-
#include <sys/epoll.h>
223-
]], [[
224-
int fd;
225-
fd = epoll_create1(EPOLL_CLOEXEC);]])],
226-
[mhd_cv_have_epoll_create1=yes],
227-
[mhd_cv_have_epoll_create1=no])])
228-
AS_IF([test "x$mhd_cv_have_epoll_create1" = "xyes"],[
229-
AC_DEFINE([[HAVE_EPOLL_CREATE1]], [[1]], [Define if you have epoll_create1 function.])])
230-
fi
231-
232-
if test x"$enable_epoll" = x"yes"; then
233-
AM_CXXFLAGS="$AM_CXXFLAGS -DENABLE_EPOLL"
234-
AM_CFLAGS="$AM_CXXFLAGS -DENABLE_EPOLL"
235-
fi
236-
237160
AC_MSG_CHECKING([whether to link statically])
238161
AC_ARG_ENABLE([static],
239162
[AS_HELP_STRING([--enable-static],
@@ -371,8 +294,6 @@ AC_MSG_NOTICE([Configuration Summary:
371294
Debug : ${debugit}
372295
TLS Enabled : ${have_gnutls}
373296
TCP_FASTOPEN : ${is_fastopen_supported}
374-
poll support : ${enable_poll=no}
375-
epoll support : ${enable_epoll=no}
376297
Static : ${static}
377298
Build examples : ${enable_examples}
378299
])

src/httpserver/http_utils.hpp

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,24 +86,8 @@ class http_utils
8686

8787
enum start_method_T
8888
{
89-
#if defined(__MINGW32__) || defined(__CYGWIN__)
90-
#ifdef ENABLE_POLL
91-
INTERNAL_SELECT = MHD_USE_SELECT_INTERNALLY | MHD_USE_POLL,
92-
#else
93-
INTERNAL_SELECT = MHD_USE_SELECT_INTERNALLY,
94-
#endif
95-
#else
96-
#ifdef ENABLE_EPOLL
97-
INTERNAL_SELECT = MHD_USE_SELECT_INTERNALLY | MHD_USE_EPOLL | MHD_USE_EPOLL_TURBO,
98-
#else
99-
INTERNAL_SELECT = MHD_USE_SELECT_INTERNALLY,
100-
#endif
101-
#endif
102-
#ifdef ENABLE_POLL
103-
THREAD_PER_CONNECTION = MHD_USE_THREAD_PER_CONNECTION | MHD_USE_POLL
104-
#else
105-
THREAD_PER_CONNECTION = MHD_USE_THREAD_PER_CONNECTION
106-
#endif
89+
INTERNAL_SELECT = MHD_USE_SELECT_INTERNALLY | MHD_USE_AUTO,
90+
THREAD_PER_CONNECTION = MHD_USE_THREAD_PER_CONNECTION | MHD_USE_AUTO
10791
};
10892

10993
enum policy_T

0 commit comments

Comments
 (0)