From 5cbdf771760d1e50147ee54b44b200218fa20ebe Mon Sep 17 00:00:00 2001 From: "Evgeny Grin (Karlson2k)" Date: Fri, 17 Nov 2023 13:49:32 +0300 Subject: [PATCH] MHD_start_daemon(): moved daemon flags internal initialisation --- src/microhttpd/daemon.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index b7e9a5d1..a696b260 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c @@ -7594,6 +7594,10 @@ MHD_start_daemon_va (unsigned int flags, MHD_check_global_init_ (); eflags = (enum MHD_FLAG) flags; pflags = &eflags; + + if (0 != (*pflags & MHD_USE_THREAD_PER_CONNECTION)) + *pflags |= MHD_USE_INTERNAL_POLLING_THREAD; /* Force enable, log warning later if needed */ + #ifndef HAVE_INET6 if (0 != (*pflags & MHD_USE_IPv6)) return NULL; @@ -7657,6 +7661,16 @@ MHD_start_daemon_va (unsigned int flags, #endif } + if (0 == (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) + *pflags = (*pflags & ~((enum MHD_FLAG) MHD_USE_ITC)); /* useless if we are using 'external' select */ + else + { +#ifdef HAVE_LISTEN_SHUTDOWN + if (0 != (*pflags & MHD_USE_NO_LISTEN_SOCKET)) +#endif + *pflags |= MHD_USE_ITC; /* yes, must use ITC to signal thread */ + } + if (NULL == (daemon = MHD_calloc_ (1, sizeof (struct MHD_Daemon)))) return NULL; interim_params = (struct MHD_InterimParams_ *) \ @@ -7723,21 +7737,6 @@ MHD_start_daemon_va (unsigned int flags, daemon->fdset_size_set_by_app = false; #endif /* HAS_FD_SETSIZE_OVERRIDABLE */ - if ( (0 != (*pflags & MHD_USE_THREAD_PER_CONNECTION)) && - (0 == (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) ) - { - /* Log warning message later, when log parameters are processes */ - *pflags |= MHD_USE_INTERNAL_POLLING_THREAD; - } - if (0 == (*pflags & MHD_USE_INTERNAL_POLLING_THREAD)) - *pflags = (*pflags & ~((enum MHD_FLAG) MHD_USE_ITC)); /* useless if we are using 'external' select */ - else - { -#ifdef HAVE_LISTEN_SHUTDOWN - if (0 != (*pflags & MHD_USE_NO_LISTEN_SOCKET)) -#endif - *pflags |= MHD_USE_ITC; /* yes, must use ITC to signal thread */ - } #ifdef DAUTH_SUPPORT daemon->digest_auth_rand_size = 0; daemon->digest_auth_random = NULL;