summaryrefslogtreecommitdiff
path: root/qpid/cpp/examples/qmf-agent/example.cpp
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2009-11-12 14:35:39 +0000
committerTed Ross <tross@apache.org>2009-11-12 14:35:39 +0000
commit9221c0c4e30258d111217d7d362014bbaf308388 (patch)
tree9bbac4f558666c148e2a62cddd14fe04144b6c68 /qpid/cpp/examples/qmf-agent/example.cpp
parent42b9543988f073f22f5d6ecef54f53e8035c316e (diff)
downloadqpid-python-9221c0c4e30258d111217d7d362014bbaf308388.tar.gz
QPID-2179 - example qmf-agent occasionally crashes on shutdown
Committed patch from Ken Giusti git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@835392 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/examples/qmf-agent/example.cpp')
-rw-r--r--qpid/cpp/examples/qmf-agent/example.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/qpid/cpp/examples/qmf-agent/example.cpp b/qpid/cpp/examples/qmf-agent/example.cpp
index a611c25ba3..5ab9c10c91 100644
--- a/qpid/cpp/examples/qmf-agent/example.cpp
+++ b/qpid/cpp/examples/qmf-agent/example.cpp
@@ -36,6 +36,8 @@
#include <sstream>
+static bool running = true;
+
using namespace std;
using qpid::management::ManagementAgent;
using qpid::management::ManagementObject;
@@ -101,7 +103,7 @@ CoreClass::CoreClass(ManagementAgent* _agent, string _name) : name(_name), agent
void CoreClass::doLoop()
{
// Periodically bump a counter to provide a changing statistical value
- while (1) {
+ while (running) {
qpid::sys::sleep(1);
mgmtObject->inc_count();
mgmtObject->set_state("IN_LOOP");
@@ -155,8 +157,7 @@ ManagementAgent::Singleton* singleton;
void shutdown(int)
{
- delete singleton;
- exit(0);
+ running = false;
}
int main_int(int argc, char** argv)
@@ -188,6 +189,9 @@ int main_int(int argc, char** argv)
core1.doLoop();
+ // done, cleanup and exit
+ delete singleton;
+
return 0;
}