Change in vdsm[master]: misc: Fix RWLock leak due to reference cycle

nsoffer at redhat.com nsoffer at redhat.com
Thu Jan 14 17:21:25 UTC 2016


Nir Soffer has uploaded a new change for review.

Change subject: misc: Fix RWLock leak due to reference cycle
......................................................................

misc: Fix RWLock leak due to reference cycle

RWLock shared and exclusive context managers had a reference cycle; the
context manager reference the RWLock, and the RWLock reference the
context manager. Python garbage collections can easly handle such
cycles, but not if one of the objects in this cycle is implementing
__del__, making the entire graph uncollectible. RWLock holds a reference
to a pthreading.RLock, inheriting from pthread.Mutex, implementing
__del__.

This patch changes RWLock.shared and RWLock.exclusive to properties
returning a new context manager on each access, avoiding the reference
cycle.

This change eliminates leak of pthreading.Lock and pthread.Cond growing
constantly as vdsm run.

Change-Id: Iecd4967ad037b81618e00996caec150296da541f
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M vdsm/storage/misc.py
1 file changed, 7 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/68/51868/1

diff --git a/vdsm/storage/misc.py b/vdsm/storage/misc.py
index f9b3865..2a4f1c3 100644
--- a/vdsm/storage/misc.py
+++ b/vdsm/storage/misc.py
@@ -532,8 +532,13 @@
         self._currentState = None
         self._holdingThreads = {}
 
-        self.shared = self._contextLock(self, False)
-        self.exclusive = self._contextLock(self, True)
+    @property
+    def shared(self):
+        return self._contextLock(self, False)
+
+    @property
+    def exclusive(self):
+        return self._contextLock(self, True)
 
     def acquireRead(self):
         return self.acquire(False)


-- 
To view, visit https://gerrit.ovirt.org/51868
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iecd4967ad037b81618e00996caec150296da541f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list