diff options
author | Alan Conway <aconway@apache.org> | 2010-08-09 19:29:18 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2010-08-09 19:29:18 +0000 |
commit | db421d82a01e82eae72ff262e632bce92ecf575b (patch) | |
tree | f7e2ec1a1b9105c63598d71349772592b054eb86 /cpp/src | |
parent | f1492c206ea64eaddb1bece4e83939c1d845b70b (diff) | |
download | qpid-python-db421d82a01e82eae72ff262e632bce92ecf575b.tar.gz |
Fixed memory management error in cluster::Quorum causing problems with --cluster-cman.
Sometimes caused brokers using --cluster-cman to fail with a "no
permission" or "bad file-descriptor" error.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@983786 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/qpid/cluster/Quorum_cman.cpp | 6 | ||||
-rw-r--r-- | cpp/src/qpid/cluster/Quorum_cman.h | 3 |
2 files changed, 5 insertions, 4 deletions
diff --git a/cpp/src/qpid/cluster/Quorum_cman.cpp b/cpp/src/qpid/cluster/Quorum_cman.cpp index f7d2c5c409..728f824b16 100644 --- a/cpp/src/qpid/cluster/Quorum_cman.cpp +++ b/cpp/src/qpid/cluster/Quorum_cman.cpp @@ -42,7 +42,7 @@ void cmanCallbackFn(cman_handle_t handle, void */*privdata*/, int reason, int /* } } -Quorum::Quorum(boost::function<void()> err) : enable(false), cman(0), cmanFd(0) { +Quorum::Quorum(boost::function<void()> err) : cman(0), cmanFd(0) { errorFn = err; } @@ -54,7 +54,6 @@ Quorum::~Quorum() { void Quorum::start(boost::shared_ptr<sys::Poller> p) { poller = p; - enable = true; QPID_LOG(debug, "Connecting to quorum service."); cman = cman_init(0); if (cman == 0) throw ErrnoException("Can't connect to cman service"); @@ -70,9 +69,10 @@ void Quorum::start(boost::shared_ptr<sys::Poller> p) { void Quorum::watch(int fd) { cmanFd = fd; if (dispatchHandle.get()) dispatchHandle->stopWatch(); + ioHandle.reset(new sys::PosixIOHandle(cmanFd)); dispatchHandle.reset( new sys::DispatchHandleRef( - sys::PosixIOHandle(cmanFd), + *ioHandle, // This must outlive the dispatchHandleRef boost::bind(&Quorum::dispatch, this, _1), // read 0, // write boost::bind(&Quorum::disconnect, this, _1) // disconnect diff --git a/cpp/src/qpid/cluster/Quorum_cman.h b/cpp/src/qpid/cluster/Quorum_cman.h index 130f1baf64..98e6baee89 100644 --- a/cpp/src/qpid/cluster/Quorum_cman.h +++ b/cpp/src/qpid/cluster/Quorum_cman.h @@ -34,6 +34,7 @@ extern "C" { namespace qpid { namespace sys { class Poller; +class PosixIOHandle; } namespace cluster { @@ -51,9 +52,9 @@ class Quorum { int getFd(); void watch(int fd); - bool enable; cman_handle_t cman; int cmanFd; + std::auto_ptr<sys::PosixIOHandle> ioHandle; std::auto_ptr<sys::DispatchHandleRef> dispatchHandle; boost::shared_ptr<sys::Poller> poller; }; |