From 082c55fb9cf87263f1f585a1adeda464a9d7328a Mon Sep 17 00:00:00 2001 From: David Kupka Date: Mon, 16 Mar 2015 08:05:59 -0400 Subject: Always reload StateFile before getting or modifying the stored values. This change does not solve using multiple instances of StateFile concurently because there is no use for it in near future. Instead this solves an issue of loosing records when more instances of StateFile are interleaved in sequential code. https://fedorahosted.org/freeipa/ticket/4901 Reviewed-By: Martin Basti --- ipapython/sysrestore.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'ipapython') diff --git a/ipapython/sysrestore.py b/ipapython/sysrestore.py index 6db33a7ef..580df9a4f 100644 --- a/ipapython/sysrestore.py +++ b/ipapython/sysrestore.py @@ -283,8 +283,11 @@ class FileStore: class StateFile: """A metadata file for recording system state which can - be backed up and later restored. The format is something - like: + be backed up and later restored. + StateFile gets reloaded every time to prevent loss of information + recorded by child processes. But we do not solve concurrency + because there is no need for it right now. + The format is something like: [httpd] running=True @@ -363,6 +366,8 @@ class StateFile: if not isinstance(value, (str, bool, unicode)): raise ValueError("Only strings, booleans or unicode strings are supported") + self._load() + if not self.modules.has_key(module): self.modules[module] = {} @@ -378,6 +383,8 @@ class StateFile: If the item doesn't exist, #None will be returned, otherwise the original string or boolean value is returned. """ + self._load() + if not self.modules.has_key(module): return None @@ -389,6 +396,8 @@ class StateFile: If the item doesn't exist, no change is done. """ + self._load() + try: del self.modules[module][key] except KeyError: -- cgit