diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-10-06 13:51:11 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-10-10 11:54:31 +0300 |
commit | 3921f777c11a5d8d4d275519cca87319218b77d2 (patch) | |
tree | 90484ad60870ba4de23f12927348b832e4df3a84 | |
parent | 88d27af738c0c73cc885ec75d52a142c5087367e (diff) | |
download | libmicrohttpd-3921f777c11a5d8d4d275519cca87319218b77d2.tar.gz libmicrohttpd-3921f777c11a5d8d4d275519cca87319218b77d2.zip |
daemon: small refactoring for more compact code when poll() is not supported
-rw-r--r-- | src/microhttpd/daemon.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index eb210a36..6c8f3db6 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -4930,6 +4930,7 @@ MHD_poll_listen_socket (struct MHD_Daemon *daemon, | |||
4930 | 4930 | ||
4931 | #endif | 4931 | #endif |
4932 | 4932 | ||
4933 | #ifdef HAVE_POLL | ||
4933 | 4934 | ||
4934 | /** | 4935 | /** |
4935 | * Do poll()-based processing. | 4936 | * Do poll()-based processing. |
@@ -4942,7 +4943,6 @@ static enum MHD_Result | |||
4942 | MHD_poll (struct MHD_Daemon *daemon, | 4943 | MHD_poll (struct MHD_Daemon *daemon, |
4943 | int may_block) | 4944 | int may_block) |
4944 | { | 4945 | { |
4945 | #ifdef HAVE_POLL | ||
4946 | if (daemon->shutdown) | 4946 | if (daemon->shutdown) |
4947 | return MHD_NO; | 4947 | return MHD_NO; |
4948 | if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) | 4948 | if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) |
@@ -4950,14 +4950,12 @@ MHD_poll (struct MHD_Daemon *daemon, | |||
4950 | may_block ? -1 : 0); | 4950 | may_block ? -1 : 0); |
4951 | return MHD_poll_listen_socket (daemon, | 4951 | return MHD_poll_listen_socket (daemon, |
4952 | may_block); | 4952 | may_block); |
4953 | #else | ||
4954 | (void) daemon; | ||
4955 | (void) may_block; | ||
4956 | return MHD_NO; | ||
4957 | #endif | ||
4958 | } | 4953 | } |
4959 | 4954 | ||
4960 | 4955 | ||
4956 | #endif /* HAVE_POLL */ | ||
4957 | |||
4958 | |||
4961 | #ifdef EPOLL_SUPPORT | 4959 | #ifdef EPOLL_SUPPORT |
4962 | 4960 | ||
4963 | /** | 4961 | /** |
@@ -5642,14 +5640,17 @@ MHD_polling_thread (void *cls) | |||
5642 | #endif /* HAVE_PTHREAD_SIGMASK */ | 5640 | #endif /* HAVE_PTHREAD_SIGMASK */ |
5643 | while (! daemon->shutdown) | 5641 | while (! daemon->shutdown) |
5644 | { | 5642 | { |
5643 | #ifdef HAVE_POLL | ||
5645 | if (0 != (daemon->options & MHD_USE_POLL)) | 5644 | if (0 != (daemon->options & MHD_USE_POLL)) |
5646 | MHD_poll (daemon, MHD_YES); | 5645 | MHD_poll (daemon, MHD_YES); |
5646 | else | ||
5647 | #endif /* HAVE_POLL */ | ||
5647 | #ifdef EPOLL_SUPPORT | 5648 | #ifdef EPOLL_SUPPORT |
5648 | else if (0 != (daemon->options & MHD_USE_EPOLL)) | 5649 | if (0 != (daemon->options & MHD_USE_EPOLL)) |
5649 | MHD_epoll (daemon, -1); | 5650 | MHD_epoll (daemon, -1); |
5650 | #endif | ||
5651 | else | 5651 | else |
5652 | MHD_select (daemon, -1); | 5652 | #endif |
5653 | MHD_select (daemon, -1); | ||
5653 | MHD_cleanup_connections (daemon); | 5654 | MHD_cleanup_connections (daemon); |
5654 | } | 5655 | } |
5655 | 5656 | ||