You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2009/01/20 23:04:22 UTC

svn commit: r736133 - /felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java

Author: rickhall
Date: Tue Jan 20 14:04:22 2009
New Revision: 736133

URL: http://svn.apache.org/viewvc?rev=736133&view=rev
Log:
Only mark a bundle as lock after it is verified it is lockable. (FELIX-891)

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java?rev=736133&r1=736132&r2=736133&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java Tue Jan 20 14:04:22 2009
@@ -3946,10 +3946,12 @@
     {
         synchronized (m_bundleLock)
         {
-            // Wait if any thread has the global lock, unless the current thread
+            // Wait if the desired bundle is already locked by someone else
+            // or if any thread has the global lock, unless the current thread
             // holds the global lock.
-            while ((m_globalLockCount > 0)
-                && !m_lockingThreadMap.containsKey(Thread.currentThread()))
+            while (!bundle.isLockable() ||
+                ((m_globalLockCount > 0)
+                && !m_lockingThreadMap.containsKey(Thread.currentThread())))
             {
                 try
                 {
@@ -3970,18 +3972,7 @@
             counter[0]++;
             m_lockingThreadMap.put(Thread.currentThread(), counter);
 
-            // Wait until the bundle lock is available, then lock it.
-            while (!bundle.isLockable())
-            {
-                try
-                {
-                    m_bundleLock.wait();
-                }
-                catch (InterruptedException ex)
-                {
-                    // Ignore and just keep waiting.
-                }
-            }
+            // Acquire the bundle lock.
             bundle.lock();
         }
     }