Author: astitcher
Date: Tue Jun 23 20:02:51 2009
New Revision: 787816

URL: http://svn.apache.org/viewvc?rev=787816&view=rev
Log:
Fix to perftest to make sure that all threads are joined even if there
is an exception

Modified:
    qpid/trunk/qpid/cpp/src/tests/perftest.cpp

Modified: qpid/trunk/qpid/cpp/src/tests/perftest.cpp
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/perftest.cpp?rev=787816&r1=787815&r2=787816&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/perftest.cpp (original)
+++ qpid/trunk/qpid/cpp/src/tests/perftest.cpp Tue Jun 23 20:02:51 2009
@@ -656,7 +656,10 @@
 };
 
 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 @@
             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 @@
 
         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 @@
         }
 
         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;
+    }
+
+    // Wait for started threads.
+    if (opts.publish) {
+        for (boost::ptr_vector<Client>::iterator i=pubs.begin();
+             i != pubs.end();
+             ++i)
+            i->thread.join();
     }
-    return 1;
-}
 
-                                            
+    if (opts.subscribe) {
+        for (boost::ptr_vector<Client>::iterator i=subs.begin();
+             i != subs.end();
+             ++i)
+            i->thread.join();
+    }
+    return exitCode;
+}



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscr...@qpid.apache.org

Reply via email to