diff options
author | Simon Rettberg | 2022-09-28 10:55:24 +0200 |
---|---|---|
committer | Simon Rettberg | 2022-09-28 10:55:24 +0200 |
commit | a41f213668308b0510a74948694535a51605180d (patch) | |
tree | 02dc112917aa006054c911eb81147b9c7370bfa6 | |
parent | Revert "[inc/main] one more syntax err. corr. -ADD main/install.inc.php" (diff) | |
download | slx-admin-a41f213668308b0510a74948694535a51605180d.tar.gz slx-admin-a41f213668308b0510a74948694535a51605180d.tar.xz slx-admin-a41f213668308b0510a74948694535a51605180d.zip |
[statistics] Prevent out-of-order event handling
-rw-r--r-- | modules-available/statistics/api.inc.php | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/modules-available/statistics/api.inc.php b/modules-available/statistics/api.inc.php index 88b27d86..6f4917b0 100644 --- a/modules-available/statistics/api.inc.php +++ b/modules-available/statistics/api.inc.php @@ -220,6 +220,10 @@ if ($type[0] === '~') { 'oldlastseen' => $old['lastseen'], 'oldstate' => $old['state'], ); + if ($NOW - $old['lastseen'] < 10 && ($old['state'] === 'OFFLINE' || $old['state'] === 'STANDBY')) { + // Avoid racing calls to ~runstate updates while/after we send a ~poweroff or ~suspend + die("OK.\n"); + } if ($old['state'] === 'OFFLINE') { // This should never happen -- we expect a poweron event before runstate, which would set the state to IDLE // So it might be that the poweron event got lost, or that a couple of runstate events got lost, which |