commit 2ce755c491920eee5a28d314b42ddcca3f4cdca6
parent 9c46ac5e7d4b9d3072049d92795c8ae6a52b206e
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date: Sat, 28 Feb 2026 17:16:46 +0100
Fixed optimisation used for select() processing
Diffstat:
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/mhd2/events_process.c b/src/mhd2/events_process.c
@@ -1091,6 +1091,10 @@ select_update_statuses_from_fdsets_and_resume_conn (struct MHD_Daemon *d,
d->net.listen.is_broken = true;
/* Stop monitoring socket to avoid spinning with busy-waiting */
d->net.listen.fd = MHD_INVALID_SOCKET;
+#ifndef MHD_FAVOR_SMALL_CODE
+ if (FD_ISSET (d->net.listen.fd, rfds))
+ --num_events;
+#endif /* MHD_FAVOR_SMALL_CODE */
}
else
{
@@ -1135,15 +1139,14 @@ select_update_statuses_from_fdsets_and_resume_conn (struct MHD_Daemon *d,
send_ready,
err_state);
#ifndef MHD_FAVOR_SMALL_CODE
- if (recv_ready || send_ready || err_state)
- --num_events;
+ num_events -=
+ (recv_ready ? 1 : 0) + (send_ready ? 1 : 0) + (err_state ? 1 : 0);
#endif /* MHD_FAVOR_SMALL_CODE */
}
}
#ifndef MHD_FAVOR_SMALL_CODE
- // TODO: recheck functionality with HTTP/2
- // mhd_assert ((0 == num_events) || resuming_conn);
+ mhd_assert ((0 == num_events) || resuming_conn);
#endif /* MHD_FAVOR_SMALL_CODE */
return true;
}