debuggers.hg
diff tools/python/xen/xend/xenstore/xstransact.py @ 16702:9fe92a88912b
Fix xend xenstore handling.
xend can get into a situation where two processes are attempting to
interact with the xenstore socket, with disastrous results. Fix the
two bad users of xstransact, add a big warning, and fix the destructor
so future mistakes will be detected earlier.
Signed-off-by: John Levon <john.levon@sun.com>
xend can get into a situation where two processes are attempting to
interact with the xenstore socket, with disastrous results. Fix the
two bad users of xstransact, add a big warning, and fix the destructor
so future mistakes will be detected earlier.
Signed-off-by: John Levon <john.levon@sun.com>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Thu Dec 27 12:27:34 2007 +0000 (2007-12-27) |
parents | 1b501311c778 |
children |
line diff
1.1 --- a/tools/python/xen/xend/xenstore/xstransact.py Thu Dec 27 12:03:02 2007 +0000 1.2 +++ b/tools/python/xen/xend/xenstore/xstransact.py Thu Dec 27 12:27:34 2007 +0000 1.3 @@ -7,8 +7,16 @@ 1.4 1.5 from xen.xend.xenstore.xsutil import xshandle 1.6 1.7 +class xstransact: 1.8 + """WARNING: Be very careful if you're instantiating an xstransact object 1.9 + yourself (i.e. not using the capitalized static helpers like .Read(). 1.10 + It is essential that you clean up the object in place via 1.11 + t.commit/abort(): GC can happen at any time, including contexts where 1.12 + it's not safe to to use the shared xenstore socket fd. In particular, 1.13 + if xend forks, and GC occurs, we can have two processes trying to 1.14 + use the same xenstore fd, and all hell breaks loose. 1.15 + """ 1.16 1.17 -class xstransact: 1.18 1.19 def __init__(self, path = ""): 1.20 1.21 @@ -22,8 +30,9 @@ class xstransact: 1.22 self.in_transaction = True 1.23 1.24 def __del__(self): 1.25 + # see above. 1.26 if self.in_transaction: 1.27 - xshandle().transaction_end(self.transaction, True) 1.28 + raise RuntimeError("ERROR: GC of live transaction") 1.29 1.30 def commit(self): 1.31 if not self.in_transaction: