commit 48d7bc547dbb1e8f16c90b7b6411e19fd3773129 parent a3ce7049bd27700a39eef6ffd03ea23078231098 Author: Evgeny Grin (Karlson2k) <k2k@narod.ru> Date: Fri, 22 Apr 2022 09:11:19 +0300 MHD_start_daemon: simplified logic for AUTO flags Avoid "duplicated branches" on some platforms Diffstat:
| M | src/microhttpd/daemon.c | | | 36 | ++++++++++-------------------------- |
1 file changed, 10 insertions(+), 26 deletions(-)
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -6453,35 +6453,19 @@ MHD_start_daemon_va (unsigned int flags, if (0 != (*pflags & MHD_USE_AUTO)) { +#if defined(EPOLL_SUPPORT) && defined(HAVE_POLL) if (0 != (*pflags & MHD_USE_THREAD_PER_CONNECTION)) - { - /* Thread per connection with internal polling thread. */ -#ifdef HAVE_POLL - *pflags |= MHD_USE_POLL; -#else /* ! HAVE_POLL */ - /* use select() - do not modify flags */ -#endif /* ! HAVE_POLL */ - } - else if (0 != (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) - { - /* Internal polling thread. */ -#if defined(EPOLL_SUPPORT) - *pflags |= MHD_USE_EPOLL; -#elif defined(HAVE_POLL) *pflags |= MHD_USE_POLL; -#else /* !HAVE_POLL && !EPOLL_SUPPORT */ - /* use select() - do not modify flags */ -#endif /* !HAVE_POLL && !EPOLL_SUPPORT */ - } else - { - /* Internal threads are not used - "external" polling mode. */ -#if defined(EPOLL_SUPPORT) - *pflags |= MHD_USE_EPOLL; -#else /* ! EPOLL_SUPPORT */ - /* use select() - do not modify flags */ -#endif /* ! EPOLL_SUPPORT */ - } + *pflags |= MHD_USE_EPOLL; /* Including "external select" mode */ +#elif defined(HAVE_POLL) + if (0 != (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) + *pflags |= MHD_USE_POLL; /* Including thread-per-connection */ +#elif defined(EPOLL_SUPPORT) +#warning 'epoll' enabled, while 'poll' not detected. Check configure. +#else + /* No choice: use select() for any mode - do not modify flags */ +#endif } if (NULL == (daemon = MHD_calloc_ (1, sizeof (struct MHD_Daemon))))