BUG/MEDIUM: applet: Fix conditions to detect spinning loop with the new API

There was a mixup between read/send events and ability for an applet to
receive and send. The fix seems obvious by reading it. The call-rate must be
incremented when nothing was received from the applet while it was allowed
and nothing was sent to the applet while it was allowed.

This patch must be backported as far as 3.0.
This commit is contained in:
Christopher Faulet 2025-11-21 09:41:03 +01:00
parent 4cbff2cad9
commit dfdccbd2af

View File

@ -978,7 +978,7 @@ struct task *task_process_applet(struct task *t, void *context, unsigned int sta
} }
/* measure the call rate and check for anomalies when too high */ /* measure the call rate and check for anomalies when too high */
if ((!did_recv && sc_is_send_allowed(sc)) && (!did_send && sc_is_recv_allowed(sc))) { if ((!did_send && sc_is_send_allowed(sc)) && (!did_recv && sc_is_recv_allowed(sc))) {
rate = update_freq_ctr(&app->call_rate, 1); rate = update_freq_ctr(&app->call_rate, 1);
if (rate >= 100000 && app->call_rate.prev_ctr) // looped like this more than 100k times over last second if (rate >= 100000 && app->call_rate.prev_ctr) // looped like this more than 100k times over last second
stream_dump_and_crash(&app->obj_type, read_freq_ctr(&app->call_rate)); stream_dump_and_crash(&app->obj_type, read_freq_ctr(&app->call_rate));