summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2012-07-24 13:33:40 +0000
committerAlan Conway <aconway@apache.org>2012-07-24 13:33:40 +0000
commit6056bae55c25c6ecdbc6ca58fc9a5ae7d0d74a48 (patch)
tree9d0679f107394021ba6250cf71e4845df3a1506a
parent5b452196ca1f8fcbc3dd220758db5a6e2aa2e4ad (diff)
downloadqpid-python-6056bae55c25c6ecdbc6ca58fc9a5ae7d0d74a48.tar.gz
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. git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/0.18@1365045 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/src/qpid/broker/Link.cpp20
-rw-r--r--qpid/cpp/src/qpid/broker/LinkRegistry.cpp2
2 files changed, 12 insertions, 10 deletions
diff --git a/qpid/cpp/src/qpid/broker/Link.cpp b/qpid/cpp/src/qpid/broker/Link.cpp
index 297c5e22a9..84dd163ac3 100644
--- a/qpid/cpp/src/qpid/broker/Link.cpp
+++ b/qpid/cpp/src/qpid/broker/Link.cpp
@@ -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));
}
diff --git a/qpid/cpp/src/qpid/broker/LinkRegistry.cpp b/qpid/cpp/src/qpid/broker/LinkRegistry.cpp
index 75c311c917..31b113c4d9 100644
--- a/qpid/cpp/src/qpid/broker/LinkRegistry.cpp
+++ b/qpid/cpp/src/qpid/broker/LinkRegistry.cpp
@@ -326,13 +326,13 @@ void LinkRegistry::notifyConnection(const std::string& key, Connection* c)
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));
}
}