direct-io.hg

changeset 6707:d0b3c7061368

Always start transactions on an existing path.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Fri Sep 09 16:06:04 2005 +0000 (2005-09-09)
parents 47dca2f335de
children fbdb56cd611b
files tools/python/xen/xend/xenstore/xstransact.py
line diff
     1.1 --- a/tools/python/xen/xend/xenstore/xstransact.py	Fri Sep 09 13:20:51 2005 +0000
     1.2 +++ b/tools/python/xen/xend/xenstore/xstransact.py	Fri Sep 09 16:06:04 2005 +0000
     1.3 @@ -4,6 +4,7 @@
     1.4  # Public License.  See the file "COPYING" in the main directory of
     1.5  # this archive for more details.
     1.6  
     1.7 +import errno
     1.8  import threading
     1.9  from xen.lowlevel import xs
    1.10  
    1.11 @@ -18,9 +19,18 @@ def xshandle():
    1.12  class xstransact:
    1.13  
    1.14      def __init__(self, path):
    1.15 +        self.in_transaction = False
    1.16          self.path = path.rstrip("/")
    1.17 -        xshandle().transaction_start(path)
    1.18 -        self.in_transaction = True
    1.19 +        while True:
    1.20 +            try:
    1.21 +                xshandle().transaction_start(path)
    1.22 +                self.in_transaction = True
    1.23 +                return
    1.24 +            except RuntimeError, ex:
    1.25 +                if ex.args[0] == errno.ENOENT and path != "/":
    1.26 +                    path = "/".join(path.split("/")[0:-1]) or "/"
    1.27 +                else:
    1.28 +                    raise
    1.29  
    1.30      def __del__(self):
    1.31          if self.in_transaction: