Module: check_mk
Branch: master
Commit: 339106bf7f1157a41f701d7a2aea037934336ea4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=339106bf7f1157…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri May 25 09:14:57 2012 +0200
WATO: implement locking for alle write processes
---
ChangeLog | 2 ++
web/htdocs/index.py | 2 ++
web/htdocs/lib.py | 2 +-
web/htdocs/wato.py | 9 +++++++++
4 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6effb00..55fba84 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,6 +16,8 @@
* FIX: D/WATO: mark site dirty after host deletion
* FIX: D/WATO: replicate auth.secret, so that login on one site also
is valid on the replication slaves
+ * FIX: implement locking in order to prevent data corruption on
+ concurrent changes
Multisite:
* New display type 'boxes-omit-root' for BI views
diff --git a/web/htdocs/index.py b/web/htdocs/index.py
index 26e991e..83adfbd 100644
--- a/web/htdocs/index.py
+++ b/web/htdocs/index.py
@@ -379,6 +379,8 @@ def handler(req, profiling = True):
response_code = apache.HTTP_BAD_GATEWAY
except apache.SERVER_RETURN:
+ release_all_locks()
+ html.live = None
raise
except Exception, e:
diff --git a/web/htdocs/lib.py b/web/htdocs/lib.py
index fa5a58f..f1298fc 100644
--- a/web/htdocs/lib.py
+++ b/web/htdocs/lib.py
@@ -238,7 +238,7 @@ def aquire_lock(path):
g_locked_paths.append(path)
def release_all_locks():
- global g_aquired_locks
+ global g_aquired_locks, g_locked_paths
for fd in g_aquired_locks:
os.close(fd)
g_aquired_locks = []
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index a602e75..3d0d2fc 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -214,6 +214,11 @@ def page_handler():
current_mode = html.var("mode") or "main"
+ # If we do an action, we aquire an exclusive lock on the complete
+ # WATO.
+ if html.is_transaction():
+ lock_exclusive()
+
try:
# Make information about current folder and hosts available
# To be able to perform a "factory reset" or a snapshot restore
@@ -378,6 +383,10 @@ def need_sidebar_reload():
global g_need_sidebar_reload
g_need_sidebar_reload = id(html)
+def lock_exclusive():
+ aquire_lock(defaults.default_config_dir + "/multisite.mk")
+
+
#.
# .-Load/Save------------------------------------------------------------.
# | _ _ ______ |