summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/tests/perftest.cpp
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2009-06-23 20:02:51 +0000
committerAndrew Stitcher <astitcher@apache.org>2009-06-23 20:02:51 +0000
commit25b77d22fbeaee052b7301824206981f68f901d7 (patch)
treebef887f1d54156252b37f52a7f57025276a92cb5 /qpid/cpp/src/tests/perftest.cpp
parentd673a703d179cfd4187ec83cff7a6466823c002d (diff)
downloadqpid-python-25b77d22fbeaee052b7301824206981f68f901d7.tar.gz
Fix to perftest to make sure that all threads are joined even if there
is an exception git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@787816 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests/perftest.cpp')
-rw-r--r--qpid/cpp/src/tests/perftest.cpp50
1 files changed, 23 insertions, 27 deletions
diff --git a/qpid/cpp/src/tests/perftest.cpp b/qpid/cpp/src/tests/perftest.cpp
index 78606e46cd..f55528fcd5 100644
--- a/qpid/cpp/src/tests/perftest.cpp
+++ b/qpid/cpp/src/tests/perftest.cpp
@@ -656,7 +656,10 @@ struct SubscribeThread : public Client {
};
int main(int argc, char** argv) {
-
+ int exitCode = 0;
+ boost::ptr_vector<Client> subs(opts.subs);
+ boost::ptr_vector<Client> pubs(opts.pubs);
+
try {
opts.parse(argc, argv);
@@ -666,7 +669,7 @@ int main(int argc, char** argv) {
case TOPIC: exchange="amq.topic"; break;
case SHARED: break;
}
-
+
bool singleProcess=
(!opts.setup && !opts.control && !opts.publish && !opts.subscribe);
if (singleProcess)
@@ -674,9 +677,6 @@ int main(int argc, char** argv) {
if (opts.setup) Setup().run(); // Set up queues
- boost::ptr_vector<Client> subs(opts.subs);
- boost::ptr_vector<Client> pubs(opts.pubs);
-
// Start pubs/subs for each queue/topic.
for (size_t i = 0; i < opts.qt; ++i) {
ostringstream key;
@@ -701,29 +701,25 @@ int main(int argc, char** argv) {
}
if (opts.control) Controller().run();
-
-
- // Wait for started threads.
- if (opts.publish) {
- for (boost::ptr_vector<Client>::iterator i=pubs.begin();
- i != pubs.end();
- ++i)
- i->thread.join();
- }
-
-
- if (opts.subscribe) {
- for (boost::ptr_vector<Client>::iterator i=subs.begin();
- i != subs.end();
- ++i)
- i->thread.join();
- }
- return 0;
}
catch (const std::exception& e) {
- cout << endl << e.what() << endl;
+ cout << endl << e.what() << endl;
+ exitCode = 1;
}
- return 1;
-}
-
+ // Wait for started threads.
+ if (opts.publish) {
+ for (boost::ptr_vector<Client>::iterator i=pubs.begin();
+ i != pubs.end();
+ ++i)
+ i->thread.join();
+ }
+
+ if (opts.subscribe) {
+ for (boost::ptr_vector<Client>::iterator i=subs.begin();
+ i != subs.end();
+ ++i)
+ i->thread.join();
+ }
+ return exitCode;
+}