You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2012/08/01 00:41:05 UTC

svn commit: r1367809 - /activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/AbstractQueuedSynchronizer.cpp

Author: tabish
Date: Tue Jul 31 22:41:04 2012
New Revision: 1367809

URL: http://svn.apache.org/viewvc?rev=1367809&view=rev
Log:
Don't modify the waiters list when not the lock owner because of a Thread interrupt. 

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/AbstractQueuedSynchronizer.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/AbstractQueuedSynchronizer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/AbstractQueuedSynchronizer.cpp?rev=1367809&r1=1367808&r2=1367809&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/AbstractQueuedSynchronizer.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/locks/AbstractQueuedSynchronizer.cpp Tue Jul 31 22:41:04 2012
@@ -1016,7 +1016,9 @@ namespace locks {
             if (impl->acquireQueued(node, savedState) && interruptMode != THROW_IE) {
                 interruptMode = REINTERRUPT;
             }
-            if (node->nextWaiter != NULL) { // clean up if canceled
+            if (node->nextWaiter != NULL && interruptMode == 0) {
+                // clean up if canceled but only if we own the lock otherwise another
+                // thread could already be changing the list.
                 unlinkCancelledWaiters();
             }
             if (interruptMode != 0) {
@@ -1068,7 +1070,9 @@ namespace locks {
             if (impl->acquireQueued(node, savedState) && interruptMode != THROW_IE) {
                 interruptMode = REINTERRUPT;
             }
-            if (node->nextWaiter != NULL) {
+            if (node->nextWaiter != NULL && interruptMode == 0) {
+                // clean up if canceled but only if we own the lock otherwise another
+                // thread could already be changing the list.
                 unlinkCancelledWaiters();
             }
             if (interruptMode != 0) {
@@ -1108,7 +1112,9 @@ namespace locks {
             if (impl->acquireQueued(node, savedState) && interruptMode != THROW_IE) {
                 interruptMode = REINTERRUPT;
             }
-            if (node->nextWaiter != NULL) {
+            if (node->nextWaiter != NULL && interruptMode == 0) {
+                // clean up if canceled but only if we own the lock otherwise another
+                // thread could already be changing the list.
                 unlinkCancelledWaiters();
             }
             if (interruptMode != 0) {
@@ -1142,7 +1148,9 @@ namespace locks {
             if (impl->acquireQueued(node, savedState) && interruptMode != THROW_IE) {
                 interruptMode = REINTERRUPT;
             }
-            if (node->nextWaiter != NULL) {
+            if (node->nextWaiter != NULL && interruptMode == 0) {
+                // clean up if canceled but only if we own the lock otherwise another
+                // thread could already be changing the list.
                 unlinkCancelledWaiters();
             }
             if (interruptMode != 0) {