You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2012/07/23 23:29:08 UTC

svn commit: r1364805 - in /qpid/trunk/qpid/cpp/src/qpid/broker: Link.cpp LinkRegistry.cpp

Author: aconway
Date: Mon Jul 23 21:29:08 2012
New Revision: 1364805

URL: http://svn.apache.org/viewvc?rev=1364805&view=rev
Log:
QPID-4163: Deadlock between LinkRegistry and TimerTask locks

Previously TimerTask::cancel was being called with locks held in this stack trace, causing a deadlock.

Moved call to cancel outside of the lock.

Modified:
    qpid/trunk/qpid/cpp/src/qpid/broker/Link.cpp
    qpid/trunk/qpid/cpp/src/qpid/broker/LinkRegistry.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/Link.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/Link.cpp?rev=1364805&r1=1364804&r2=1364805&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/Link.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/Link.cpp Mon Jul 23 21:29:08 2012
@@ -249,17 +249,19 @@ void Link::established(Connection* c)
 
     if (!hideManagement() && agent)
         agent->raiseEvent(_qmf::EventBrokerLinkUp(addr.str()));
-
-    Mutex::ScopedLock mutex(lock);
-    setStateLH(STATE_OPERATIONAL);
-    currentInterval = 1;
-    visitCount      = 0;
-    connection = c;
-
-    if (closing)
+    bool isClosing = false;
+    {
+        Mutex::ScopedLock mutex(lock);
+        setStateLH(STATE_OPERATIONAL);
+        currentInterval = 1;
+        visitCount      = 0;
+        connection = c;
+        isClosing = closing;
+    }
+    if (isClosing)
         destroy();
     else // Process any IO tasks bridges added before established.
-        connection->requestIOProcessing (boost::bind(&Link::ioThreadProcessing, this));
+        c->requestIOProcessing (boost::bind(&Link::ioThreadProcessing, this));
 }
 
 

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/LinkRegistry.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/LinkRegistry.cpp?rev=1364805&r1=1364804&r2=1364805&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/LinkRegistry.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/LinkRegistry.cpp Mon Jul 23 21:29:08 2012
@@ -326,13 +326,13 @@ void LinkRegistry::notifyConnection(cons
             if (l->second->pendingConnection(host, port)) {
                 link = l->second;
                 connections[key] = link->getName();
-                link->established(c);
                 break;
             }
         }
     }
 
     if (link) {
+        link->established(c);
         c->setUserId(str(format("%1%@%2%") % link->getUsername() % realm));
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org