From 4160ac7115f4ba20e58f898c98074ce5d3e5dd75 Mon Sep 17 00:00:00 2001 From: Mark Harrison <mark@mivok.net> Date: Wed, 12 Dec 2012 11:46:58 -0500 Subject: [PATCH] Don't store blank data if we fail to get anything from the shared state file Occasionally on some systems, the data returned from the shared state file is bad/blank, despite locking. Ideally we'd find the cause of this and fix it, but various attempts haven't identified exactly why this happens (including running fsync after writing and before unlocking). If the data returned is blank, we should use the latest available data rather than returning blank data to the user/monitoring system. --- lib/Resmon/Status.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Resmon/Status.pm b/lib/Resmon/Status.pm index 19b6c20..e99b8ad 100644 --- a/lib/Resmon/Status.pm +++ b/lib/Resmon/Status.pm @@ -42,9 +42,11 @@ sub get_shared_state { $blob = <$fh>; } flock($fh, LOCK_UN); # Release the lock - eval $blob; - die $@ if ($@); - $self->{store} = $VAR1; + if (defined $blob) { + eval $blob; + die $@ if ($@); + $self->{store} = $VAR1; + } } else { die "Unable to read shared state"; }; -- GitLab