From 2892436cd0b008962e4c363257eef51b81b233ba Mon Sep 17 00:00:00 2001
From: Nigel Kukard <nkukard@lbsd.net>
Date: Sun, 12 Jan 2014 21:08:05 +0000
Subject: [PATCH] Better handling of zero sized state file

---
 opentrafficshaper/plugins/configmanager.pm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/opentrafficshaper/plugins/configmanager.pm b/opentrafficshaper/plugins/configmanager.pm
index 0c54759..c4f7da2 100644
--- a/opentrafficshaper/plugins/configmanager.pm
+++ b/opentrafficshaper/plugins/configmanager.pm
@@ -3037,14 +3037,15 @@ sub _override_remove_pool
 # Load our statefile
 sub _load_statefile
 {
-	my $kernel = shift;
-
-
 	# Check if the state file exists first of all
-	if (! -e $config->{'statefile'}) {
+	if (! -f $config->{'statefile'}) {
 		$logger->log(LOG_ERR,"[CONFIGMANAGER] Statefile '%s' doesn't exist",$config->{'statefile'});
 		return;
 	}
+	if (! -s $config->{'statefile'}) {
+		$logger->log(LOG_ERR,"[CONFIGMANAGER] Statefile '%s' has zero size ignoring",$config->{'statefile'});
+		return;
+	}
 
 	$logger->log(LOG_NOTICE,"[CONFIGMANAGER] Loading statefile '%s'",$config->{'statefile'});
 
-- 
GitLab