diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-08-24 15:02:10 +0000 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-08-24 15:02:10 +0000 |
commit | 9826ad54e0de815ca9a2b071717dc8aed1ce1a5c (patch) | |
tree | 72da2ca91f3bd6ae8ed23d8614db888a3510cd16 | |
parent | dfbda8ae1ee98455a488de3a78ae4fd198e57cd4 (diff) |
Refactoring: do not define EPOLL_SUPPORT if epoll is disabled or not supported.
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | src/examples/benchmark.c | 2 | ||||
-rw-r--r-- | src/examples/benchmark_https.c | 2 | ||||
-rw-r--r-- | src/examples/demo.c | 2 | ||||
-rw-r--r-- | src/examples/demo_https.c | 2 | ||||
-rw-r--r-- | src/microhttpd/connection.c | 4 | ||||
-rw-r--r-- | src/microhttpd/connection.h | 2 | ||||
-rw-r--r-- | src/microhttpd/connection_https.c | 2 | ||||
-rw-r--r-- | src/microhttpd/daemon.c | 56 | ||||
-rw-r--r-- | src/microhttpd/internal.h | 8 | ||||
-rw-r--r-- | src/microhttpd/mhd_sockets.h | 2 | ||||
-rw-r--r-- | src/testcurl/https/test_https_get_parallel.c | 4 | ||||
-rw-r--r-- | src/testcurl/https/test_https_get_select.c | 2 |
13 files changed, 45 insertions, 46 deletions
diff --git a/configure.ac b/configure.ac index 0285bb4f..3c528754 100644 --- a/configure.ac +++ b/configure.ac @@ -529,10 +529,9 @@ AC_ARG_ENABLE([[epoll]], if test "$enable_epoll" != "no"; then AX_HAVE_EPOLL if test "${ax_cv_have_epoll}" = "yes"; then - AC_DEFINE([EPOLL_SUPPORT],[1],[define to 1 to enable epoll support]) + AC_DEFINE([[EPOLL_SUPPORT]],[[1]],[Define to 1 to enable epoll support]) enable_epoll='yes' else - AC_DEFINE([EPOLL_SUPPORT],[0],[define to 0 to disable epoll support]) if test "$enable_epoll" = "yes"; then AC_MSG_ERROR([[Support for epoll was explicitly requested but cannot be enabled on this platform.]]) fi diff --git a/src/examples/benchmark.c b/src/examples/benchmark.c index d287b2fe..bb103c98 100644 --- a/src/examples/benchmark.c +++ b/src/examples/benchmark.c @@ -135,7 +135,7 @@ main (int argc, char *const *argv) "close"); #endif d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_SUPPRESS_DATE_NO_CLOCK -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT | MHD_USE_EPOLL_LINUX_ONLY | MHD_USE_EPOLL_TURBO #endif , diff --git a/src/examples/benchmark_https.c b/src/examples/benchmark_https.c index 735a913e..5d7171be 100644 --- a/src/examples/benchmark_https.c +++ b/src/examples/benchmark_https.c @@ -181,7 +181,7 @@ main (int argc, char *const *argv) (void *) PAGE, MHD_RESPMEM_PERSISTENT); d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_SSL -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT | MHD_USE_EPOLL_LINUX_ONLY | MHD_USE_EPOLL_TURBO #endif , diff --git a/src/examples/demo.c b/src/examples/demo.c index 7b2064e2..eca2c069 100644 --- a/src/examples/demo.c +++ b/src/examples/demo.c @@ -884,7 +884,7 @@ main (int argc, char *const *argv) mark_as_html (internal_error_response); update_directory (); d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT | MHD_USE_EPOLL_LINUX_ONLY #endif , diff --git a/src/examples/demo_https.c b/src/examples/demo_https.c index ad986148..a80ce5cf 100644 --- a/src/examples/demo_https.c +++ b/src/examples/demo_https.c @@ -933,7 +933,7 @@ main (int argc, char *const *argv) mark_as_html (internal_error_response); update_directory (); d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG | MHD_USE_SSL -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT | MHD_USE_EPOLL_LINUX_ONLY #endif , diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index bf3f4d00..279aeaff 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c @@ -2894,7 +2894,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) return MHD_YES; } MHD_connection_update_event_loop_info (connection); -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT if (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) { switch (connection->event_loop_info) @@ -2945,7 +2945,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) } -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT /** * Perform epoll() processing, possibly moving the connection back into * the epoll() set if needed. diff --git a/src/microhttpd/connection.h b/src/microhttpd/connection.h index c2733fdf..4067af78 100644 --- a/src/microhttpd/connection.h +++ b/src/microhttpd/connection.h @@ -93,7 +93,7 @@ MHD_connection_close_ (struct MHD_Connection *connection, enum MHD_RequestTerminationCode termination_code); -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT /** * Perform epoll processing, possibly moving the connection back into * the epoll set if needed. diff --git a/src/microhttpd/connection_https.c b/src/microhttpd/connection_https.c index 94b6f3a6..a79d989a 100644 --- a/src/microhttpd/connection_https.c +++ b/src/microhttpd/connection_https.c @@ -159,7 +159,7 @@ MHD_tls_connection_handle_idle (struct MHD_Connection *connection) return MHD_YES; return MHD_connection_handle_idle (connection); } -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT return MHD_connection_epoll_update_ (connection); #else return MHD_YES; diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 7a8aa4ac..d813ca1b 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c @@ -415,7 +415,7 @@ recv_tls_adapter (struct MHD_Connection *connection, void *other, size_t i) (GNUTLS_E_INTERRUPTED == res) ) { MHD_socket_set_error_ (MHD_SCKT_EINTR_); -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT connection->epoll_state &= ~MHD_EPOLL_STATE_READ_READY; #endif return -1; @@ -456,7 +456,7 @@ send_tls_adapter (struct MHD_Connection *connection, (GNUTLS_E_INTERRUPTED == res) ) { MHD_socket_set_error_ (MHD_SCKT_EINTR_); -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY; #endif return -1; @@ -663,7 +663,7 @@ MHD_get_fdset2 (struct MHD_Daemon *daemon, || (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || (0 != (daemon->options & MHD_USE_POLL))) return MHD_NO; -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT if (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) { /* we're in epoll mode, use the epoll FD as a stand-in for @@ -1047,7 +1047,7 @@ recv_param_adapter (struct MHD_Connection *connection, other, (MHD_SCKT_SEND_SIZE_) i, MSG_NOSIGNAL); -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT if ( (0 > ret) && (MHD_SCKT_ERR_IS_EAGAIN_ (MHD_socket_get_error_ ())) ) { /* Got EAGAIN --- no longer read-ready */ @@ -1128,7 +1128,7 @@ send_param_adapter (struct MHD_Connection *connection, return ret; } err = MHD_socket_get_error_(); -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT if ( (0 > ret) && (MHD_SCKT_ERR_IS_EAGAIN_(err)) ) { /* EAGAIN --- no longer write-ready */ @@ -1148,7 +1148,7 @@ send_param_adapter (struct MHD_Connection *connection, #endif ret = (ssize_t) send (connection->socket_fd, other, (MHD_SCKT_SEND_SIZE_)i, MSG_NOSIGNAL); err = MHD_socket_get_error_(); -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT if ( (0 > ret) && (MHD_SCKT_ERR_IS_EAGAIN_(err)) ) { /* EAGAIN --- no longer write-ready */ @@ -1485,7 +1485,7 @@ internal_add_connection (struct MHD_Daemon *daemon, "failed to signal new connection via pipe"); #endif } -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT if (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) { if (0 == (daemon->options & MHD_USE_EPOLL_TURBO)) @@ -1610,7 +1610,7 @@ MHD_suspend_connection (struct MHD_Connection *connection) DLL_insert (daemon->suspended_connections_head, daemon->suspended_connections_tail, connection); -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT if (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) { if (0 != (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) @@ -1728,7 +1728,7 @@ resume_suspended_connections (struct MHD_Daemon *daemon) daemon->manual_timeout_tail, pos); } -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT if (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) { if (0 != (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) @@ -1970,7 +1970,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon) &pos->socket_context, MHD_CONNECTION_NOTIFY_CLOSED); MHD_ip_limit_del (daemon, pos->addr, pos->addr_len); -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT if (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) { if (0 != (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) @@ -2152,7 +2152,7 @@ MHD_run_from_select (struct MHD_Daemon *daemon, if (MHD_USE_SUSPEND_RESUME == (daemon->options & mask)) resume_suspended_connections (daemon); -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT if (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) { /* we're in epoll mode, the epoll FD stands for @@ -2583,7 +2583,7 @@ MHD_poll (struct MHD_Daemon *daemon, } -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT /** * How many events to we process at most per epoll() call? Trade-off @@ -2833,7 +2833,7 @@ MHD_run (struct MHD_Daemon *daemon) MHD_poll (daemon, MHD_NO); MHD_cleanup_connections (daemon); } -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT else if (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) { MHD_epoll (daemon, MHD_NO); @@ -2865,7 +2865,7 @@ MHD_select_thread (void *cls) { if (0 != (daemon->options & MHD_USE_POLL)) MHD_poll (daemon, MHD_YES); -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT else if (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) MHD_epoll (daemon, MHD_YES); #endif @@ -2972,7 +2972,7 @@ MHD_quiesce_daemon (struct MHD_Daemon *daemon) for (i = 0; i < daemon->worker_pool_size; i++) { daemon->worker_pool[i].socket_fd = MHD_INVALID_SOCKET; -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT if ( (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) && (-1 != daemon->worker_pool[i].epoll_fd) && (MHD_YES == daemon->worker_pool[i].listen_socket_in_epoll) ) @@ -2993,7 +2993,7 @@ MHD_quiesce_daemon (struct MHD_Daemon *daemon) } } daemon->socket_fd = MHD_INVALID_SOCKET; -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT if ( (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) && (-1 != daemon->epoll_fd) && (MHD_YES == daemon->listen_socket_in_epoll) ) @@ -3414,7 +3414,7 @@ parse_options_va (struct MHD_Daemon *daemon, } -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT /** * Setup epoll() FD for the daemon and initialize it to listen * on the listen FD. @@ -3549,7 +3549,7 @@ MHD_start_daemon_va (unsigned int flags, if (NULL == (daemon = malloc (sizeof (struct MHD_Daemon)))) return NULL; memset (daemon, 0, sizeof (struct MHD_Daemon)); -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT daemon->epoll_fd = -1; #endif /* try to open listen socket */ @@ -3999,7 +3999,7 @@ MHD_start_daemon_va (unsigned int flags, goto free_and_fail; } -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT if ( (0 != (flags & MHD_USE_EPOLL_LINUX_ONLY)) && (0 == daemon->worker_pool_size) && (0 == (daemon->options & MHD_USE_NO_LISTEN_SOCKET)) ) @@ -4172,7 +4172,7 @@ MHD_start_daemon_va (unsigned int flags, d->connection_limit = conns_per_thread; if (i < leftover_conns) ++d->connection_limit; -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT if ( (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) && (MHD_YES != setup_epoll_to_listen (d)) ) goto thread_failed; @@ -4242,7 +4242,7 @@ thread_failed: free_and_fail: /* clean up basic memory state in 'daemon' and return NULL to indicate failure */ -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT if (-1 != daemon->epoll_fd) close (daemon->epoll_fd); #endif @@ -4362,7 +4362,7 @@ close_all_connections (struct MHD_Daemon *daemon) } -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT /** * Shutdown epoll()-event loop by adding 'wpipe' to its event set. * @@ -4417,7 +4417,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) { daemon->worker_pool[i].shutdown = MHD_YES; daemon->worker_pool[i].socket_fd = MHD_INVALID_SOCKET; -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT if ( (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) && (-1 != daemon->worker_pool[i].epoll_fd) && (MHD_INVALID_SOCKET == fd) ) @@ -4439,7 +4439,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) (void) shutdown (fd, SHUT_RDWR); } #endif -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT if ( (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) && (-1 != daemon->epoll_fd) && (MHD_INVALID_SOCKET == fd) ) @@ -4469,7 +4469,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) MHD_PANIC ("Failed to join a thread\n"); close_all_connections (&daemon->worker_pool[i]); (void) MHD_mutex_destroy_ (&daemon->worker_pool[i].cleanup_connection_mutex); -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT if ( (-1 != daemon->worker_pool[i].epoll_fd) && (0 != MHD_socket_close_ (daemon->worker_pool[i].epoll_fd)) ) MHD_PANIC ("close failed\n"); @@ -4520,7 +4520,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) gnutls_certificate_free_credentials (daemon->x509_cred); } #endif -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT if ( (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) && (-1 != daemon->epoll_fd) && (0 != MHD_socket_close_ (daemon->epoll_fd)) ) @@ -4569,7 +4569,7 @@ MHD_get_daemon_info (struct MHD_Daemon *daemon, return NULL; /* no longer supported */ case MHD_DAEMON_INFO_LISTEN_FD: return (const union MHD_DaemonInfo *) &daemon->socket_fd; -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT case MHD_DAEMON_INFO_EPOLL_FD_LINUX_ONLY: return (const union MHD_DaemonInfo *) &daemon->epoll_fd; #endif @@ -4699,7 +4699,7 @@ MHD_is_feature_supported(enum MHD_FEATURE feature) return MHD_NO; #endif case MHD_FEATURE_EPOLL: -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT return MHD_YES; #else return MHD_NO; diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h index 40621e2d..863def56 100644 --- a/src/microhttpd/internal.h +++ b/src/microhttpd/internal.h @@ -512,7 +512,7 @@ typedef ssize_t struct MHD_Connection { -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT /** * Next pointer for the EDLL listing connections that are epoll-ready. */ @@ -757,7 +757,7 @@ struct MHD_Connection */ int in_idle; -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT /** * What is the state of this socket in relation to epoll? */ @@ -949,7 +949,7 @@ struct MHD_Daemon */ struct MHD_Connection *cleanup_tail; -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT /** * Head of EDLL of connections ready for processing (in epoll mode). */ @@ -1133,7 +1133,7 @@ struct MHD_Daemon */ int listening_address_reuse; -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT /** * File descriptor associated with our epoll loop. */ diff --git a/src/microhttpd/mhd_sockets.h b/src/microhttpd/mhd_sockets.h index 1d68fa44..c3ca1626 100644 --- a/src/microhttpd/mhd_sockets.h +++ b/src/microhttpd/mhd_sockets.h @@ -85,7 +85,7 @@ # ifdef HAVE_SYS_SELECT_H # include <sys/select.h> # endif -# if EPOLL_SUPPORT +# ifdef EPOLL_SUPPORT # include <sys/epoll.h> # endif # ifdef HAVE_NETINET_TCP_H diff --git a/src/testcurl/https/test_https_get_parallel.c b/src/testcurl/https/test_https_get_parallel.c index cf32a021..5b1b23f5 100644 --- a/src/testcurl/https/test_https_get_parallel.c +++ b/src/testcurl/https/test_https_get_parallel.c @@ -147,7 +147,7 @@ main (int argc, char *const *argv) if (curl_uses_nss_ssl() == 0) aes256_sha = "rsa_aes_256_sha"; -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT errorCount += test_wrap ("single threaded daemon, single client, epoll", &test_single_client, NULL, @@ -163,7 +163,7 @@ main (int argc, char *const *argv) aes256_sha, CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, MHD_OPTION_END); -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT errorCount += test_wrap ("single threaded daemon, parallel clients, epoll", &test_parallel_clients, NULL, diff --git a/src/testcurl/https/test_https_get_select.c b/src/testcurl/https/test_https_get_select.c index 487b475e..e3e7af93 100644 --- a/src/testcurl/https/test_https_get_select.c +++ b/src/testcurl/https/test_https_get_select.c @@ -223,7 +223,7 @@ main (int argc, char *const *argv) fprintf (stderr, "Error: %s\n", strerror (errno)); return -1; } -#if EPOLL_SUPPORT +#ifdef EPOLL_SUPPORT if (0 != (errorCount = testExternalGet (MHD_USE_EPOLL_LINUX_ONLY))) fprintf (stderr, "Fail: %d\n", errorCount); #endif |