summaryrefslogtreecommitdiffstats
path: root/ipapython
diff options
context:
space:
mode:
authorDavid Kupka <dkupka@redhat.com>2015-03-16 08:05:59 -0400
committerTomas Babej <tbabej@redhat.com>2015-03-18 12:42:16 +0100
commit082c55fb9cf87263f1f585a1adeda464a9d7328a (patch)
treee6997a61f5aa7052d14716f1d2d7a178cc0855d6 /ipapython
parent26d6c6fbbbd6d024d82b1ab515d300e6113d2c34 (diff)
downloadfreeipa-082c55fb9cf87263f1f585a1adeda464a9d7328a.tar.gz
freeipa-082c55fb9cf87263f1f585a1adeda464a9d7328a.tar.xz
freeipa-082c55fb9cf87263f1f585a1adeda464a9d7328a.zip
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 <mbasti@redhat.com>
Diffstat (limited to 'ipapython')
-rw-r--r--ipapython/sysrestore.py13
1 files changed, 11 insertions, 2 deletions
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: