mirror of
https://github.com/Cacti/cacti.git
synced 2026-10-29 16:17:14 +09:00
* Serialize process registry admission with Symfony Lock Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * Fix PDO process lock mode handling Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * ci: run process lock coverage on PHP 8.2 Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * fix: confirm a pid is still ours before signalling it #7574 added the still-running guard to dsstats but left six byte-identical siblings signalling a pid straight out of the processes table. After a crash or a power loss the row survives, the pid is recycled by an unrelated daemon, and the next start SIGTERMs a stranger. That is issue #7425, still live in rrdcheck, boost, poller_commands, float_rrdfiles, poller_reindex_hosts and rebuild_poller_cache. Wrap each kill in cacti_process_still_running(), matching the dsstats shape, and leave unregister_process() outside the guard so a stale row is still cleaned up. Cover all seven with a test that walks every kill site, so a new variant cannot reintroduce it. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * test: assert the guard plainly toContain() takes needles rather than a failure message, so the file name was being asserted as a second required substring and the test always failed. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> * docs(poller): describe required lock parameters --------- Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
45 lines
1.5 KiB
PHP
45 lines
1.5 KiB
PHP
<?php
|
|
/*
|
|
+-------------------------------------------------------------------------+
|
|
| Copyright (C) 2004-2026 The Cacti Group |
|
|
+-------------------------------------------------------------------------+
|
|
| Cacti: The Complete RRDtool-based Graphing Solution |
|
|
+-------------------------------------------------------------------------+
|
|
*/
|
|
|
|
// A pid read from the processes table may have been recycled by an unrelated
|
|
// process after a crash, so every kill_running_processes() variant has to
|
|
// confirm the pid is still ours before signalling it (issue #7425).
|
|
test('every kill_running_processes signals only a process confirmed still running', function () {
|
|
$root = dirname(__DIR__, 3);
|
|
|
|
$files = [
|
|
'/lib/dsstats.php',
|
|
'/lib/rrdcheck.php',
|
|
'/poller_boost.php',
|
|
'/poller_commands.php',
|
|
'/cli/float_rrdfiles.php',
|
|
'/cli/poller_reindex_hosts.php',
|
|
'/cli/rebuild_poller_cache.php',
|
|
];
|
|
|
|
foreach ($files as $file) {
|
|
$source = file_get_contents($root . $file);
|
|
|
|
expect($source)->not->toBeFalse();
|
|
|
|
$offset = 0;
|
|
|
|
while (($at = strpos($source, "posix_kill(\$p['pid'], SIGTERM)", $offset)) !== false) {
|
|
$preceding = substr($source, max(0, $at - 400), min(400, $at));
|
|
|
|
// toContain() takes needles, not a message, so assert plainly and
|
|
// name the file through the surrounding loop instead.
|
|
expect(str_contains($preceding, 'cacti_process_still_running'))
|
|
->toBeTrue();
|
|
|
|
$offset = $at + 1;
|
|
}
|
|
}
|
|
});
|