commit b8a83b2737ee54a22934b15e3001a759d8ed3aae
parent 3e54ac543e934ce2f0b024eb98f2a172a29c5cdf
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date: Fri, 26 Dec 2025 13:58:37 +0100
Connection timeouts: do not shuffle list when nothing to update
Diffstat:
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/mhd2/conn_data_recv.c b/src/mhd2/conn_data_recv.c
@@ -126,7 +126,7 @@ mhd_conn_data_recv (struct MHD_Connection *c,
c->sk.state.rmt_shut_wr = true;
c->read_buffer_offset += received;
- mhd_conn_update_activity_mark (c); // TODO: centralise activity update
+ mhd_conn_update_activity_mark (c);
return;
}
diff --git a/src/mhd2/conn_data_send.c b/src/mhd2/conn_data_send.c
@@ -408,7 +408,7 @@ mhd_conn_data_send (struct MHD_Connection *c)
if (mhd_SOCKET_ERR_NO_ERROR == res)
{
- mhd_conn_update_activity_mark (c); // TODO: centralise activity mark updates
+ mhd_conn_update_activity_mark (c);
}
else if (mhd_SOCKET_ERR_IS_HARD (res))
{
diff --git a/src/mhd2/conn_timeout.c b/src/mhd2/conn_timeout.c
@@ -182,6 +182,8 @@ MHD_INTERNAL MHD_FN_PAR_NONNULL_ALL_ void
mhd_conn_update_activity_mark (struct MHD_Connection *restrict c)
{
struct MHD_Daemon *const restrict d = c->daemon;
+ uint_fast64_t prev_mark;
+
#if defined(MHD_SUPPORT_THREADS)
mhd_assert (! mhd_D_HAS_WORKERS (d));
#endif /* MHD_SUPPORT_THREADS */
@@ -194,7 +196,12 @@ mhd_conn_update_activity_mark (struct MHD_Connection *restrict c)
return;
}
+ prev_mark = c->timeout.last_act;
c->timeout.last_act = mhd_daemon_get_milsec_counter (d);
+
+ if (c->timeout.last_act == prev_mark)
+ return; /* Nothing to update */
+
if (mhd_D_HAS_THR_PER_CONN (d))
{
mhd_assert (! c->timeout.in_cstm_tmout_list);