summaryrefslogtreecommitdiff
path: root/qpid/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/cpp/src')
-rw-r--r--qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp16
-rw-r--r--qpid/cpp/src/qpid/agent/ManagementAgentImpl.h5
2 files changed, 15 insertions, 6 deletions
diff --git a/qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp b/qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp
index a537127119..f9f39316e2 100644
--- a/qpid/cpp/src/qpid/agent/ManagementAgentImpl.cpp
+++ b/qpid/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/qpid/cpp/src/qpid/agent/ManagementAgentImpl.h b/qpid/cpp/src/qpid/agent/ManagementAgentImpl.h
index 63366823fe..a876496e98 100644
--- a/qpid/cpp/src/qpid/agent/ManagementAgentImpl.h
+++ b/qpid/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;