From 4fb780d11a3498f2ff738deea44cdd486a1d79ee Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Mon, 23 Aug 2010 14:15:46 +0200
Subject: [PATCH] locking.LockSet: Use function to get member lock name

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/locking.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/locking.py b/lib/locking.py
index 59ab7db47..8793fae13 100644
--- a/lib/locking.py
+++ b/lib/locking.py
@@ -731,7 +731,7 @@ class LockSet:
     self.__lockdict = {}
 
     for mname in members:
-      self.__lockdict[mname] = SharedLock("%s/%s" % (name, mname))
+      self.__lockdict[mname] = SharedLock(self._GetLockName(mname))
 
     # The owner dict contains the set of locks each thread owns. For
     # performance each thread can access its own key without a global lock on
@@ -742,6 +742,12 @@ class LockSet:
     # will be trouble.
     self.__owners = {}
 
+  def _GetLockName(self, mname):
+    """Returns the name for a member lock.
+
+    """
+    return "%s/%s" % (self.name, mname)
+
   def _is_owned(self):
     """Is the current thread a current level owner?"""
     return threading.currentThread() in self.__owners
@@ -1049,7 +1055,7 @@ class LockSet:
                                (invalid_names, self.name))
 
       for lockname in names:
-        lock = SharedLock("%s/%s" % (self.name, lockname))
+        lock = SharedLock(self._GetLockName(lockname))
 
         if acquired:
           lock.acquire(shared=shared)
-- 
GitLab