mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-25 04:09:31 +03:00
Check for epoll_create1() function, fix build for Android
This commit is contained in:
@@ -293,6 +293,18 @@ if test "$enable_epoll" != "no"; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$enable_epoll" = "xyes"; then
|
||||
AC_CACHE_CHECK([for epoll_create1()], [mhd_cv_have_epoll_create1], [
|
||||
AC_LINK_IFELSE([
|
||||
AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[
|
||||
int fd;
|
||||
fd = epoll_create1(EPOLL_CLOEXEC);]])],
|
||||
[mhd_cv_have_epoll_create1=yes],
|
||||
[mhd_cv_have_epoll_create1=no])])
|
||||
AS_IF([test "x$mhd_cv_have_epoll_create1" = "xyes"],[
|
||||
AC_DEFINE([[HAVE_EPOLL_CREATE1]], [[1]], [Define if you have epoll_create1 function.])])
|
||||
fi
|
||||
|
||||
if test "x$HAVE_POSIX_THREADS" = "xyes"; then
|
||||
# Check for pthread_setname_np()
|
||||
SAVE_LIBS="$LIBS"
|
||||
|
||||
@@ -3333,7 +3333,11 @@ setup_epoll_to_listen (struct MHD_Daemon *daemon)
|
||||
{
|
||||
struct epoll_event event;
|
||||
|
||||
#ifdef HAVE_EPOLL_CREATE1
|
||||
daemon->epoll_fd = epoll_create1 (EPOLL_CLOEXEC);
|
||||
#else /* !HAVE_EPOLL_CREATE1 */
|
||||
daemon->epoll_fd = epoll_create (MAX_EVENTS);
|
||||
#endif /* !HAVE_EPOLL_CREATE1 */
|
||||
if (-1 == daemon->epoll_fd)
|
||||
{
|
||||
#if HAVE_MESSAGES
|
||||
@@ -3343,6 +3347,20 @@ setup_epoll_to_listen (struct MHD_Daemon *daemon)
|
||||
#endif
|
||||
return MHD_NO;
|
||||
}
|
||||
#ifndef HAVE_EPOLL_CREATE1
|
||||
else
|
||||
{
|
||||
int fdflags = fcntl (daemon->epoll_fd, F_GETFD);
|
||||
if (0 > fdflags || 0 > fcntl (daemon->epoll_fd, F_SETFD, fdflags | FD_CLOEXEC))
|
||||
{
|
||||
#if HAVE_MESSAGES
|
||||
MHD_DLOG (daemon,
|
||||
"Failed to change flags on epoll fd: %s\n",
|
||||
MHD_socket_last_strerr_ ());
|
||||
#endif /* HAVE_MESSAGES */
|
||||
}
|
||||
}
|
||||
#endif /* !HAVE_EPOLL_CREATE1 */
|
||||
if (0 == EPOLL_CLOEXEC)
|
||||
make_nonblocking_noninheritable (daemon,
|
||||
daemon->epoll_fd);
|
||||
|
||||
Reference in New Issue
Block a user