From: Willy Tarreau Date: Tue, 20 May 2025 14:19:50 +0000 (+0200) Subject: CLEANUP: wdt: clarify the comments on the common exit path X-Git-Tag: v3.2-dev17~16 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=3b2fb5cc15244e2b87224a470d964ec270e4f972;p=thirdparty%2Fhaproxy.git CLEANUP: wdt: clarify the comments on the common exit path The condition in which we reach the check for ha_panic() and ha_stuck_warning() are not super clear, let's reformulate them. --- diff --git a/src/wdt.c b/src/wdt.c index d52fded05..f1159b000 100644 --- a/src/wdt.c +++ b/src/wdt.c @@ -175,11 +175,16 @@ void wdt_handler(int sig, siginfo_t *si, void *arg) } #endif - /* Now the interesting things begin. The timer was at least as large - * as the warning threshold. If the stuck bit was set, we must now - * panic. Otherwise we're checking if we're still context-switching - * or not and we'll either warn if not, or just update the ctxsw - * counter to check next time. + /* Now the interesting things begin. We're on the thread of interest. + * Its timer was at least as large as the warning threshold since poll + * was left. If it was at least as high as the panic threshold, we also + * have TH_FL_STUCK, which now proves that nothing is happening since + * the scheduler clears it for each task. We can still recheck whether + * the scheduler looks alive and get away with all of this if we've got + * a proof that it's making forward progress. If stuck, we have to die, + * otherwise we just send a warning. In short, is_sched_alive() serves + * as a ping to detect the warning condition while TH_FL_STUCK works + * the same but for a panic condition. */ if (_HA_ATOMIC_LOAD(&th_ctx->flags) & TH_FL_STUCK) ha_panic();