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/07/08 23:00:42 UTC
git commit: https://issues.apache.org/jira/browse/AMQCPP-546
Repository: activemq-cpp
Updated Branches:
refs/heads/3.8.x cea38b846 -> 4883523f7
https://issues.apache.org/jira/browse/AMQCPP-546
Make the method in this class thread safe
Project: http://git-wip-us.apache.org/repos/asf/activemq-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-cpp/commit/4883523f
Tree: http://git-wip-us.apache.org/repos/asf/activemq-cpp/tree/4883523f
Diff: http://git-wip-us.apache.org/repos/asf/activemq-cpp/diff/4883523f
Branch: refs/heads/3.8.x
Commit: 4883523f77f3a0dc2847ca63feb56c949ccd0d65
Parents: cea38b8
Author: Timothy Bish <ta...@gmail.com>
Authored: Tue Jul 8 17:00:30 2014 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Tue Jul 8 17:00:30 2014 -0400
----------------------------------------------------------------------
.../src/main/activemq/core/ConnectionAudit.cpp | 61 ++++++++++----------
1 file changed, 32 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/4883523f/activemq-cpp/src/main/activemq/core/ConnectionAudit.cpp
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/activemq/core/ConnectionAudit.cpp b/activemq-cpp/src/main/activemq/core/ConnectionAudit.cpp
index b8e3c5e..40b8cde 100644
--- a/activemq-cpp/src/main/activemq/core/ConnectionAudit.cpp
+++ b/activemq-cpp/src/main/activemq/core/ConnectionAudit.cpp
@@ -90,30 +90,31 @@ void ConnectionAudit::removeDispatcher(Dispatcher* dispatcher) {
////////////////////////////////////////////////////////////////////////////////
bool ConnectionAudit::isDuplicate(Dispatcher* dispatcher, Pointer<commands::Message> message) {
-
- if (checkForDuplicates && message != NULL) {
- Pointer<ActiveMQDestination> destination = message->getDestination();
- if (destination != NULL) {
- if (destination->isQueue()) {
+ synchronized(&this->impl->mutex) {
+ if (checkForDuplicates && message != NULL) {
+ Pointer<ActiveMQDestination> destination = message->getDestination();
+ if (destination != NULL) {
+ if (destination->isQueue()) {
+ Pointer<ActiveMQMessageAudit> audit;
+ try {
+ audit = this->impl->destinations.get(destination);
+ } catch (NoSuchElementException& ex) {
+ audit.reset(new ActiveMQMessageAudit(auditDepth, auditMaximumProducerNumber));
+ this->impl->destinations.put(destination, audit);
+ }
+ bool result = audit->isDuplicate(message->getMessageId());
+ return result;
+ }
Pointer<ActiveMQMessageAudit> audit;
try {
- audit = this->impl->destinations.get(destination);
+ audit = this->impl->dispatchers.get(dispatcher);
} catch (NoSuchElementException& ex) {
audit.reset(new ActiveMQMessageAudit(auditDepth, auditMaximumProducerNumber));
- this->impl->destinations.put(destination, audit);
+ this->impl->dispatchers.put(dispatcher, audit);
}
bool result = audit->isDuplicate(message->getMessageId());
return result;
}
- Pointer<ActiveMQMessageAudit> audit;
- try {
- audit = this->impl->dispatchers.get(dispatcher);
- } catch (NoSuchElementException& ex) {
- audit.reset(new ActiveMQMessageAudit(auditDepth, auditMaximumProducerNumber));
- this->impl->dispatchers.put(dispatcher, audit);
- }
- bool result = audit->isDuplicate(message->getMessageId());
- return result;
}
}
return false;
@@ -121,19 +122,21 @@ bool ConnectionAudit::isDuplicate(Dispatcher* dispatcher, Pointer<commands::Mess
////////////////////////////////////////////////////////////////////////////////
void ConnectionAudit::rollbackDuplicate(Dispatcher* dispatcher, Pointer<commands::Message> message) {
- if (checkForDuplicates && message != NULL) {
- Pointer<ActiveMQDestination> destination = message->getDestination();
- if (destination != NULL) {
- if (destination->isQueue()) {
- try {
- Pointer<ActiveMQMessageAudit> audit = this->impl->destinations.get(destination);
- audit->rollback(message->getMessageId());
- } catch (NoSuchElementException& ex) {}
- } else {
- try {
- Pointer<ActiveMQMessageAudit> audit = this->impl->dispatchers.get(dispatcher);
- audit->rollback(message->getMessageId());
- } catch (NoSuchElementException& ex) {}
+ synchronized(&this->impl->mutex) {
+ if (checkForDuplicates && message != NULL) {
+ Pointer<ActiveMQDestination> destination = message->getDestination();
+ if (destination != NULL) {
+ if (destination->isQueue()) {
+ try {
+ Pointer<ActiveMQMessageAudit> audit = this->impl->destinations.get(destination);
+ audit->rollback(message->getMessageId());
+ } catch (NoSuchElementException& ex) {}
+ } else {
+ try {
+ Pointer<ActiveMQMessageAudit> audit = this->impl->dispatchers.get(dispatcher);
+ audit->rollback(message->getMessageId());
+ } catch (NoSuchElementException& ex) {}
+ }
}
}
}