Only unlock config if we did lock it
authorKlaus Aehlig <aehlig@google.com>
Mon, 3 Nov 2014 19:27:45 +0000 (20:27 +0100)
committerKlaus Aehlig <aehlig@google.com>
Tue, 5 May 2015 14:07:59 +0000 (16:07 +0200)
We only acquired a config lock if it was not shared in order
to have lock-free reads. Hence, only release the config lock
if we actually acquired it.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Niklas Hambuechen <niklash@google.com>

Cherry-picked-from: 35056743
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Hrvoje Ribicic <riba@google.com>

lib/config.py

index af0e650..da0a007 100644 (file)
@@ -2844,7 +2844,7 @@ class ConfigWriter(object):
       logging.critical("Can't write the configuration: %s", str(err))
       raise
     finally:
-      if not self._offline:
+      if not self._offline and not self._lock_current_shared:
         try:
           self._wconfd.UnlockConfig(self._GetWConfdContext())
         except AttributeError: