Change in vdsm[master]: supervdsm: Fix race regarding instance ident

smizrahi at redhat.com smizrahi at redhat.com
Tue Feb 5 18:47:14 UTC 2013


Saggi Mizrahi has uploaded a new change for review.

Change subject: supervdsm: Fix race regarding instance ident
......................................................................

supervdsm: Fix race regarding instance ident

- Move typeid registration to module initialization as it is a class
  level operation
- Change callMethod() from lambda to a method and make expression
  evaluation make sense and understandable. Lambdas are tricky :)
- Don't cache svdsm instance BaseManager does weird incref\decref and
  indexes the transient instances by their `id(proxyObj)`. Lets just use
  it's cache and avoid cache coherency issues.

Change-Id: I4f548cb9ad805508cf75df691e0ab58b3278dc87
Signed-off-by: Saggi Mizrahi <smizrahi at redhat.com>
---
M vdsm/supervdsm.py
1 file changed, 15 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/59/11759/1

diff --git a/vdsm/supervdsm.py b/vdsm/supervdsm.py
index 10abae0..fd641ab 100644
--- a/vdsm/supervdsm.py
+++ b/vdsm/supervdsm.py
@@ -59,6 +59,9 @@
 class _SuperVdsmManager(BaseManager):
     pass
 
+_SuperVdsmManager.register('instance')
+_SuperVdsmManager.register('open')
+
 
 class ProxyCaller(object):
 
@@ -67,9 +70,11 @@
         self._supervdsmProxy = supervdsmProxy
 
     def __call__(self, *args, **kwargs):
-        callMethod = lambda: \
-            getattr(self._supervdsmProxy._svdsm, self._funcName)(*args,
-                                                                 **kwargs)
+        def callMethod():
+            instance = self._supervdsmProxy.getInstance()
+            method = getattr(instance, self._funcName)
+            return method(*args, **kwargs)
+
         if not self._supervdsmProxy.isRunning():
             # getting inside only when svdsm is down. its rare case so we
             # don't care that isRunning will run twice
@@ -144,11 +149,10 @@
         self._cleanOldFiles()
         self._authkey = None
         self._manager = None
-        self._svdsm = None
         self._firstLaunch = True
 
     def isRunning(self):
-        if self._firstLaunch or self._svdsm is None:
+        if self._firstLaunch or self.getInstance() is None:
             return False
 
         try:
@@ -181,15 +185,18 @@
     def _connect(self):
         self._manager = _SuperVdsmManager(address=self.address,
                                           authkey=self._authkey)
-        self._manager.register('instance')
-        self._manager.register('open')
         self._log.debug("Trying to connect to Super Vdsm")
         try:
             self._manager.connect()
         except Exception as ex:
             self._log.warn("Connect to svdsm failed %s", ex)
             raise
-        self._svdsm = self._manager.instance()
+
+    def getInstance(self):
+        try:
+            return self._manager.instance()
+        except:
+            return None
 
     def launch(self):
         self._firstLaunch = False


--
To view, visit http://gerrit.ovirt.org/11759
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4f548cb9ad805508cf75df691e0ab58b3278dc87
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi at redhat.com>


More information about the vdsm-patches mailing list