From 88a3f9073c06478fe5065f537acb3162f0651d89 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 8 Oct 2009 19:04:05 +0000 Subject: QPID-2132: further fix from Ken Giusti. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@823279 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/agent/ManagementAgentImpl.cpp | 16 +++++++++++----- cpp/src/qpid/agent/ManagementAgentImpl.h | 5 ++++- 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/qpid/agent/ManagementAgentImpl.cpp b/cpp/src/qpid/agent/ManagementAgentImpl.cpp index a537127119..f9f39316e2 100644 --- a/cpp/src/qpid/agent/ManagementAgentImpl.cpp +++ b/cpp/src/qpid/agent/ManagementAgentImpl.cpp @@ -89,11 +89,12 @@ ManagementAgentImpl::ManagementAgentImpl() : ManagementAgentImpl::~ManagementAgentImpl() { - // shutdown the connection thread + // shutdown & cleanup all threads connThreadBody.close(); - connThread.join(); + pubThreadBody.close(); - // @todo need to shutdown pubThread? + connThread.join(); + pubThread.join(); // Release the memory associated with stored management objects. { @@ -907,8 +908,13 @@ bool ManagementAgentImpl::ConnectionThread::isSleeping() const void ManagementAgentImpl::PublishThread::run() { - while (true) { + uint16_t totalSleep; + + while (!shutdown) { agent.periodicProcessing(); - ::sleep(agent.getInterval()); + totalSleep = 0; + while (totalSleep++ < agent.getInterval() && !shutdown) { + ::sleep(1); + } } } diff --git a/cpp/src/qpid/agent/ManagementAgentImpl.h b/cpp/src/qpid/agent/ManagementAgentImpl.h index 63366823fe..a876496e98 100644 --- a/cpp/src/qpid/agent/ManagementAgentImpl.h +++ b/cpp/src/qpid/agent/ManagementAgentImpl.h @@ -194,8 +194,11 @@ class ManagementAgentImpl : public ManagementAgent, public client::MessageListen { ManagementAgentImpl& agent; void run(); + bool shutdown; public: - PublishThread(ManagementAgentImpl& _agent) : agent(_agent) {} + PublishThread(ManagementAgentImpl& _agent) : + agent(_agent), shutdown(false) {} + void close() { shutdown = true; } }; ConnectionThread connThreadBody; -- cgit v1.2.1