commit 9ca784b0f4684c043fae1c3189c976da27d40332
parent 5feff9f77bd6b51db3bcbc8ed0ce4310c39bfcc2
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date: Sat, 28 Feb 2026 11:23:47 +0100
Debug-trace refactoring, added new configure parameters
Diffstat:
12 files changed, 338 insertions(+), 94 deletions(-)
diff --git a/configure.ac b/configure.ac
@@ -84,15 +84,16 @@ AC_ARG_ENABLE([build-type],
[AS_HELP_STRING([[--enable-build-type=TYPE]],
[enable build TYPE, a set of configuration parameters; individual settings ]
[(asserts, sanitizers, compiler and linker flags) can be overridden by ]
- [additional configure parameters (debug, debugger, neutral, release, release-compact, ]
- [release-hardened) [neutral]])],
+ [additional configure parameters (debug, debugger, trace, neutral, release, ]
+ [release-compact, release-hardened) [neutral]])],
[], [enable_build_type=neutral])
AS_IF([test "x${enable_build_type}" = "x"], [enable_build_type="neutral"])
AS_VAR_IF([enable_build_type], ["no"], [enable_build_type="neutral"])
AS_VAR_IF([enable_build_type], ["yes"], [AC_MSG_ERROR([[Missing TYPE for --enable-build-type=]])])
AS_CASE([${enable_build_type}],
[debug], [AC_MSG_RESULT([debug. Defaults: enable asserts, sanitizers (if any supported), debug information, compiler optimisation for debugging])],
- [debugger], [AC_MSG_RESULT([debugger. Defaults: enable asserts, disable sanitizers, debug information, no compiler optimisation, static lib])],
+ [trace], [AC_MSG_RESULT([trace. Defaults: enable asserts, debug prints, debug information, compiler optimisation for debugging])],
+ [debugger], [AC_MSG_RESULT([debugger. Defaults: enable asserts, debug information, no compiler optimisation, static lib])],
[neutral], [AC_MSG_RESULT([neutral. Defaults: use only user-specified compiler and linker flags])],
[release], [AC_MSG_RESULT([release. Defaults: disable asserts, enable compiler optimisations])],
[release-compact], [AC_MSG_RESULT([release-compact. Defaults: disable asserts, enable compiler optimisations for size, enable compact code])],
@@ -124,7 +125,7 @@ AS_VAR_IF([enable_build_type], ["debugger"],
)
]
)
-AS_CASE([${enable_build_type}],[debug|debugger],
+AS_CASE([${enable_build_type}],[debug|debugger|trace],
[ AS_IF([test -z "${enable_silent_rules}"], [ enable_silent_rules="yes" ])]
)
@@ -365,8 +366,8 @@ choke me now
)
]
)
-AS_CASE([${enable_build_type}],[debug|debugger],
- [ # Debug build or build for walking with debugger
+AS_CASE([${enable_build_type}],[debug|debugger|trace],
+ [ # Debug build, build for walking with debugger or debug printing build
CFLAGS="${user_CFLAGS}"
AS_VAR_IF([enable_build_type],["debug"],
[
@@ -430,8 +431,8 @@ AS_VAR_IF([enable_build_type],["neutral"],[],
LDFLAGS="${LDFLAGS_ac} ${user_LDFLAGS}"
]
)
-AS_CASE([${enable_build_type}],[debug|debugger],
- [ # Debug build or build for walking with debugger
+AS_CASE([${enable_build_type}],[debug|debugger|trace],
+ [ # Debug build, build for walking with debugger or debug printing build
CFLAGS="${user_CFLAGS}"
MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-ggdb3], [-g3], [-ggdb], [-g])
MHD_CHECK_ADD_CC_CFLAG([-Wextra], [CFLAGS_ac])
@@ -8210,7 +8211,7 @@ AC_MSG_CHECKING([[whether to enable debug asserts]])
AS_VAR_IF([enable_asserts],["auto"],
[
AS_CASE([${enable_build_type}],
- [debug|debugger],
+ [debug|debugger|trace],
[
enable_asserts="yes"
use_asserts_MSG="yes, enabled by --enable-bulid-type=${enable_build_type}"
@@ -8268,6 +8269,227 @@ int main(void)
]
)
+AC_ARG_ENABLE([[trace-fds-polling]],
+ [AS_HELP_STRING([[--enable-trace-fds-polling]],
+ [enable test build with debug printing of FDs polling])],
+ [
+ AS_CASE([${enable_trace_fds_polling}],
+ [yes|no],[:],
+ [AC_MSG_ERROR([wrong parameter --enable-trace-fds-polling=${enable_trace_fds_polling}])]
+ )
+ ],
+ [enable_trace_fds_polling='auto']
+)
+AS_UNSET([use_trace_fds_polling_MSG])
+AS_UNSET([use_trace_fds_polling])
+AC_CACHE_CHECK([[whether MHD_USE_TRACE_POLLING_FDS macro is defined]], [mhd_cv_macro_trace_polling_fds_def],
+ [
+ AC_LINK_IFELSE(
+ [
+ AC_LANG_SOURCE([[
+#ifndef MHD_USE_TRACE_POLLING_FDS
+#error MHD_USE_TRACE_POLLING_FDS is NOT defined
+chome me now
+#endif
+
+int main(void)
+{ return 0; }
+ ]]
+ )
+ ],
+ [[mhd_cv_macro_trace_polling_fds_def='yes']],
+ [[mhd_cv_macro_trace_polling_fds_def='no']]
+ )
+ ]
+)
+AC_MSG_CHECKING([whether to enable debug-print of FDs polling])
+AS_VAR_IF([mhd_cv_macro_trace_polling_fds_def],["yes"],
+ [
+ use_trace_fds_polling="yes"
+ use_trace_fds_polling_MSG="yes, forced by MHD_USE_TRACE_POLLING_FDS macro"
+ ]
+)
+AS_VAR_SET_IF([use_trace_fds_polling],[:],
+ [
+ AS_CASE([${enable_trace_fds_polling}],
+ [yes],[
+ use_trace_fds_polling="yes"
+ use_trace_fds_polling_MSG="yes, enabled by --enable-trace-fds-polling"
+ ],
+ [no],[
+ use_trace_fds_polling="no"
+ use_trace_fds_polling_MSG="no, disabled by --disable-trace-fds-polling"
+ ],
+ [auto],[
+ AS_CASE([${enable_build_type}],
+ [trace],[
+ use_trace_fds_polling="yes"
+ use_trace_fds_polling_MSG="yes, enabled by --enable-bulid-type=${enable_build_type}"
+ ],
+ [
+ use_trace_fds_polling="no"
+ use_trace_fds_polling_MSG="no"
+ ]
+ )
+ ],
+ [AC_MSG_FAILURE([configure is broken])]
+ )
+ ]
+)
+AS_IF([test "X${use_trace_fds_polling}" = "Xyes" && test "X${mhd_cv_macro_trace_polling_fds_def}" != "Xyes"],
+ [AC_DEFINE([[MHD_USE_TRACE_POLLING_FDS]], [[1]], [Define to enable debug-print of FDs polling])]
+)
+test -n "${use_trace_fds_polling_MSG}" || use_trace_fds_polling_MSG}="${use_trace_fds_polling}"
+AC_MSG_RESULT([${use_trace_fds_polling_MSG}])
+
+AC_ARG_ENABLE([[trace-conn-add-close]],
+ [AS_HELP_STRING([[--enable-trace-conn-add-close]],
+ [enable test build with debug printing of connections adding and closing])],
+ [
+ AS_CASE([${enable_trace_conn_add_close}],
+ [yes|no],[:],
+ [AC_MSG_ERROR([wrong parameter --enable-trace-conn-add-close=${enable_trace_conn_add_close}])]
+ )
+ ],
+ [enable_trace_conn_add_close='auto']
+)
+AS_UNSET([use_trace_conn_add_close_MSG])
+AS_UNSET([use_trace_conn_add_close])
+AC_CACHE_CHECK([[whether MHD_USE_TRACE_CONN_ADD_CLOSE macro is defined]],
+ [mhd_cv_macro_trace_conn_add_close_def],
+ [
+ AC_LINK_IFELSE(
+ [
+ AC_LANG_SOURCE([[
+#ifndef MHD_USE_TRACE_CONN_ADD_CLOSE
+#error MHD_USE_TRACE_CONN_ADD_CLOSE is NOT defined
+chome me now
+#endif
+
+int main(void)
+{ return 0; }
+ ]]
+ )
+ ],
+ [[mhd_cv_macro_trace_conn_add_close_def='yes']],
+ [[mhd_cv_macro_trace_conn_add_close_def='no']]
+ )
+ ]
+)
+AC_MSG_CHECKING([whether to enable debug-print of of connections adding and closing])
+AS_VAR_IF([mhd_cv_macro_trace_conn_add_close_def],["yes"],
+ [
+ use_trace_conn_add_close="yes"
+ use_trace_conn_add_close_MSG="yes, forced by MHD_USE_TRACE_CONN_ADD_CLOSE macro"
+ ]
+)
+AS_VAR_SET_IF([use_trace_conn_add_close],[:],
+ [
+ AS_CASE([${enable_trace_conn_add_close}],
+ [yes],[
+ use_trace_conn_add_close="yes"
+ use_trace_conn_add_close_MSG="yes, enabled by --enable-trace-conn-add-close"
+ ],
+ [no],[
+ use_trace_conn_add_close="no"
+ use_trace_conn_add_close_MSG="no, disabled by --disable-trace-conn-add-close"
+ ],
+ [auto],[
+ AS_CASE([${enable_build_type}],
+ [trace],[
+ use_trace_conn_add_close="yes"
+ use_trace_conn_add_close_MSG="yes, enabled by --enable-bulid-type=${enable_build_type}"
+ ],
+ [
+ use_trace_conn_add_close="no"
+ use_trace_conn_add_close_MSG="no"
+ ]
+ )
+ ],
+ [AC_MSG_FAILURE([configure is broken])]
+ )
+ ]
+)
+AS_IF([test "X${use_trace_conn_add_close}" = "Xyes" && test "X${mhd_cv_macro_trace_conn_add_close_def}" != "Xyes"],
+ [AC_DEFINE([[MHD_USE_TRACE_CONN_ADD_CLOSE]], [[1]], [Define to enable debug-print of connection adding and closing])]
+)
+test -n "${use_trace_conn_add_close_MSG}" || use_trace_conn_add_close_MSG="${use_trace_conn_add_close}"
+AC_MSG_RESULT([${use_trace_conn_add_close_MSG}])
+
+AC_ARG_ENABLE([[trace-suspend-resume]],
+ [AS_HELP_STRING([[--enable-trace-suspend-resume]],
+ [enable test build with debug printing of requests suspending and resuming])],
+ [
+ AS_CASE([${enable_trace_suspend_resume}],
+ [yes|no],[:],
+ [AC_MSG_ERROR([wrong parameter --enable-trace-suspend-resume=${enable_trace_suspend_resume}])]
+ )
+ ],
+ [enable_trace_suspend_resume='auto']
+)
+AS_UNSET([use_trace_suspend_resume_MSG])
+AS_UNSET([use_trace_suspend_resume])
+AC_CACHE_CHECK([[whether MHD_USE_TRACE_SUSPEND_RESUME macro is defined]],
+ [mhd_cv_macro_trace_suspend_resume_def],
+ [
+ AC_LINK_IFELSE(
+ [
+ AC_LANG_SOURCE([[
+#ifndef MHD_USE_TRACE_SUSPEND_RESUME
+#error MHD_USE_TRACE_SUSPEND_RESUME is NOT defined
+chome me now
+#endif
+
+int main(void)
+{ return 0; }
+ ]]
+ )
+ ],
+ [[mhd_cv_macro_trace_suspend_resume_def='yes']],
+ [[mhd_cv_macro_trace_suspend_resume_def='no']]
+ )
+ ]
+)
+AC_MSG_CHECKING([whether to enable debug-print of of requests suspending and resuming])
+AS_VAR_IF([mhd_cv_macro_trace_suspend_resume_def],["yes"],
+ [
+ use_trace_suspend_resume="yes"
+ use_trace_suspend_resume_MSG="yes, forced by MHD_USE_TRACE_SUSPEND_RESUME macro"
+ ]
+)
+AS_VAR_SET_IF([use_trace_suspend_resume],[:],
+ [
+ AS_CASE([${enable_trace_suspend_resume}],
+ [yes],[
+ use_trace_suspend_resume="yes"
+ use_trace_suspend_resume_MSG="yes, enabled by --enable-trace-suspend-resume"
+ ],
+ [no],[
+ use_trace_suspend_resume="no"
+ use_trace_suspend_resume_MSG="no, disabled by --disable-trace-suspend-resume"
+ ],
+ [auto],[
+ AS_CASE([${enable_build_type}],
+ [trace],[
+ use_trace_suspend_resume="yes"
+ use_trace_suspend_resume_MSG="yes, enabled by --enable-bulid-type=${enable_build_type}"
+ ],
+ [
+ use_trace_suspend_resume="no"
+ use_trace_suspend_resume_MSG="no"
+ ]
+ )
+ ],
+ [AC_MSG_FAILURE([configure is broken])]
+ )
+ ]
+)
+AS_IF([test "X${use_trace_suspend_resume}" = "Xyes" && test "X${mhd_cv_macro_trace_suspend_resume_def}" != "Xyes"],
+ [AC_DEFINE([[MHD_USE_TRACE_SUSPEND_RESUME]], [[1]], [Define to enable debug-print of requests suspending and resuming])]
+)
+test -n "${use_trace_suspend_resume_MSG}" || use_trace_suspend_resume_MSG="${use_trace_suspend_resume}"
+AC_MSG_RESULT([${use_trace_suspend_resume_MSG}])
+
AS_UNSET([enabled_sanitizers])
TESTS_ENVIRONMENT_ac=""
AM_ASAN_OPTIONS=""
@@ -9008,8 +9230,8 @@ AM_CONDITIONAL([RUN_ZZUF_TESTS],[test "x$run_zzuf_tests" = "xyes"])
AM_CONDITIONAL([FORCE_USE_ZZUF_SOCAT],[test "x$zzuf_socat_mandatory" = "xyes"])
# Final flags that may interfere with autoconf detections
-AS_CASE([${enable_build_type}],[debug|debugger],
- [ # Debug build or build for walking with debugger
+AS_CASE([${enable_build_type}],[debug|debugger|trace],
+ [ # Debug build, build for walking with debugger or debug printing build
CFLAGS="${user_CFLAGS}"
MHD_CHECK_ADD_CC_CFLAGS([-Wextra-semi -Wextra-semi-stmt], [CFLAGS_ac])
MHD_FIND_ADD_CC_CFLAG([CFLAGS_ac], [-Wleading-whitespace=spaces], [-Wleading-whitespace])
@@ -9193,6 +9415,11 @@ AC_MSG_NOTICE([[${PACKAGE_NAME} ${PACKAGE_VERSION} Configuration Summary:
Use thread names : ${enable_thread_names}
Use debug asserts: ${use_asserts_MSG=no}
Use sanitizers : ${enabled_sanitizers:=no}
+
+ [ Tracing debug prints ]
+ Trace FDs polling: ${use_trace_fds_polling_MSG}
+ Conns add/close : ${use_trace_conn_add_close_MSG}
+ Suspend/resume : ${use_trace_suspend_resume_MSG}
[ Build items ]
Build static lib : ${enable_static}
diff --git a/src/incl_priv/mhd_sys_options.h b/src/incl_priv/mhd_sys_options.h
@@ -627,19 +627,21 @@
# endif
#endif
-#ifndef mhd_DEBUG_POLLING_FDS
+/* Manual overrides for debug-printing */
+
+#ifndef MHD_USE_TRACE_POLLING_FDS
/* Use debug-print for FDs polling */
-/* # define mhd_DEBUG_POLLING_FDS 1 */
+/* # define MHD_USE_TRACE_POLLING_FDS 1 */
#endif
-#ifndef mhd_DEBUG_SUSPEND_RESUME
-/* Use debug-print for suspending and resuming of the requests */
-/* # define mhd_DEBUG_SUSPEND_RESUME 1 */
+#ifndef MHD_USE_TRACE_CONN_ADD_CLOSE
+/* Use debug-print for adding and closing of the connections */
+/* # define MHD_USE_TRACE_CONN_ADD_CLOSE 1 */
#endif
-#ifndef mhd_DEBUG_CONN_ADD_CLOSE
-/* Use debug-print for adding and closing of the connections */
-/* # define mhd_DEBUG_CONN_ADD_CLOSE 1 */
+#ifndef MHD_USE_TRACE_SUSPEND_RESUME
+/* Use debug-print for suspending and resuming of the requests */
+/* # define MHD_USE_TRACE_SUSPEND_RESUME 1 */
#endif
#ifndef MHD_AUTH_DIGEST_DEF_TIMEOUT
diff --git a/src/mhd2/daemon_add_conn.c b/src/mhd2/daemon_add_conn.c
@@ -69,9 +69,9 @@
#include "sys_sockets_headers.h"
#include "sys_ip_headers.h"
-#ifdef mhd_DEBUG_CONN_ADD_CLOSE
+#ifdef MHD_USE_TRACE_CONN_ADD_CLOSE
# include <stdio.h>
-#endif /* mhd_DEBUG_CONN_ADD_CLOSE */
+#endif /* MHD_USE_TRACE_CONN_ADD_CLOSE */
#include <string.h>
#ifdef MHD_SUPPORT_EPOLL
# include <sys/epoll.h>
@@ -568,7 +568,7 @@ new_connection_process_ (struct MHD_Daemon *restrict daemon,
res = new_connection_process_inner (daemon,
connection);
-#ifdef mhd_DEBUG_CONN_ADD_CLOSE
+#ifdef MHD_USE_TRACE_CONN_ADD_CLOSE
if (MHD_SC_OK == res)
fprintf (stderr,
"&&& Added new connection, FD: %2llu\n",
@@ -578,7 +578,7 @@ new_connection_process_ (struct MHD_Daemon *restrict daemon,
"&&& Failed add connection, FD: %2llu -> %u\n",
(unsigned long long) connection->sk.fd,
(unsigned int) res);
-#endif /* mhd_DEBUG_CONN_ADD_CLOSE */
+#endif /* MHD_USE_TRACE_CONN_ADD_CLOSE */
return res;
}
@@ -1229,11 +1229,11 @@ mhd_conn_close_final (struct MHD_Connection *restrict c)
if (NULL != c->sk.addr.data)
free (c->sk.addr.data);
mhd_socket_close (c->sk.fd);
-#ifdef mhd_DEBUG_CONN_ADD_CLOSE
+#ifdef MHD_USE_TRACE_CONN_ADD_CLOSE
fprintf (stderr,
"&&& Closed connection, FD: %2llu\n",
(unsigned long long) c->sk.fd);
-#endif /* mhd_DEBUG_CONN_ADD_CLOSE */
+#endif /* MHD_USE_TRACE_CONN_ADD_CLOSE */
free (c);
}
diff --git a/src/mhd2/daemon_event_update.c b/src/mhd2/daemon_event_update.c
@@ -54,10 +54,10 @@
#include "daemon_logger.h"
-#ifdef mhd_DEBUG_POLLING_FDS
+#ifdef MHD_USE_TRACE_POLLING_FDS
# include "mhd_itc.h"
# include <stdio.h>
-#endif /* mhd_DEBUG_POLLING_FDS */
+#endif /* MHD_USE_TRACE_POLLING_FDS */
#include "mhd_public_api.h"
@@ -78,7 +78,7 @@ MHD_daemon_event_update (
if (mhd_DAEMON_STATE_STARTED < daemon->state)
return;
-#ifdef mhd_DEBUG_POLLING_FDS
+#ifdef MHD_USE_TRACE_POLLING_FDS
if (1)
{
char state_str[] = "x:x:x";
@@ -114,7 +114,7 @@ MHD_daemon_event_update (
break;
}
}
-#endif /* mhd_DEBUG_POLLING_FDS */
+#endif /* MHD_USE_TRACE_POLLING_FDS */
broken_app_data = false;
unneeded_event = false;
diff --git a/src/mhd2/events_process.c b/src/mhd2/events_process.c
@@ -50,9 +50,9 @@
#include "mhd_predict.h"
-#if defined(mhd_DEBUG_SUSPEND_RESUME) || defined(mhd_DEBUG_POLLING_FDS)
+#if defined(MHD_USE_TRACE_SUSPEND_RESUME) || defined(MHD_USE_TRACE_POLLING_FDS)
# include <stdio.h>
-#endif /* mhd_DEBUG_SUSPEND_RESUME */
+#endif /* MHD_USE_TRACE_SUSPEND_RESUME || MHD_USE_TRACE_POLLING_FDS */
#include "mhd_locks.h"
@@ -101,7 +101,7 @@
#include "mhd_public_api.h"
-#ifdef mhd_DEBUG_POLLING_FDS
+#ifdef MHD_USE_TRACE_POLLING_FDS
/**
* Debug-printf request of FD polling/monitoring
* @param fd_name the name of FD ("ITC", "lstn" or "conn")
@@ -158,10 +158,10 @@ dbg_print_fd_state_update (const char *fd_name,
}
-#else /* ! mhd_DEBUG_POLLING_FDS */
+#else /* ! MHD_USE_TRACE_POLLING_FDS */
# define dbg_print_fd_state_update(fd_n,fd,r_ready,w_ready,e_ready) \
((void) 0)
-#endif /* ! mhd_DEBUG_POLLING_FDS */
+#endif /* ! MHD_USE_TRACE_POLLING_FDS */
#ifdef MHD_SUPPORT_THREADS
/**
@@ -240,7 +240,7 @@ mhd_daemon_get_wait_max (const struct MHD_Daemon *restrict d)
if (d->events.accept_pending && ! d->conns.block_new)
{
-#ifdef mhd_DEBUG_POLLING_FDS
+#ifdef MHD_USE_TRACE_POLLING_FDS
fprintf (stderr,
"### mhd_daemon_get_wait_max(daemon) -> zero "
"(accept new conn pending)\n");
@@ -249,7 +249,7 @@ mhd_daemon_get_wait_max (const struct MHD_Daemon *restrict d)
}
if (d->events.act_req.resume)
{
-#ifdef mhd_DEBUG_POLLING_FDS
+#ifdef MHD_USE_TRACE_POLLING_FDS
fprintf (stderr,
"### mhd_daemon_get_wait_max(daemon) -> zero "
"(resume connection pending)\n");
@@ -258,7 +258,7 @@ mhd_daemon_get_wait_max (const struct MHD_Daemon *restrict d)
}
if (NULL != mhd_DLINKEDL_GET_FIRST (&(d->events), proc_ready))
{
-#ifdef mhd_DEBUG_POLLING_FDS
+#ifdef MHD_USE_TRACE_POLLING_FDS
fprintf (stderr,
"### mhd_daemon_get_wait_max(daemon) -> zero "
"(connection(s) is already ready)\n");
@@ -268,7 +268,7 @@ mhd_daemon_get_wait_max (const struct MHD_Daemon *restrict d)
if (NULL != mhd_DLINKEDL_GET_FIRST (&(d->events.act_req.ext_added.worker),
queue))
{
-#ifdef mhd_DEBUG_POLLING_FDS
+#ifdef MHD_USE_TRACE_POLLING_FDS
fprintf (stderr,
"### mhd_daemon_get_wait_max(daemon) -> zero "
"(externally added connection(s) pending)\n");
@@ -278,7 +278,7 @@ mhd_daemon_get_wait_max (const struct MHD_Daemon *restrict d)
ret = mhd_daemon_get_wait_erliest_timeout (d);
-#ifdef mhd_DEBUG_POLLING_FDS
+#ifdef MHD_USE_TRACE_POLLING_FDS
if (MHD_WAIT_INDEFINITELY == ret)
fprintf (stderr,
"### mhd_daemon_get_wait_max(daemon) -> MHD_WAIT_INDEFINITELY\n");
@@ -297,11 +297,11 @@ start_resuming_connection (struct MHD_Connection *restrict c,
struct MHD_Daemon *restrict d)
{
mhd_assert (c->suspended);
-#ifdef mhd_DEBUG_SUSPEND_RESUME
+#ifdef MHD_USE_TRACE_SUSPEND_RESUME
fprintf (stderr,
"%%%%%% Resuming connection, FD: %2llu\n",
(unsigned long long) c->sk.fd);
-#endif /* mhd_DEBUG_SUSPEND_RESUME */
+#endif /* MHD_USE_TRACE_SUSPEND_RESUME */
c->suspended = false;
mhd_conn_init_activity_timeout (c,
c->timeout.milsec);
@@ -1237,7 +1237,7 @@ get_all_net_updates_by_select_and_resume_conn (struct MHD_Daemon *restrict d,
}
#endif /* MHD_SOCKETS_KIND_WINSOCK */
-#ifdef mhd_DEBUG_POLLING_FDS
+#ifdef MHD_USE_TRACE_POLLING_FDS
if (NULL != tmvl_ptr)
fprintf (stderr,
"### (Starting) select(%d, rfds, wfds, efds, [%llu, %llu])...\n",
@@ -1248,13 +1248,13 @@ get_all_net_updates_by_select_and_resume_conn (struct MHD_Daemon *restrict d,
fprintf (stderr,
"### (Starting) select(%d, rfds, wfds, efds, [NULL])...\n",
max_socket + 1);
-#endif /* mhd_DEBUG_POLLING_FDS */
+#endif /* MHD_USE_TRACE_POLLING_FDS */
num_events = select (max_socket + 1,
d->events.data.select.rfds,
d->events.data.select.wfds,
d->events.data.select.efds,
tmvl_ptr);
-#ifdef mhd_DEBUG_POLLING_FDS
+#ifdef MHD_USE_TRACE_POLLING_FDS
if (NULL != tmvl_ptr)
fprintf (stderr,
"### (Finished) select(%d, rfds, wfds, efds, ->[%llu, %llu]) -> "
@@ -1269,7 +1269,7 @@ get_all_net_updates_by_select_and_resume_conn (struct MHD_Daemon *restrict d,
"%d\n",
max_socket + 1,
num_events);
-#endif /* mhd_DEBUG_POLLING_FDS */
+#endif /* MHD_USE_TRACE_POLLING_FDS */
if (0 > num_events)
{
@@ -1569,13 +1569,13 @@ static MHD_FN_PAR_NONNULL_ (1) bool
get_all_net_updates_by_poll (struct MHD_Daemon *restrict d,
bool listen_only)
{
-#ifdef mhd_DEBUG_POLLING_FDS
+#ifdef MHD_USE_TRACE_POLLING_FDS
# ifdef MHD_SOCKETS_KIND_POSIX
static const char poll_fn_name[] = "poll";
# else /* MHD_SOCKETS_KIND_WINSOCK */
static const char poll_fn_name[] = "WSAPoll";
# endif /* MHD_SOCKETS_KIND_WINSOCK */
-#endif /* mhd_DEBUG_POLLING_FDS */
+#endif /* MHD_USE_TRACE_POLLING_FDS */
unsigned int num_fds;
int max_wait;
int num_events;
@@ -1587,24 +1587,24 @@ get_all_net_updates_by_poll (struct MHD_Daemon *restrict d,
// TODO: handle empty list situation
max_wait = get_max_wait (d);
-#ifdef mhd_DEBUG_POLLING_FDS
+#ifdef MHD_USE_TRACE_POLLING_FDS
fprintf (stderr,
"### (Starting) %s(fds, %u, %d)...\n",
poll_fn_name,
num_fds,
max_wait);
-#endif /* mhd_DEBUG_POLLING_FDS */
+#endif /* MHD_USE_TRACE_POLLING_FDS */
num_events = mhd_poll (d->events.data.poll.fds,
num_fds,
max_wait); // TODO: use correct timeout value
-#ifdef mhd_DEBUG_POLLING_FDS
+#ifdef MHD_USE_TRACE_POLLING_FDS
fprintf (stderr,
"### (Finished) %s(fds, %u, %d) -> %d\n",
poll_fn_name,
num_fds,
max_wait,
num_events);
-#endif /* mhd_DEBUG_POLLING_FDS */
+#endif /* MHD_USE_TRACE_POLLING_FDS */
if (0 > num_events)
{
int err;
@@ -1781,25 +1781,25 @@ get_all_net_updates_by_epoll (struct MHD_Daemon *restrict d)
max_wait = get_max_wait (d);
do
{
-#ifdef mhd_DEBUG_POLLING_FDS
+#ifdef MHD_USE_TRACE_POLLING_FDS
fprintf (stderr,
"### (Starting) epoll_wait(%d, events, %d, %d)...\n",
d->events.data.epoll.e_fd,
(int) d->events.data.epoll.num_elements,
max_wait);
-#endif /* mhd_DEBUG_POLLING_FDS */
+#endif /* MHD_USE_TRACE_POLLING_FDS */
num_events = epoll_wait (d->events.data.epoll.e_fd,
d->events.data.epoll.events,
max_events,
max_wait);
-#ifdef mhd_DEBUG_POLLING_FDS
+#ifdef MHD_USE_TRACE_POLLING_FDS
fprintf (stderr,
"### (Finished) epoll_wait(%d, events, %d, %d) -> %d\n",
d->events.data.epoll.e_fd,
max_events,
max_wait,
num_events);
-#endif /* mhd_DEBUG_POLLING_FDS */
+#endif /* MHD_USE_TRACE_POLLING_FDS */
max_wait = 0;
if (0 > num_events)
{
@@ -2039,14 +2039,14 @@ MHD_daemon_process_reg_events (struct MHD_Daemon *MHD_RESTRICT daemon,
uint_fast64_t *MHD_RESTRICT next_max_wait)
{
enum MHD_StatusCode res;
-#ifdef mhd_DEBUG_POLLING_FDS
+#ifdef MHD_USE_TRACE_POLLING_FDS
fprintf (stderr,
"### (Starting) MHD_daemon_process_reg_events(daemon, [%s])...\n",
(NULL != next_max_wait) ? "non-NULL" : "NULL");
#endif
res = process_reg_events_int (daemon,
next_max_wait);
-#ifdef mhd_DEBUG_POLLING_FDS
+#ifdef MHD_USE_TRACE_POLLING_FDS
if (NULL == next_max_wait)
fprintf (stderr,
"### (Finished) MHD_daemon_process_reg_events(daemon, [NULL]) ->"
diff --git a/src/mhd2/extr_events_funcs.h b/src/mhd2/extr_events_funcs.h
@@ -47,12 +47,12 @@
#include "mhd_sys_options.h"
-#ifdef mhd_DEBUG_POLLING_FDS
+#ifdef MHD_USE_TRACE_POLLING_FDS
# include <stdio.h>
# include "mhd_daemon.h"
# include "mhd_assert.h"
# include "sys_null_macro.h"
-#endif /* mhd_DEBUG_POLLING_FDS */
+#endif /* MHD_USE_TRACE_POLLING_FDS */
#ifdef MHD_SUPPORT_LOG_FUNCTIONALITY
@@ -73,7 +73,7 @@ mhd_log_extr_event_dereg_failed (struct MHD_Daemon *restrict d);
#endif /* ! MHD_SUPPORT_LOG_FUNCTIONALITY */
-#ifdef mhd_DEBUG_POLLING_FDS
+#ifdef MHD_USE_TRACE_POLLING_FDS
/**
* Call application event registration callback
* @param d the daemon to use
@@ -141,12 +141,12 @@ mhd_daemon_extr_event_reg (struct MHD_Daemon *d,
return res;
}
-#else /* ! mhd_DEBUG_POLLING_FDS */
+#else /* ! MHD_USE_TRACE_POLLING_FDS */
# define mhd_daemon_extr_event_reg(d,fd,w_for,app_cntx_old,ecb_cntx) \
d->events.data.extr.cb_data.cb (d->events.data.extr.cb_data.cls, \
fd, w_for, app_cntx_old, ecb_cntx)
-#endif /* ! mhd_DEBUG_POLLING_FDS */
+#endif /* ! MHD_USE_TRACE_POLLING_FDS */
#endif /* ! MHD_EXTR_EVENTS_FUNCS_H */
diff --git a/src/mhd2/h2/h2_app_cb.c b/src/mhd2/h2/h2_app_cb.c
@@ -222,11 +222,11 @@ mhd_h2_stream_cb_request (struct mhd_H2Stream *restrict s)
#endif /* MHD_SUPPORT_POST_PARSER */
case mhd_ACTION_SUSPEND:
c->suspended = true;
-#ifdef mhd_DEBUG_SUSPEND_RESUME
+#ifdef MHD_USE_TRACE_SUSPEND_RESUME
fprintf (stderr,
"%%%%%% Suspending connection, FD: %2llu\n",
(unsigned long long) c->sk.fd);
-#endif /* mhd_DEBUG_SUSPEND_RESUME */
+#endif /* MHD_USE_TRACE_SUSPEND_RESUME */
s->req.app_act.head_act.act = mhd_ACTION_NO_ACTION;
return false;
#ifdef MHD_SUPPORT_UPGRADE
diff --git a/src/mhd2/mhd_dbg_print.h b/src/mhd2/mhd_dbg_print.h
@@ -38,7 +38,7 @@
/**
* @file src/mhd2/mhd_dbg_print.h
- * @brief The declarations of interl debug-print helpers
+ * @brief The declarations of internal debug-print/trace helpers
* @author Karlson2k (Evgeny Grin)
*/
@@ -47,13 +47,13 @@
#include "mhd_sys_options.h"
-#ifdef mhd_DEBUG_POLLING_FDS
+#ifdef MHD_USE_TRACE_POLLING_FDS
# include "sys_bool_type.h"
# include "mhd_socket_type.h"
-#endif /* mhd_DEBUG_POLLING_FDS */
+#endif /* MHD_USE_TRACE_POLLING_FDS */
-#ifdef mhd_DEBUG_POLLING_FDS
+#ifdef MHD_USE_TRACE_POLLING_FDS
/**
* Debug-printf request of FD polling/monitoring
* @param fd_name the name of FD ("ITC", "lstn" or "conn")
@@ -71,9 +71,24 @@ mhd_dbg_print_fd_mon_req (const char *fd_name,
bool e_ready)
MHD_FN_PAR_NONNULL_ALL_;
-#else /* ! mhd_DEBUG_POLLING_FDS */
+# ifdef MHD_SUPPORT_KQUEUE
+/**
+ * Debug print kqueue event request update or event report
+ * @param fd_name the name of FD ("ITC", "lstn" or "conn")
+ * @param ke the pointer to kevent
+ * @param update_req set to 'true' if @a ke is in the change list,
+ * set to 'false' if @a ke is in the reported events list
+ */
+MHD_INTERNAL void
+mhd_dbg_print_kevent (const char *fd_name,
+ const struct kevent *ke,
+ bool update_req)
+MHD_FN_PAR_NONNULL_ALL_;
+# endif /* MHD_SUPPORT_KQUEUE */
+
+#else /* ! MHD_USE_TRACE_POLLING_FDS */
# define mhd_dbg_print_fd_mon_req(fd_n,fd,r_ready,w_ready,e_ready) ((void) 0)
-#endif /* ! mhd_DEBUG_POLLING_FDS */
+#endif /* ! MHD_USE_TRACE_POLLING_FDS */
#endif /* ! MHD_DBG_PRINT_H */
diff --git a/src/mhd2/request_resume.c b/src/mhd2/request_resume.c
@@ -46,9 +46,9 @@
#include "mhd_cntnr_ptr.h"
-#ifdef mhd_DEBUG_SUSPEND_RESUME
+#ifdef MHD_USE_TRACE_SUSPEND_RESUME
# include <stdio.h>
-#endif /* mhd_DEBUG_SUSPEND_RESUME */
+#endif /* MHD_USE_TRACE_SUSPEND_RESUME */
#include "mhd_daemon.h"
#include "mhd_connection.h"
@@ -67,20 +67,20 @@ MHD_request_resume (struct MHD_Request *request)
if (! c->suspended)
{
-#ifdef mhd_DEBUG_SUSPEND_RESUME
+#ifdef MHD_USE_TRACE_SUSPEND_RESUME
fprintf (stderr,
"%%%%%% Requested conn resume, FD: %2llu -> "
"failed as not suspended\n",
(unsigned long long) c->sk.fd);
-#endif /* mhd_DEBUG_SUSPEND_RESUME */
+#endif /* MHD_USE_TRACE_SUSPEND_RESUME */
return;
}
c->resuming = true;
-#ifdef mhd_DEBUG_SUSPEND_RESUME
+#ifdef MHD_USE_TRACE_SUSPEND_RESUME
fprintf (stderr,
"%%%%%% Requested conn resume, FD: %2llu\n",
(unsigned long long) c->sk.fd);
-#endif /* mhd_DEBUG_SUSPEND_RESUME */
+#endif /* MHD_USE_TRACE_SUSPEND_RESUME */
d->events.act_req.resume = true;
(void) mhd_daemon_trigger_itc (d);
}
diff --git a/src/mhd2/stream_funcs.c b/src/mhd2/stream_funcs.c
@@ -49,9 +49,9 @@
#include "mhd_assert.h"
#include "mhd_unreachable.h"
-#ifdef mhd_DEBUG_CONN_ADD_CLOSE
+#ifdef MHD_USE_TRACE_CONN_ADD_CLOSE
# include <stdio.h>
-#endif /* mhd_DEBUG_CONN_ADD_CLOSE */
+#endif /* MHD_USE_TRACE_CONN_ADD_CLOSE */
#include <string.h>
#include "extr_events_funcs.h"
#ifdef MHD_SUPPORT_EPOLL
@@ -723,7 +723,7 @@ mhd_conn_start_closing (struct MHD_Connection *restrict c,
enum MHD_StatusCode sc;
bool reply_sending_aborted;
-#ifdef mhd_DEBUG_CONN_ADD_CLOSE
+#ifdef MHD_USE_TRACE_CONN_ADD_CLOSE
fprintf (stderr,
"&&& mhd_conn_start_closing([FD: %2llu], %u, %s%s%s)...\n",
(unsigned long long) c->sk.fd,
@@ -731,7 +731,7 @@ mhd_conn_start_closing (struct MHD_Connection *restrict c,
log_msg ? "\"" : "",
log_msg ? log_msg : "[NULL]",
log_msg ? "\"" : "");
-#endif /* mhd_DEBUG_CONN_ADD_CLOSE */
+#endif /* MHD_USE_TRACE_CONN_ADD_CLOSE */
#ifdef MHD_SUPPORT_HTTP2
if (mhd_C_IS_HTTP2 (c))
@@ -1075,11 +1075,11 @@ MHD_INTERNAL
MHD_FN_PAR_NONNULL_ (1) void
mhd_conn_pre_clean (struct MHD_Connection *restrict c)
{
-#ifdef mhd_DEBUG_CONN_ADD_CLOSE
+#ifdef MHD_USE_TRACE_CONN_ADD_CLOSE
fprintf (stderr,
"&&& Closing connection, FD: %2llu\n",
(unsigned long long) c->sk.fd);
-#endif /* mhd_DEBUG_CONN_ADD_CLOSE */
+#endif /* MHD_USE_TRACE_CONN_ADD_CLOSE */
mhd_assert (c->dbg.closing_started);
mhd_assert (! c->dbg.pre_cleaned);
diff --git a/src/mhd2/stream_process_request.c b/src/mhd2/stream_process_request.c
@@ -58,9 +58,9 @@
#include "sys_malloc.h"
-#ifdef mhd_DEBUG_SUSPEND_RESUME
+#ifdef MHD_USE_TRACE_SUSPEND_RESUME
# include <stdio.h>
-#endif /* mhd_DEBUG_SUSPEND_RESUME */
+#endif /* MHD_USE_TRACE_SUSPEND_RESUME */
#include "mhd_str_types.h"
#include "mhd_str_macros.h"
@@ -3127,11 +3127,11 @@ mhd_stream_call_app_request_cb (struct MHD_Connection *restrict c)
#endif /* MHD_SUPPORT_POST_PARSER */
case mhd_ACTION_SUSPEND:
c->suspended = true;
-#ifdef mhd_DEBUG_SUSPEND_RESUME
+#ifdef MHD_USE_TRACE_SUSPEND_RESUME
fprintf (stderr,
"%%%%%% Suspending connection, FD: %2llu\n",
(unsigned long long) c->sk.fd);
-#endif /* mhd_DEBUG_SUSPEND_RESUME */
+#endif /* MHD_USE_TRACE_SUSPEND_RESUME */
c->rq.app_act.head_act.act = mhd_ACTION_NO_ACTION;
return false;
#ifdef MHD_SUPPORT_UPGRADE
@@ -3217,11 +3217,11 @@ mhd_stream_process_upload_action (struct MHD_Connection *restrict c,
return false;
case mhd_UPLOAD_ACTION_SUSPEND:
c->suspended = true;
-#ifdef mhd_DEBUG_SUSPEND_RESUME
+#ifdef MHD_USE_TRACE_SUSPEND_RESUME
fprintf (stderr,
"%%%%%% Suspending connection, FD: %2llu\n",
(unsigned long long) c->sk.fd);
-#endif /* mhd_DEBUG_SUSPEND_RESUME */
+#endif /* MHD_USE_TRACE_SUSPEND_RESUME */
memset (&(c->rq.app_act.upl_act), 0, sizeof(c->rq.app_act.upl_act));
return false;
#ifdef MHD_SUPPORT_UPGRADE
diff --git a/src/mhd2/stream_process_states.c b/src/mhd2/stream_process_states.c
@@ -79,9 +79,9 @@
# include "upgrade_proc.h"
#endif /* MHD_SUPPORT_UPGRADE */
-#ifdef mhd_DEBUG_SUSPEND_RESUME
+#ifdef MHD_USE_TRACE_SUSPEND_RESUME
# include <stdio.h>
-#endif /* mhd_DEBUG_SUSPEND_RESUME */
+#endif /* MHD_USE_TRACE_SUSPEND_RESUME */
MHD_INTERNAL MHD_FN_PAR_NONNULL_ALL_ void
mhd_conn_event_loop_state_update (struct MHD_Connection *restrict c)
@@ -266,11 +266,11 @@ finish_resume (struct MHD_Connection *restrict c)
mhd_assert (c->resuming);
c->resuming = false;
-#ifdef mhd_DEBUG_SUSPEND_RESUME
+#ifdef MHD_USE_TRACE_SUSPEND_RESUME
fprintf (stderr,
"%%%%%% Resumed connection, FD: %2llu\n",
(unsigned long long) c->sk.fd);
-#endif /* mhd_DEBUG_SUSPEND_RESUME */
+#endif /* MHD_USE_TRACE_SUSPEND_RESUME */
mhd_assert (! c->suspended);
mhd_assert (MHD_EVENT_LOOP_INFO_PROCESS == c->event_loop_info);
}
@@ -594,11 +594,11 @@ mhd_conn_process_data (struct MHD_Connection *restrict c)
mhd_conn_mark_unready (c, d);
mhd_conn_deinit_activity_timeout (c);
- #ifdef mhd_DEBUG_SUSPEND_RESUME
+ #ifdef MHD_USE_TRACE_SUSPEND_RESUME
fprintf (stderr,
"%%%%%% Connection suspended, FD: %2llu\n",
(unsigned long long) c->sk.fd);
- #endif /* mhd_DEBUG_SUSPEND_RESUME */
+ #endif /* MHD_USE_TRACE_SUSPEND_RESUME */
return true;
}