Browse Source
Kernel watchdog: feed from its own thread while the kernel loop makes progress
Kernel watchdog: feed from its own thread while the kernel loop makes progress
watchDogDaemon kills a client that misses its deadline (signal 9). The
mojo kernel loop sent "4000" (next update within 4 s) at the start of each
pass and then ran all validations in the same thread. A pass of about
3 s killed la_mojo, for example a gateway connect (5 s), rm -rf of a
report day, or a synchronous systemctl restart of MediaMTX.
kernelPrototype
- A feeder thread (wdStart) sends KERNEL_WD_FEED_MS (4 s) every second
while the kernel loop reports progress (wdStep). A loop without progress
for KERNEL_WD_STALL_MS (60 s) is a hang: the feeding stops, logged as
"Kernel loop stalled in '<step>' for N s - watchdog no longer fed", and
the daemon kills the process as before.
- wdStep() logs steps slower than 1 s ("Kernel step '<step>' took N
ms"). The feeder logs a step that runs longer than 5 s every 5 s
("Kernel loop busy in '<step>' for N s"), so the step is named before
any kill.
- wdExtend(): stops feeding and grants a one-time deadline.
- send(MSG_NOSIGNAL) instead of write(): a watchDogDaemon that restarted
closed the socket, and the next write() killed la_mojo with SIGPIPE.
A lost connection is logged and closed.
- The socket is closed when connect() fails (it leaked).
- The feeder is opt-in: servaKernel is unchanged.
mojoKernel
- The loop calls wdStart() and names each step: debug mode, filters,
session, reports, hardwareManager::validate, updateSysInfo, media
helper, remote server, kernel commands, cleanNodePushedCMD.
- ~mojoKernel grants KERNEL_WD_SHUTDOWN_MS (120 s) before deleting the
factories / nodes / threads. Before, the 4 s of the last feed ran out
and the daemon killed la_mojo in the middle of a reload / restart /
exit. "-1" at the end goes through wdSend().
Tested with the real watchDogDaemon and a test kernel built on
kernelPrototype (stall limit 8 s for the test):
- old behaviour, one 6 s step: killed (137);
- new, normal passes: runs to the end;
- new, one 6 s step: not killed; logs "busy ... 5 s" and "took 6000 ms";
- new, a step that hangs: logs "stalled in '<step>'", then killed (137).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
pull/26/head
Failed to extract signature
3 changed files with 203 additions and 19 deletions
-
144lib/App/common/kernelPrototype.cpp
-
37lib/App/common/kernelPrototype.h
-
41lib/App/mojo/mojoKernel.cpp
Write
Preview
Loading…
Cancel
Save
Reference in new issue