aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2023-11-01 15:47:01 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2023-11-01 15:47:01 +0300
commita225047802d49add197983055005f55559d7b47f (patch)
tree06f4ec68d223c55e0fd1cf7400ab1c47b35d15b3
parent75e2addd08c4e73873d8e3511accb25a01e7e4d8 (diff)
downloadlibmicrohttpd-a225047802d49add197983055005f55559d7b47f.tar.gz
libmicrohttpd-a225047802d49add197983055005f55559d7b47f.zip
Updated and used macros for polling modes
-rw-r--r--src/microhttpd/connection.c24
-rw-r--r--src/microhttpd/daemon.c99
-rw-r--r--src/microhttpd/internal.h24
-rw-r--r--src/microhttpd/response.c4
4 files changed, 76 insertions, 75 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index b09dbd9a..3f11b4eb 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -1305,11 +1305,11 @@ MHD_connection_finish_forward_ (struct MHD_Connection *connection)
1305 daemon->urh_tail, 1305 daemon->urh_tail,
1306 urh); 1306 urh);
1307#ifdef EPOLL_SUPPORT 1307#ifdef EPOLL_SUPPORT
1308 if ( (0 != (daemon->options & MHD_USE_EPOLL)) && 1308 if (MHD_D_IS_USING_EPOLL_ (daemon) &&
1309 (0 != epoll_ctl (daemon->epoll_upgrade_fd, 1309 (0 != epoll_ctl (daemon->epoll_upgrade_fd,
1310 EPOLL_CTL_DEL, 1310 EPOLL_CTL_DEL,
1311 connection->socket_fd, 1311 connection->socket_fd,
1312 NULL)) ) 1312 NULL)) )
1313 { 1313 {
1314 MHD_PANIC (_ ("Failed to remove FD from epoll set.\n")); 1314 MHD_PANIC (_ ("Failed to remove FD from epoll set.\n"));
1315 } 1315 }
@@ -1324,11 +1324,11 @@ MHD_connection_finish_forward_ (struct MHD_Connection *connection)
1324 if (MHD_INVALID_SOCKET != urh->mhd.socket) 1324 if (MHD_INVALID_SOCKET != urh->mhd.socket)
1325 { 1325 {
1326#ifdef EPOLL_SUPPORT 1326#ifdef EPOLL_SUPPORT
1327 if ( (0 != (daemon->options & MHD_USE_EPOLL)) && 1327 if (MHD_D_IS_USING_EPOLL_ (daemon) &&
1328 (0 != epoll_ctl (daemon->epoll_upgrade_fd, 1328 (0 != epoll_ctl (daemon->epoll_upgrade_fd,
1329 EPOLL_CTL_DEL, 1329 EPOLL_CTL_DEL,
1330 urh->mhd.socket, 1330 urh->mhd.socket,
1331 NULL)) ) 1331 NULL)) )
1332 { 1332 {
1333 MHD_PANIC (_ ("Failed to remove FD from epoll set.\n")); 1333 MHD_PANIC (_ ("Failed to remove FD from epoll set.\n"));
1334 } 1334 }
@@ -7509,7 +7509,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
7509 ret = MHD_YES; 7509 ret = MHD_YES;
7510#ifdef EPOLL_SUPPORT 7510#ifdef EPOLL_SUPPORT
7511 if ( (! connection->suspended) && 7511 if ( (! connection->suspended) &&
7512 (0 != (daemon->options & MHD_USE_EPOLL)) ) 7512 MHD_D_IS_USING_EPOLL_ (daemon) )
7513 { 7513 {
7514 ret = MHD_connection_epoll_update_ (connection); 7514 ret = MHD_connection_epoll_update_ (connection);
7515 } 7515 }
@@ -7533,7 +7533,7 @@ MHD_connection_epoll_update_ (struct MHD_Connection *connection)
7533{ 7533{
7534 struct MHD_Daemon *const daemon = connection->daemon; 7534 struct MHD_Daemon *const daemon = connection->daemon;
7535 7535
7536 mhd_assert (0 != (daemon->options & MHD_USE_EPOLL)); 7536 mhd_assert (MHD_D_IS_USING_EPOLL_ (daemon));
7537 7537
7538 if ((0 != (MHD_EVENT_LOOP_INFO_PROCESS & connection->event_loop_info)) && 7538 if ((0 != (MHD_EVENT_LOOP_INFO_PROCESS & connection->event_loop_info)) &&
7539 (0 == (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL))) 7539 (0 == (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)))
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 2c3dbe1a..ae334226 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -1107,7 +1107,7 @@ MHD_get_fdset2 (struct MHD_Daemon *daemon,
1107 (NULL == read_fd_set) || 1107 (NULL == read_fd_set) ||
1108 (NULL == write_fd_set) || 1108 (NULL == write_fd_set) ||
1109 (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || 1109 (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) ||
1110 (0 != (daemon->options & MHD_USE_POLL))) 1110 MHD_D_IS_USING_POLL_ (daemon))
1111 return MHD_NO; 1111 return MHD_NO;
1112 1112
1113 if (NULL == except_fd_set) 1113 if (NULL == except_fd_set)
@@ -1122,7 +1122,7 @@ MHD_get_fdset2 (struct MHD_Daemon *daemon,
1122 } 1122 }
1123 1123
1124#ifdef EPOLL_SUPPORT 1124#ifdef EPOLL_SUPPORT
1125 if (0 != (daemon->options & MHD_USE_EPOLL)) 1125 if (MHD_D_IS_USING_EPOLL_ (daemon))
1126 { 1126 {
1127 if (daemon->shutdown) 1127 if (daemon->shutdown)
1128 return MHD_NO; 1128 return MHD_NO;
@@ -1680,7 +1680,7 @@ thread_main_connection_upgrade (struct MHD_Connection *con)
1680 until the application tells us that it is done 1680 until the application tells us that it is done
1681 with the socket; */ 1681 with the socket; */
1682 if ( (0 != (daemon->options & MHD_USE_TLS)) && 1682 if ( (0 != (daemon->options & MHD_USE_TLS)) &&
1683 (0 == (daemon->options & MHD_USE_POLL))) 1683 MHD_D_IS_USING_SELECT_ (daemon))
1684 { 1684 {
1685 while ( (0 != urh->in_buffer_size) || 1685 while ( (0 != urh->in_buffer_size) ||
1686 (0 != urh->out_buffer_size) || 1686 (0 != urh->out_buffer_size) ||
@@ -1896,7 +1896,7 @@ thread_main_handle_connection (void *data)
1896#endif 1896#endif
1897#undef EXTRA_SLOTS 1897#undef EXTRA_SLOTS
1898#ifdef HAVE_POLL 1898#ifdef HAVE_POLL
1899 const bool use_poll = (0 != (daemon->options & MHD_USE_POLL)); 1899 const bool use_poll = MHD_D_IS_USING_POLL_ (daemon);
1900#else /* ! HAVE_POLL */ 1900#else /* ! HAVE_POLL */
1901 const bool use_poll = 0; 1901 const bool use_poll = 0;
1902#endif /* ! HAVE_POLL */ 1902#endif /* ! HAVE_POLL */
@@ -2813,7 +2813,7 @@ new_connection_process_ (struct MHD_Daemon *daemon,
2813#ifdef MHD_USE_THREADS 2813#ifdef MHD_USE_THREADS
2814 if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) 2814 if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
2815 { 2815 {
2816 mhd_assert (0 == (daemon->options & MHD_USE_EPOLL)); 2816 mhd_assert (! MHD_D_IS_USING_EPOLL_ (daemon));
2817 if (! MHD_create_named_thread_ (&connection->tid, 2817 if (! MHD_create_named_thread_ (&connection->tid,
2818 "MHD-connection", 2818 "MHD-connection",
2819 daemon->thread_stack_size, 2819 daemon->thread_stack_size,
@@ -2847,7 +2847,7 @@ new_connection_process_ (struct MHD_Daemon *daemon,
2847 connection->tid = daemon->tid; 2847 connection->tid = daemon->tid;
2848#endif /* MHD_USE_THREADS */ 2848#endif /* MHD_USE_THREADS */
2849#ifdef EPOLL_SUPPORT 2849#ifdef EPOLL_SUPPORT
2850 if (0 != (daemon->options & MHD_USE_EPOLL)) 2850 if (MHD_D_IS_USING_EPOLL_ (daemon))
2851 { 2851 {
2852 if (0 == (daemon->options & MHD_USE_TURBO)) 2852 if (0 == (daemon->options & MHD_USE_TURBO))
2853 { 2853 {
@@ -2979,8 +2979,8 @@ internal_add_connection (struct MHD_Daemon *daemon,
2979 mhd_assert ((NULL == daemon->worker_pool)); 2979 mhd_assert ((NULL == daemon->worker_pool));
2980#endif 2980#endif
2981 2981
2982 if ( (0 == (daemon->options & (MHD_USE_POLL | MHD_USE_EPOLL))) && 2982 if (MHD_D_IS_USING_SELECT_ (daemon) &&
2983 (! MHD_SCKT_FD_FITS_FDSET_ (client_socket, NULL)) ) 2983 (! MHD_SCKT_FD_FITS_FDSET_ (client_socket, NULL)) )
2984 { 2984 {
2985#ifdef HAVE_MESSAGES 2985#ifdef HAVE_MESSAGES
2986 MHD_DLOG (daemon, 2986 MHD_DLOG (daemon,
@@ -2996,8 +2996,8 @@ internal_add_connection (struct MHD_Daemon *daemon,
2996 return MHD_NO; 2996 return MHD_NO;
2997 } 2997 }
2998 2998
2999 if ( (0 != (daemon->options & MHD_USE_EPOLL)) && 2999 if (MHD_D_IS_USING_EPOLL_ (daemon) &&
3000 (! non_blck) ) 3000 (! non_blck) )
3001 { 3001 {
3002#ifdef HAVE_MESSAGES 3002#ifdef HAVE_MESSAGES
3003 MHD_DLOG (daemon, 3003 MHD_DLOG (daemon,
@@ -3142,7 +3142,7 @@ internal_suspend_connection_ (struct MHD_Connection *connection)
3142 connection); 3142 connection);
3143 connection->suspended = true; 3143 connection->suspended = true;
3144#ifdef EPOLL_SUPPORT 3144#ifdef EPOLL_SUPPORT
3145 if (0 != (daemon->options & MHD_USE_EPOLL)) 3145 if (MHD_D_IS_USING_EPOLL_ (daemon))
3146 { 3146 {
3147 if (0 != (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) 3147 if (0 != (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL))
3148 { 3148 {
@@ -3392,7 +3392,7 @@ resume_suspended_connections (struct MHD_Daemon *daemon)
3392 pos); 3392 pos);
3393 } 3393 }
3394#ifdef EPOLL_SUPPORT 3394#ifdef EPOLL_SUPPORT
3395 if (0 != (daemon->options & MHD_USE_EPOLL)) 3395 if (MHD_D_IS_USING_EPOLL_ (daemon))
3396 { 3396 {
3397 if (0 != (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) 3397 if (0 != (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL))
3398 MHD_PANIC ("Resumed connection was already in EREADY set.\n"); 3398 MHD_PANIC ("Resumed connection was already in EREADY set.\n");
@@ -3932,7 +3932,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
3932 pos->addr, 3932 pos->addr,
3933 pos->addr_len); 3933 pos->addr_len);
3934#ifdef EPOLL_SUPPORT 3934#ifdef EPOLL_SUPPORT
3935 if (0 != (daemon->options & MHD_USE_EPOLL)) 3935 if (MHD_D_IS_USING_EPOLL_ (daemon))
3936 { 3936 {
3937 if (0 != (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) 3937 if (0 != (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL))
3938 { 3938 {
@@ -4101,12 +4101,12 @@ MHD_get_timeout64 (struct MHD_Daemon *daemon,
4101 return MHD_YES; 4101 return MHD_YES;
4102 } 4102 }
4103#ifdef EPOLL_SUPPORT 4103#ifdef EPOLL_SUPPORT
4104 if ( (0 != (daemon->options & MHD_USE_EPOLL)) && 4104 if (MHD_D_IS_USING_EPOLL_ (daemon) &&
4105 ((NULL != daemon->eready_head) 4105 ((NULL != daemon->eready_head)
4106#if defined(UPGRADE_SUPPORT) && defined(HTTPS_SUPPORT) 4106#if defined(UPGRADE_SUPPORT) && defined(HTTPS_SUPPORT)
4107 || (NULL != daemon->eready_urh_head) 4107 || (NULL != daemon->eready_urh_head)
4108#endif /* UPGRADE_SUPPORT && HTTPS_SUPPORT */ 4108#endif /* UPGRADE_SUPPORT && HTTPS_SUPPORT */
4109 ) ) 4109 ) )
4110 { 4110 {
4111 /* Some connection(s) already have some data pending. */ 4111 /* Some connection(s) already have some data pending. */
4112 *timeout64 = 0; 4112 *timeout64 = 0;
@@ -4449,8 +4449,8 @@ MHD_run_from_select (struct MHD_Daemon *daemon,
4449 const fd_set *except_fd_set) 4449 const fd_set *except_fd_set)
4450{ 4450{
4451 fd_set es; 4451 fd_set es;
4452 if (0 != (daemon->options 4452 if (MHD_D_IS_USING_POLL_ (daemon) ||
4453 & (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_POLL)) ) 4453 (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)))
4454 return MHD_NO; 4454 return MHD_NO;
4455 if ((NULL == read_fd_set) || (NULL == write_fd_set)) 4455 if ((NULL == read_fd_set) || (NULL == write_fd_set))
4456 return MHD_NO; 4456 return MHD_NO;
@@ -4464,7 +4464,7 @@ MHD_run_from_select (struct MHD_Daemon *daemon,
4464 FD_ZERO (&es); 4464 FD_ZERO (&es);
4465 except_fd_set = &es; 4465 except_fd_set = &es;
4466 } 4466 }
4467 if (0 != (daemon->options & MHD_USE_EPOLL)) 4467 if (MHD_D_IS_USING_EPOLL_ (daemon))
4468 { 4468 {
4469#ifdef EPOLL_SUPPORT 4469#ifdef EPOLL_SUPPORT
4470 enum MHD_Result ret = MHD_epoll (daemon, 4470 enum MHD_Result ret = MHD_epoll (daemon,
@@ -5606,7 +5606,7 @@ MHD_run_wait (struct MHD_Daemon *daemon,
5606 if (0 > millisec) 5606 if (0 > millisec)
5607 millisec = -1; 5607 millisec = -1;
5608#ifdef HAVE_POLL 5608#ifdef HAVE_POLL
5609 if (0 != (daemon->options & MHD_USE_POLL)) 5609 if (MHD_D_IS_USING_POLL_ (daemon))
5610 { 5610 {
5611 res = MHD_poll_all (daemon, millisec); 5611 res = MHD_poll_all (daemon, millisec);
5612 MHD_cleanup_connections (daemon); 5612 MHD_cleanup_connections (daemon);
@@ -5614,7 +5614,7 @@ MHD_run_wait (struct MHD_Daemon *daemon,
5614 else 5614 else
5615#endif /* HAVE_POLL */ 5615#endif /* HAVE_POLL */
5616#ifdef EPOLL_SUPPORT 5616#ifdef EPOLL_SUPPORT
5617 if (0 != (daemon->options & MHD_USE_EPOLL)) 5617 if (MHD_D_IS_USING_EPOLL_ (daemon))
5618 { 5618 {
5619 res = MHD_epoll (daemon, millisec); 5619 res = MHD_epoll (daemon, millisec);
5620 MHD_cleanup_connections (daemon); 5620 MHD_cleanup_connections (daemon);
@@ -5720,12 +5720,12 @@ MHD_polling_thread (void *cls)
5720 while (! daemon->shutdown) 5720 while (! daemon->shutdown)
5721 { 5721 {
5722#ifdef HAVE_POLL 5722#ifdef HAVE_POLL
5723 if (0 != (daemon->options & MHD_USE_POLL)) 5723 if (MHD_D_IS_USING_POLL_ (daemon))
5724 MHD_poll (daemon, MHD_YES); 5724 MHD_poll (daemon, MHD_YES);
5725 else 5725 else
5726#endif /* HAVE_POLL */ 5726#endif /* HAVE_POLL */
5727#ifdef EPOLL_SUPPORT 5727#ifdef EPOLL_SUPPORT
5728 if (0 != (daemon->options & MHD_USE_EPOLL)) 5728 if (MHD_D_IS_USING_EPOLL_ (daemon))
5729 MHD_epoll (daemon, -1); 5729 MHD_epoll (daemon, -1);
5730 else 5730 else
5731#endif 5731#endif
@@ -5876,9 +5876,9 @@ MHD_quiesce_daemon (struct MHD_Daemon *daemon)
5876 { 5876 {
5877 daemon->worker_pool[i].was_quiesced = true; 5877 daemon->worker_pool[i].was_quiesced = true;
5878#ifdef EPOLL_SUPPORT 5878#ifdef EPOLL_SUPPORT
5879 if ( (0 != (daemon->options & MHD_USE_EPOLL)) && 5879 if (MHD_D_IS_USING_EPOLL_ (daemon) &&
5880 (-1 != daemon->worker_pool[i].epoll_fd) && 5880 (-1 != daemon->worker_pool[i].epoll_fd) &&
5881 (daemon->worker_pool[i].listen_socket_in_epoll) ) 5881 (daemon->worker_pool[i].listen_socket_in_epoll) )
5882 { 5882 {
5883 if (0 != epoll_ctl (daemon->worker_pool[i].epoll_fd, 5883 if (0 != epoll_ctl (daemon->worker_pool[i].epoll_fd,
5884 EPOLL_CTL_DEL, 5884 EPOLL_CTL_DEL,
@@ -5899,9 +5899,9 @@ MHD_quiesce_daemon (struct MHD_Daemon *daemon)
5899#endif 5899#endif
5900 daemon->was_quiesced = true; 5900 daemon->was_quiesced = true;
5901#ifdef EPOLL_SUPPORT 5901#ifdef EPOLL_SUPPORT
5902 if ( (0 != (daemon->options & MHD_USE_EPOLL)) && 5902 if (MHD_D_IS_USING_EPOLL_ (daemon) &&
5903 (-1 != daemon->epoll_fd) && 5903 (-1 != daemon->epoll_fd) &&
5904 (daemon->listen_socket_in_epoll) ) 5904 (daemon->listen_socket_in_epoll) )
5905 { 5905 {
5906 if ( (0 != epoll_ctl (daemon->epoll_fd, 5906 if ( (0 != epoll_ctl (daemon->epoll_fd,
5907 EPOLL_CTL_DEL, 5907 EPOLL_CTL_DEL,
@@ -7007,7 +7007,7 @@ setup_epoll_to_listen (struct MHD_Daemon *daemon)
7007 struct epoll_event event; 7007 struct epoll_event event;
7008 MHD_socket ls; 7008 MHD_socket ls;
7009 7009
7010 mhd_assert (0 != (daemon->options & MHD_USE_EPOLL)); 7010 mhd_assert (MHD_D_IS_USING_EPOLL_ (daemon));
7011 mhd_assert (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION)); 7011 mhd_assert (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION));
7012 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \ 7012 mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
7013 (MHD_INVALID_SOCKET != (ls = daemon->listen_fd)) || \ 7013 (MHD_INVALID_SOCKET != (ls = daemon->listen_fd)) || \
@@ -7170,7 +7170,8 @@ MHD_start_daemon_va (unsigned int flags,
7170 if (0 != (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) 7170 if (0 != (*pflags & MHD_USE_INTERNAL_POLLING_THREAD))
7171 *pflags |= MHD_USE_POLL; /* Including thread-per-connection */ 7171 *pflags |= MHD_USE_POLL; /* Including thread-per-connection */
7172#elif defined(EPOLL_SUPPORT) 7172#elif defined(EPOLL_SUPPORT)
7173#warning 'epoll' enabled, while 'poll' not detected. Check configure. 7173 if (0 == (*pflags & MHD_USE_THREAD_PER_CONNECTION))
7174 *pflags |= MHD_USE_EPOLL; /* Including "external select" mode */
7174#else 7175#else
7175 /* No choice: use select() for any mode - do not modify flags */ 7176 /* No choice: use select() for any mode - do not modify flags */
7176#endif 7177#endif
@@ -7328,9 +7329,9 @@ MHD_start_daemon_va (unsigned int flags,
7328 free (daemon); 7329 free (daemon);
7329 return NULL; 7330 return NULL;
7330 } 7331 }
7331 if ( (0 == (*pflags & (MHD_USE_POLL | MHD_USE_EPOLL))) && 7332 if (MHD_D_IS_USING_SELECT_ (daemon) &&
7332 (! MHD_SCKT_FD_FITS_FDSET_ (MHD_itc_r_fd_ (daemon->itc), 7333 (! MHD_SCKT_FD_FITS_FDSET_ (MHD_itc_r_fd_ (daemon->itc),
7333 NULL)) ) 7334 NULL)) )
7334 { 7335 {
7335#ifdef HAVE_MESSAGES 7336#ifdef HAVE_MESSAGES
7336 MHD_DLOG (daemon, 7337 MHD_DLOG (daemon,
@@ -7774,7 +7775,7 @@ MHD_start_daemon_va (unsigned int flags,
7774 _ ("Failed to set nonblocking mode on listening socket: %s\n"), 7775 _ ("Failed to set nonblocking mode on listening socket: %s\n"),
7775 MHD_socket_last_strerr_ ()); 7776 MHD_socket_last_strerr_ ());
7776#endif 7777#endif
7777 if (0 != (*pflags & MHD_USE_EPOLL) 7778 if (MHD_D_IS_USING_EPOLL_ (daemon)
7778#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 7779#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
7779 || (daemon->worker_pool_size > 0) 7780 || (daemon->worker_pool_size > 0)
7780#endif 7781#endif
@@ -7792,7 +7793,7 @@ MHD_start_daemon_va (unsigned int flags,
7792 daemon->listen_nonblk = true; 7793 daemon->listen_nonblk = true;
7793 if ( (! MHD_SCKT_FD_FITS_FDSET_ (listen_fd, 7794 if ( (! MHD_SCKT_FD_FITS_FDSET_ (listen_fd,
7794 NULL)) && 7795 NULL)) &&
7795 (0 == (*pflags & (MHD_USE_POLL | MHD_USE_EPOLL)) ) ) 7796 MHD_D_IS_USING_SELECT_ (daemon) )
7796 { 7797 {
7797#ifdef HAVE_MESSAGES 7798#ifdef HAVE_MESSAGES
7798 MHD_DLOG (daemon, 7799 MHD_DLOG (daemon,
@@ -7809,11 +7810,11 @@ MHD_start_daemon_va (unsigned int flags,
7809 daemon->listen_nonblk = false; /* Actually listen socket does not exist */ 7810 daemon->listen_nonblk = false; /* Actually listen socket does not exist */
7810 7811
7811#ifdef EPOLL_SUPPORT 7812#ifdef EPOLL_SUPPORT
7812 if ( (0 != (*pflags & MHD_USE_EPOLL)) 7813 if (MHD_D_IS_USING_EPOLL_ (daemon)
7813#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS) 7814#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
7814 && (0 == daemon->worker_pool_size) 7815 && (0 == daemon->worker_pool_size)
7815#endif 7816#endif
7816 ) 7817 )
7817 { 7818 {
7818 if (0 != (*pflags & MHD_USE_THREAD_PER_CONNECTION)) 7819 if (0 != (*pflags & MHD_USE_THREAD_PER_CONNECTION))
7819 { 7820 {
@@ -7992,9 +7993,9 @@ MHD_start_daemon_va (unsigned int flags,
7992 MHD_mutex_destroy_chk_ (&d->cleanup_connection_mutex); 7993 MHD_mutex_destroy_chk_ (&d->cleanup_connection_mutex);
7993 goto thread_failed; 7994 goto thread_failed;
7994 } 7995 }
7995 if ( (0 == (*pflags & (MHD_USE_POLL | MHD_USE_EPOLL))) && 7996 if (MHD_D_IS_USING_SELECT_ (d) &&
7996 (! MHD_SCKT_FD_FITS_FDSET_ (MHD_itc_r_fd_ (d->itc), 7997 (! MHD_SCKT_FD_FITS_FDSET_ (MHD_itc_r_fd_ (d->itc),
7997 NULL)) ) 7998 NULL)) )
7998 { 7999 {
7999#ifdef HAVE_MESSAGES 8000#ifdef HAVE_MESSAGES
8000 MHD_DLOG (daemon, 8001 MHD_DLOG (daemon,
@@ -8024,8 +8025,8 @@ MHD_start_daemon_va (unsigned int flags,
8024 if (i < leftover_conns) 8025 if (i < leftover_conns)
8025 ++d->connection_limit; 8026 ++d->connection_limit;
8026#ifdef EPOLL_SUPPORT 8027#ifdef EPOLL_SUPPORT
8027 if ( (0 != (*pflags & MHD_USE_EPOLL)) && 8028 if (MHD_D_IS_USING_EPOLL_ (d) &&
8028 (MHD_NO == setup_epoll_to_listen (d)) ) 8029 (MHD_NO == setup_epoll_to_listen (d)) )
8029 { 8030 {
8030 if (MHD_ITC_IS_VALID_ (d->itc)) 8031 if (MHD_ITC_IS_VALID_ (d->itc))
8031 MHD_itc_destroy_chk_ (d->itc); 8032 MHD_itc_destroy_chk_ (d->itc);
@@ -8527,12 +8528,12 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
8527 MHD_itc_destroy_chk_ (daemon->itc); 8528 MHD_itc_destroy_chk_ (daemon->itc);
8528 8529
8529#ifdef EPOLL_SUPPORT 8530#ifdef EPOLL_SUPPORT
8530 if ( (0 != (daemon->options & MHD_USE_EPOLL)) && 8531 if (MHD_D_IS_USING_EPOLL_ (daemon) &&
8531 (-1 != daemon->epoll_fd) ) 8532 (-1 != daemon->epoll_fd) )
8532 MHD_socket_close_chk_ (daemon->epoll_fd); 8533 MHD_socket_close_chk_ (daemon->epoll_fd);
8533#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) 8534#if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT)
8534 if ( (0 != (daemon->options & MHD_USE_EPOLL)) && 8535 if (MHD_D_IS_USING_EPOLL_ (daemon) &&
8535 (-1 != daemon->epoll_upgrade_fd) ) 8536 (-1 != daemon->epoll_upgrade_fd) )
8536 MHD_socket_close_chk_ (daemon->epoll_upgrade_fd); 8537 MHD_socket_close_chk_ (daemon->epoll_upgrade_fd);
8537#endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ 8538#endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */
8538#endif /* EPOLL_SUPPORT */ 8539#endif /* EPOLL_SUPPORT */
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index adcc43da..3ccc7347 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -153,55 +153,55 @@
153/** 153/**
154 * Checks whether the @a d daemon is using select() 154 * Checks whether the @a d daemon is using select()
155 */ 155 */
156#define MHD_D_USING_SELECT_(d) \ 156#define MHD_D_IS_USING_SELECT_(d) \
157 (0 == (d->options & (MHD_USE_POLL | MHD_USE_EPOLL))) 157 (0 == (d->options & (MHD_USE_POLL | MHD_USE_EPOLL)))
158/** 158/**
159 * Checks whether the @a d daemon is using poll() 159 * Checks whether the @a d daemon is using poll()
160 */ 160 */
161#define MHD_D_USING_POLL_(d) (0 != (d->options & MHD_USE_POLL)) 161#define MHD_D_IS_USING_POLL_(d) (0 != ((d)->options & MHD_USE_POLL))
162/** 162/**
163 * Checks whether the @a d daemon is using epoll 163 * Checks whether the @a d daemon is using epoll
164 */ 164 */
165#define MHD_D_USING_EPOLL_(d) (0 != (d->options & MHD_USE_EPOLL)) 165#define MHD_D_IS_USING_EPOLL_(d) (0 != ((d)->options & MHD_USE_EPOLL))
166#elif defined(HAVE_POLL) 166#elif defined(HAVE_POLL)
167/** 167/**
168 * Checks whether the @a d daemon is using select() 168 * Checks whether the @a d daemon is using select()
169 */ 169 */
170#define MHD_D_USING_SELECT_(d) (0 == (d->options & MHD_USE_POLL)) 170#define MHD_D_IS_USING_SELECT_(d) (0 == ((d)->options & MHD_USE_POLL))
171/** 171/**
172 * Checks whether the @a d daemon is using poll() 172 * Checks whether the @a d daemon is using poll()
173 */ 173 */
174#define MHD_D_USING_POLL_(d) (0 != (d->options & MHD_USE_POLL)) 174#define MHD_D_IS_USING_POLL_(d) (0 != ((d)->options & MHD_USE_POLL))
175/** 175/**
176 * Checks whether the @a d daemon is using epoll 176 * Checks whether the @a d daemon is using epoll
177 */ 177 */
178#define MHD_D_USING_EPOLL_(d) (0) 178#define MHD_D_IS_USING_EPOLL_(d) ((void) (d), 0)
179#elif defined(EPOLL_SUPPORT) 179#elif defined(EPOLL_SUPPORT)
180/** 180/**
181 * Checks whether the @a d daemon is using select() 181 * Checks whether the @a d daemon is using select()
182 */ 182 */
183#define MHD_D_USING_SELECT_(d) (0 == (d->options & MHD_USE_EPOLL)) 183#define MHD_D_IS_USING_SELECT_(d) (0 == ((d)->options & MHD_USE_EPOLL))
184/** 184/**
185 * Checks whether the @a d daemon is using poll() 185 * Checks whether the @a d daemon is using poll()
186 */ 186 */
187#define MHD_D_USING_POLL_(d) (0) 187#define MHD_D_IS_USING_POLL_(d) ((void) (d), 0)
188/** 188/**
189 * Checks whether the @a d daemon is using epoll 189 * Checks whether the @a d daemon is using epoll
190 */ 190 */
191#define MHD_D_USING_EPOLL_(d) (0 != (d->options & MHD_USE_EPOLL)) 191#define MHD_D_IS_USING_EPOLL_(d) (0 != ((d)->options & MHD_USE_EPOLL))
192#else /* select() only */ 192#else /* select() only */
193/** 193/**
194 * Checks whether the @a d daemon is using select() 194 * Checks whether the @a d daemon is using select()
195 */ 195 */
196#define MHD_D_USING_SELECT_(d) (! 0) 196#define MHD_D_IS_USING_SELECT_(d) ((void) (d), ! 0)
197/** 197/**
198 * Checks whether the @a d daemon is using poll() 198 * Checks whether the @a d daemon is using poll()
199 */ 199 */
200#define MHD_D_USING_POLL_(d) (0) 200#define MHD_D_IS_USING_POLL_(d) ((void) (d), 0)
201/** 201/**
202 * Checks whether the @a d daemon is using epoll 202 * Checks whether the @a d daemon is using epoll
203 */ 203 */
204#define MHD_D_USING_EPOLL_(d) (0) 204#define MHD_D_IS_USING_EPOLL_(d) ((void) (d), 0)
205#endif /* select() only */ 205#endif /* select() only */
206 206
207/** 207/**
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index e96bf0d8..caf7bd18 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -2023,7 +2023,7 @@ MHD_response_execute_upgrade_ (struct MHD_Response *response,
2023#endif /* MHD_socket_nosignal_ */ 2023#endif /* MHD_socket_nosignal_ */
2024 if ( (! MHD_SCKT_FD_FITS_FDSET_ (sv[1], 2024 if ( (! MHD_SCKT_FD_FITS_FDSET_ (sv[1],
2025 NULL)) && 2025 NULL)) &&
2026 (0 == (daemon->options & (MHD_USE_POLL | MHD_USE_EPOLL))) ) 2026 MHD_D_IS_USING_SELECT_ (daemon) )
2027 { 2027 {
2028#ifdef HAVE_MESSAGES 2028#ifdef HAVE_MESSAGES
2029 MHD_DLOG (daemon, 2029 MHD_DLOG (daemon,
@@ -2044,7 +2044,7 @@ MHD_response_execute_upgrade_ (struct MHD_Response *response,
2044 urh->mhd.celi = MHD_EPOLL_STATE_UNREADY; 2044 urh->mhd.celi = MHD_EPOLL_STATE_UNREADY;
2045#ifdef EPOLL_SUPPORT 2045#ifdef EPOLL_SUPPORT
2046 /* Launch IO processing by the event loop */ 2046 /* Launch IO processing by the event loop */
2047 if (0 != (daemon->options & MHD_USE_EPOLL)) 2047 if (MHD_D_IS_USING_EPOLL_ (daemon))
2048 { 2048 {
2049 /* We're running with epoll(), need to add the sockets 2049 /* We're running with epoll(), need to add the sockets
2050 to the event set of the daemon's `epoll_upgrade_fd` */ 2050 to the event set of the daemon's `epoll_upgrade_fd` */