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 2014/12/01 20:35:42 UTC
activemq-cpp git commit:
https://issues.apache.org/jira/browse/AMQCPP-556
Repository: activemq-cpp
Updated Branches:
refs/heads/trunk 84daff398 -> 660d080cd
https://issues.apache.org/jira/browse/AMQCPP-556
apply fix for deadlock on session stop()
Project: http://git-wip-us.apache.org/repos/asf/activemq-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-cpp/commit/660d080c
Tree: http://git-wip-us.apache.org/repos/asf/activemq-cpp/tree/660d080c
Diff: http://git-wip-us.apache.org/repos/asf/activemq-cpp/diff/660d080c
Branch: refs/heads/trunk
Commit: 660d080cddb02950d013f83f15c9940b4e93831d
Parents: 84daff3
Author: Timothy Bish <ta...@gmail.com>
Authored: Mon Dec 1 14:35:32 2014 -0500
Committer: Timothy Bish <ta...@gmail.com>
Committed: Mon Dec 1 14:35:32 2014 -0500
----------------------------------------------------------------------
.../main/activemq/core/ActiveMQSessionExecutor.cpp | 17 ++++++++++-------
.../core/kernels/ActiveMQSessionKernel.cpp | 14 ++++++++++++++
2 files changed, 24 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/660d080c/activemq-cpp/src/main/activemq/core/ActiveMQSessionExecutor.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/activemq/core/ActiveMQSessionExecutor.cpp b/activemq-cpp/src/main/activemq/core/ActiveMQSessionExecutor.cpp
index 5392950..04b8e60 100644
--- a/activemq-cpp/src/main/activemq/core/ActiveMQSessionExecutor.cpp
+++ b/activemq-cpp/src/main/activemq/core/ActiveMQSessionExecutor.cpp
@@ -107,6 +107,9 @@ void ActiveMQSessionExecutor::wakeup() {
Pointer<TaskRunner> taskRunner;
synchronized(messageQueue.get()) {
if (this->taskRunner == NULL) {
+ if (!messageQueue->isRunning()) {
+ return;
+ }
this->taskRunner.reset(new DedicatedTaskRunner(this));
this->taskRunner->start();
}
@@ -131,21 +134,21 @@ void ActiveMQSessionExecutor::start() {
////////////////////////////////////////////////////////////////////////////////
void ActiveMQSessionExecutor::stop() {
- if (messageQueue->isRunning()) {
- messageQueue->stop();
- Pointer<TaskRunner> taskRunner;
+ Pointer<TaskRunner> taskRunner;
+ synchronized(messageQueue.get()) {
+ if (messageQueue->isRunning()) {
+ messageQueue->stop();
- synchronized(messageQueue.get()) {
taskRunner = this->taskRunner;
if (taskRunner != NULL) {
this->taskRunner.reset(NULL);
}
}
+ }
- if (taskRunner != NULL) {
- taskRunner->shutdown();
- }
+ if (taskRunner != NULL) {
+ taskRunner->shutdown();
}
}
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/660d080c/activemq-cpp/src/main/activemq/core/kernels/ActiveMQSessionKernel.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/activemq/core/kernels/ActiveMQSessionKernel.cpp b/activemq-cpp/src/main/activemq/core/kernels/ActiveMQSessionKernel.cpp
index a4c97ac..949d51b 100644
--- a/activemq-cpp/src/main/activemq/core/kernels/ActiveMQSessionKernel.cpp
+++ b/activemq-cpp/src/main/activemq/core/kernels/ActiveMQSessionKernel.cpp
@@ -1103,6 +1103,20 @@ void ActiveMQSessionKernel::start() {
////////////////////////////////////////////////////////////////////////////////
void ActiveMQSessionKernel::stop() {
+ this->config->consumerLock.readLock().lock();
+ try {
+ Pointer<Iterator< Pointer<ActiveMQConsumerKernel> > > iter(this->config->consumers.iterator());
+
+ while (iter->hasNext()) {
+ Pointer<ActiveMQConsumerKernel> consumer = iter->next();
+ consumer->stop();
+ }
+ this->config->consumerLock.readLock().unlock();
+ } catch (Exception& ex) {
+ this->config->consumerLock.readLock().unlock();
+ throw;
+ }
+
if (this->executor.get() != NULL) {
this->executor->stop();
}