Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7AE7011340 for ; Tue, 8 Jul 2014 21:00:42 +0000 (UTC) Received: (qmail 4765 invoked by uid 500); 8 Jul 2014 21:00:42 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 4722 invoked by uid 500); 8 Jul 2014 21:00:42 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 4713 invoked by uid 99); 8 Jul 2014 21:00:42 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Jul 2014 21:00:42 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 1440B9A83BE; Tue, 8 Jul 2014 21:00:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tabish@apache.org To: commits@activemq.apache.org Message-Id: <6dda253480094ab3b69cd2bf3ec6e45b@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: https://issues.apache.org/jira/browse/AMQCPP-546 Date: Tue, 8 Jul 2014 21:00:42 +0000 (UTC) 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 Authored: Tue Jul 8 17:00:30 2014 -0400 Committer: Timothy Bish 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 message) { - - if (checkForDuplicates && message != NULL) { - Pointer destination = message->getDestination(); - if (destination != NULL) { - if (destination->isQueue()) { + synchronized(&this->impl->mutex) { + if (checkForDuplicates && message != NULL) { + Pointer destination = message->getDestination(); + if (destination != NULL) { + if (destination->isQueue()) { + Pointer 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 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 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 message) { - if (checkForDuplicates && message != NULL) { - Pointer destination = message->getDestination(); - if (destination != NULL) { - if (destination->isQueue()) { - try { - Pointer audit = this->impl->destinations.get(destination); - audit->rollback(message->getMessageId()); - } catch (NoSuchElementException& ex) {} - } else { - try { - Pointer audit = this->impl->dispatchers.get(dispatcher); - audit->rollback(message->getMessageId()); - } catch (NoSuchElementException& ex) {} + synchronized(&this->impl->mutex) { + if (checkForDuplicates && message != NULL) { + Pointer destination = message->getDestination(); + if (destination != NULL) { + if (destination->isQueue()) { + try { + Pointer audit = this->impl->destinations.get(destination); + audit->rollback(message->getMessageId()); + } catch (NoSuchElementException& ex) {} + } else { + try { + Pointer audit = this->impl->dispatchers.get(dispatcher); + audit->rollback(message->getMessageId()); + } catch (NoSuchElementException& ex) {} + } } } }