imip-agent

Changeset

1021:a04c967b2d8e
2015-11-06 Paul Boddie raw files shortlog changelog graph Removed the complicated "old" lock directory mechanism since the active lock directory should be protected by the "outside-in" attempts to create it while the dismantling operation occurs "inside-out". rel-0-1
imiptools/filesys.py (file)
     1.1 --- a/imiptools/filesys.py	Fri Nov 06 18:34:33 2015 +0100
     1.2 +++ b/imiptools/filesys.py	Fri Nov 06 18:41:26 2015 +0100
     1.3 @@ -82,7 +82,6 @@
     1.4      "Basic filesystem operations."
     1.5  
     1.6      lock_name = "__lock__"
     1.7 -    old_lock_name = "__unlock__"
     1.8  
     1.9      def __init__(self, store_dir):
    1.10          self.store_dir = abspath(store_dir)
    1.11 @@ -170,26 +169,12 @@
    1.12          "Remove the lock directory defined by the given 'parts'."
    1.13  
    1.14          parts = parts and list(parts) or []
    1.15 -        target = parts[:]
    1.16 -
    1.17 -        # Move the directory to a unique name. This prevents unlikely but
    1.18 -        # possible conflicts as a slow unlocking process is caught up by a
    1.19 -        # following, faster locking-then-unlocking process which would then
    1.20 -        # try and rename the active lock directory to a common old lock
    1.21 -        # directory name, causing a "directory not empty" exception and the
    1.22 -        # continued existence of the lock.
    1.23  
    1.24          parts.append(self.lock_name)
    1.25 -        old_lock_name = "%s.%d" % (self.old_lock_name, getpid())
    1.26 -        target.append(old_lock_name)
    1.27 -        rename(self.get_object_in_store(*parts), self.get_object_in_store(*target))
    1.28 -
    1.29 -        # Then remove the moved directory and its contents.
    1.30 -
    1.31 -        target.append(str(getpid()))
    1.32 -        rmdir(self.get_object_in_store(*target))
    1.33 -        target.pop()
    1.34 -        rmdir(self.get_object_in_store(*target))
    1.35 +        parts.append(str(getpid()))
    1.36 +        rmdir(self.get_object_in_store(*parts))
    1.37 +        parts.pop()
    1.38 +        rmdir(self.get_object_in_store(*parts))
    1.39  
    1.40      def owning_lock_dir(self, *parts):
    1.41