summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2012-02-14 16:05:39 +0000
committerAlan Conway <aconway@apache.org>2012-02-14 16:05:39 +0000
commitd0e2bfe537eb62fccd5fe0184799a5dc1fdca84f (patch)
tree434cab9e52ec9bb275c5c349a368d6652d1ceffc
parenta7777adba03274f92ce8130ed8769cd77874693c (diff)
downloadqpid-python-d0e2bfe537eb62fccd5fe0184799a5dc1fdca84f.tar.gz
QPID-3603: Fix initialization race in QueueReplicator.
Was core dumping occasionally due to QueueReplicator being deleted before it was initialized. git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/qpid-3603-6@1244060 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/src/qpid/ha/QueueReplicator.cpp6
-rw-r--r--qpid/cpp/src/qpid/ha/QueueReplicator.h3
2 files changed, 6 insertions, 3 deletions
diff --git a/qpid/cpp/src/qpid/ha/QueueReplicator.cpp b/qpid/cpp/src/qpid/ha/QueueReplicator.cpp
index d99f5126f5..6eed8010be 100644
--- a/qpid/cpp/src/qpid/ha/QueueReplicator.cpp
+++ b/qpid/cpp/src/qpid/ha/QueueReplicator.cpp
@@ -78,7 +78,7 @@ void QueueReplicator::activate() {
false, // dynamic
0, // sync?
// Include shared_ptr to self to ensure we not deleted before initializeBridge is called.
- boost::bind(&QueueReplicator::initializeBridge, this, _1, _2)
+ boost::bind(&QueueReplicator::initializeBridge, this, _1, _2, self)
);
}
@@ -91,7 +91,9 @@ void QueueReplicator::deactivate() {
}
// Called in a broker connection thread when the bridge is created.
-void QueueReplicator::initializeBridge(Bridge& bridge, SessionHandler& sessionHandler) {
+// shared_ptr to self ensures we are not deleted before initializeBridge is called.
+void QueueReplicator::initializeBridge(Bridge& bridge, SessionHandler& sessionHandler,
+ boost::shared_ptr<QueueReplicator> /*self*/) {
sys::Mutex::ScopedLock l(lock);
framing::AMQP_ServerProxy peer(sessionHandler.out);
diff --git a/qpid/cpp/src/qpid/ha/QueueReplicator.h b/qpid/cpp/src/qpid/ha/QueueReplicator.h
index 0a1453dc63..9d0ea307ef 100644
--- a/qpid/cpp/src/qpid/ha/QueueReplicator.h
+++ b/qpid/cpp/src/qpid/ha/QueueReplicator.h
@@ -70,7 +70,8 @@ class QueueReplicator : public broker::Exchange,
bool isBound(boost::shared_ptr<broker::Queue>, const std::string* const, const framing::FieldTable* const);
private:
- void initializeBridge(broker::Bridge& bridge, broker::SessionHandler& sessionHandler);
+ void initializeBridge(broker::Bridge& bridge, broker::SessionHandler& sessionHandler,
+ boost::shared_ptr<QueueReplicator> self);
void dequeue(framing::SequenceNumber, const sys::Mutex::ScopedLock&);
std::string logPrefix;