libmicrohttpd2

HTTP server C library (MHD 2.x, alpha)
Log | Files | Refs | README | LICENSE

commit 5540b4ef4df6d8a2905f12c3cf17c51937015749
parent b4f5a1cb8db43c3df5bb351fef48a108428e64d0
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date:   Fri, 26 Dec 2025 11:49:12 +0100

Connection timeouts: added flag "in custom timeouts list"

Diffstat:
Msrc/mhd2/conn_timeout.c | 24++++++++++++++++++++++--
Msrc/mhd2/mhd_connection.h | 7+++++++
2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/src/mhd2/conn_timeout.c b/src/mhd2/conn_timeout.c @@ -115,6 +115,7 @@ mhd_conn_init_activity_timeout (struct MHD_Connection *restrict c, #endif /* MHD_SUPPORT_THREADS */ mhd_assert (! c->suspended); + mhd_assert (! c->timeout.in_cstm_tmout_list); c->timeout.milsec = timeout; @@ -127,13 +128,18 @@ mhd_conn_init_activity_timeout (struct MHD_Connection *restrict c, return; if (timeout == d->conns.cfg.timeout_milsec) + { mhd_DLINKEDL_INS_FIRST_D (&(d->conns.def_timeout), c, timeout.tmout_list); + } else + { mhd_DLINKEDL_INS_FIRST_D (&(d->conns.cust_timeout), c, timeout.tmout_list); + c->timeout.in_cstm_tmout_list = true; + } } @@ -148,12 +154,18 @@ mhd_conn_deinit_activity_timeout (struct MHD_Connection *restrict c) #endif /* MHD_SUPPORT_THREADS */ if (0u == c->timeout.milsec) + { + mhd_assert (! c->timeout.in_cstm_tmout_list); return; + } if (mhd_D_HAS_THR_PER_CONN (d)) + { + mhd_assert (! c->timeout.in_cstm_tmout_list); return; + } - if (c->timeout.milsec == d->conns.cfg.timeout_milsec) + if (! c->timeout.in_cstm_tmout_list) mhd_DLINKEDL_DEL_D (&(d->conns.def_timeout), c, timeout.tmout_list); @@ -161,6 +173,8 @@ mhd_conn_deinit_activity_timeout (struct MHD_Connection *restrict c) mhd_DLINKEDL_DEL_D (&(d->conns.cust_timeout), \ c, timeout.tmout_list); + + c->timeout.in_cstm_tmout_list = false; } @@ -175,13 +189,19 @@ mhd_conn_update_activity_mark (struct MHD_Connection *restrict c) mhd_assert (! c->suspended); if (0u == c->timeout.milsec) + { + mhd_assert (! c->timeout.in_cstm_tmout_list); return; + } c->timeout.last_act = mhd_monotonic_msec_counter (); // TODO: Get and use time value one time per round if (mhd_D_HAS_THR_PER_CONN (d)) + { + mhd_assert (! c->timeout.in_cstm_tmout_list); return; /* each connection has personal timeout */ + } - if (c->timeout.milsec != d->conns.cfg.timeout_milsec) + if (c->timeout.in_cstm_tmout_list) return; /* custom timeout, no need to move it in "normal" DLL */ /* move connection to head of timeout list (by remove + add operation) */ diff --git a/src/mhd2/mhd_connection.h b/src/mhd2/mhd_connection.h @@ -567,6 +567,13 @@ struct mhd_ConnTimeoutData * The list of connections sorted by timeout */ mhd_DLNKDL_LINKS (MHD_Connection,tmout_list); + + /** + * Set to 'true' if this connection is in daemon's 'custom timeout list'. + * 'false' if connection is not in this list, including situation when + * connection is out of any daemon's timeouts lists. + */ + bool in_cstm_tmout_list; }; struct mhd_ConnDebugData