diff options
author | Ted Ross <tross@apache.org> | 2011-09-16 14:34:39 +0000 |
---|---|---|
committer | Ted Ross <tross@apache.org> | 2011-09-16 14:34:39 +0000 |
commit | ab66e50da3f39257590b941ab1fabd709e298c8f (patch) | |
tree | 5fda155ed9c6fe2d3fed8681de577501dcd5921f | |
parent | 0f4893206428cea8b6b9af46ed2fdacc7b7d834f (diff) | |
download | qpid-python-ab66e50da3f39257590b941ab1fabd709e298c8f.tar.gz |
QPID-3484 - Added missing constructor for EventNotifier, fixed initialization bug.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1171592 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | qpid/cpp/include/qmf/posix/EventNotifier.h | 1 | ||||
-rw-r--r-- | qpid/cpp/src/qmf/AgentSession.cpp | 16 | ||||
-rw-r--r-- | qpid/cpp/src/qmf/AgentSessionImpl.h | 1 | ||||
-rw-r--r-- | qpid/cpp/src/qmf/ConsoleSession.cpp | 20 | ||||
-rw-r--r-- | qpid/cpp/src/qmf/ConsoleSessionImpl.h | 1 | ||||
-rw-r--r-- | qpid/cpp/src/qmf/PosixEventNotifier.cpp | 2 |
6 files changed, 35 insertions, 6 deletions
diff --git a/qpid/cpp/include/qmf/posix/EventNotifier.h b/qpid/cpp/include/qmf/posix/EventNotifier.h index 91817cc771..ebc1cb5364 100644 --- a/qpid/cpp/include/qmf/posix/EventNotifier.h +++ b/qpid/cpp/include/qmf/posix/EventNotifier.h @@ -38,6 +38,7 @@ namespace posix { class QMF_CLASS_EXTERN EventNotifier : public qmf::Handle<qmf::PosixEventNotifierImpl> { public: + QMF_EXTERN EventNotifier(PosixEventNotifierImpl* impl = 0); QMF_EXTERN EventNotifier(::qmf::AgentSession& agentSession); QMF_EXTERN EventNotifier(::qmf::ConsoleSession& consoleSession); QMF_EXTERN EventNotifier(const EventNotifier& that); diff --git a/qpid/cpp/src/qmf/AgentSession.cpp b/qpid/cpp/src/qmf/AgentSession.cpp index d92b2a41d3..251c25fd44 100644 --- a/qpid/cpp/src/qmf/AgentSession.cpp +++ b/qpid/cpp/src/qmf/AgentSession.cpp @@ -55,7 +55,7 @@ void AgentSession::raiseEvent(const Data& d, int s) { impl->raiseEvent(d, s); } //======================================================================================== AgentSessionImpl::AgentSessionImpl(Connection& c, const string& options) : - connection(c), domain("default"), opened(false), thread(0), threadCanceled(false), + connection(c), domain("default"), opened(false), eventNotifier(0), thread(0), threadCanceled(false), bootSequence(1), interval(60), lastHeartbeat(0), lastVisit(0), forceHeartbeat(false), externalStorage(false), autoAllowQueries(true), autoAllowMethods(true), maxSubscriptions(64), minSubInterval(3000), subLifetime(300), publicEvents(true), @@ -191,7 +191,7 @@ void AgentSessionImpl::open() } -void AgentSessionImpl::close() +void AgentSessionImpl::closeAsync() { if (!opened) return; @@ -202,6 +202,18 @@ void AgentSessionImpl::close() } +void AgentSessionImpl::close() +{ + closeAsync(); + + if (thread) { + thread->join(); + delete thread; + thread = 0; + } +} + + bool AgentSessionImpl::nextEvent(AgentEvent& event, Duration timeout) { uint64_t milliseconds = timeout.getMilliseconds(); diff --git a/qpid/cpp/src/qmf/AgentSessionImpl.h b/qpid/cpp/src/qmf/AgentSessionImpl.h index cf1b1d770f..9039a5985f 100644 --- a/qpid/cpp/src/qmf/AgentSessionImpl.h +++ b/qpid/cpp/src/qmf/AgentSessionImpl.h @@ -84,6 +84,7 @@ namespace qmf { void setAttribute(const string& k, const qpid::types::Variant& v) { checkOpen(); attributes[k] = v; } const string& getName() const { return agentName; } void open(); + void closeAsync(); void close(); bool nextEvent(AgentEvent& e, Duration t); int pendingEvents() const; diff --git a/qpid/cpp/src/qmf/ConsoleSession.cpp b/qpid/cpp/src/qmf/ConsoleSession.cpp index d084b8a8eb..2dfc894c58 100644 --- a/qpid/cpp/src/qmf/ConsoleSession.cpp +++ b/qpid/cpp/src/qmf/ConsoleSession.cpp @@ -67,7 +67,7 @@ Subscription ConsoleSession::subscribe(const string& q, const string& f, const s ConsoleSessionImpl::ConsoleSessionImpl(Connection& c, const string& options) : connection(c), domain("default"), maxAgentAgeMinutes(5), listenOnDirect(true), strictSecurity(false), maxThreadWaitTime(5), - opened(false), thread(0), threadCanceled(false), lastVisit(0), lastAgePass(0), + opened(false), eventNotifier(0), thread(0), threadCanceled(false), lastVisit(0), lastAgePass(0), connectedBrokerInAgentList(false), schemaCache(new SchemaCache()), nextCorrelator(1) { if (!options.empty()) { @@ -210,7 +210,7 @@ void ConsoleSessionImpl::open() } -void ConsoleSessionImpl::close() +void ConsoleSessionImpl::closeAsync() { if (!opened) throw QmfException("The session is already closed"); @@ -221,6 +221,18 @@ void ConsoleSessionImpl::close() } +void ConsoleSessionImpl::close() +{ + closeAsync(); + + if (thread) { + thread->join(); + delete thread; + thread = 0; + } +} + + bool ConsoleSessionImpl::nextEvent(ConsoleEvent& event, Duration timeout) { uint64_t milliseconds = timeout.getMilliseconds(); @@ -256,14 +268,14 @@ int ConsoleSessionImpl::pendingEvents() const void ConsoleSessionImpl::setEventNotifier(EventNotifierImpl* notifier) { qpid::sys::Mutex::ScopedLock l(lock); - this->eventNotifier = notifier; + eventNotifier = notifier; } EventNotifierImpl* ConsoleSessionImpl::getEventNotifier() const { qpid::sys::Mutex::ScopedLock l(lock); - return this->eventNotifier; + return eventNotifier; } diff --git a/qpid/cpp/src/qmf/ConsoleSessionImpl.h b/qpid/cpp/src/qmf/ConsoleSessionImpl.h index 660fc9b83f..2f1f631715 100644 --- a/qpid/cpp/src/qmf/ConsoleSessionImpl.h +++ b/qpid/cpp/src/qmf/ConsoleSessionImpl.h @@ -62,6 +62,7 @@ namespace qmf { void setDomain(const std::string& d) { domain = d; } void setAgentFilter(const std::string& f); void open(); + void closeAsync(); void close(); bool nextEvent(ConsoleEvent& e, qpid::messaging::Duration t); int pendingEvents() const; diff --git a/qpid/cpp/src/qmf/PosixEventNotifier.cpp b/qpid/cpp/src/qmf/PosixEventNotifier.cpp index b5c71210bb..a364cc155d 100644 --- a/qpid/cpp/src/qmf/PosixEventNotifier.cpp +++ b/qpid/cpp/src/qmf/PosixEventNotifier.cpp @@ -26,6 +26,8 @@ using namespace std; typedef qmf::PrivateImplRef<posix::EventNotifier> PI; +posix::EventNotifier::EventNotifier(PosixEventNotifierImpl* impl) { PI::ctor(*this, impl); } + posix::EventNotifier::EventNotifier(AgentSession& agentSession) { PI::ctor(*this, new PosixEventNotifierImpl(agentSession)); |