diff options
author | Alan Conway <aconway@apache.org> | 2012-01-19 23:07:30 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2012-01-19 23:07:30 +0000 |
commit | da5682adea86ae2d13a69931d84aec2c80c3f248 (patch) | |
tree | 0a43a97bb2ec330e71630465aa80c0b85b88e257 | |
parent | 93305abfccb4d79634b5d8f74af3da9d29dd9dbd (diff) | |
download | qpid-python-da5682adea86ae2d13a69931d84aec2c80c3f248.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-2@1233674 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | qpid/cpp/src/qpid/ha/QueueReplicator.cpp | 6 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/ha/QueueReplicator.h | 3 |
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; |