You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2010/04/26 16:33:27 UTC

svn commit: r938060 - /qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp

Author: gsim
Date: Mon Apr 26 14:33:27 2010
New Revision: 938060

URL: http://svn.apache.org/viewvc?rev=938060&view=rev
Log:
Handle incorrect values for worker-threads option more gracefully

Modified:
    qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp?rev=938060&r1=938059&r2=938060&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp Mon Apr 26 14:33:27 2010
@@ -55,6 +55,7 @@
 #include "qpid/Version.h"
 
 #include <boost/bind.hpp>
+#include <boost/format.hpp>
 
 #include <iostream>
 #include <memory>
@@ -323,21 +324,25 @@ void Broker::setStore () {
 }
 
 void Broker::run() {
-    QPID_LOG(notice, "Broker running");
-    Dispatcher d(poller);
-    int numIOThreads = config.workerThreads;
-    std::vector<Thread> t(numIOThreads-1);
-
-    // Run n-1 io threads
-    for (int i=0; i<numIOThreads-1; ++i)
-        t[i] = Thread(d);
-
-    // Run final thread
-    d.run();
-
-    // Now wait for n-1 io threads to exit
-    for (int i=0; i<numIOThreads-1; ++i) {
-        t[i].join();
+    if (config.workerThreads > 0) {
+        QPID_LOG(notice, "Broker running");
+        Dispatcher d(poller);
+        int numIOThreads = config.workerThreads;
+        std::vector<Thread> t(numIOThreads-1);
+        
+        // Run n-1 io threads
+        for (int i=0; i<numIOThreads-1; ++i)
+            t[i] = Thread(d);
+        
+        // Run final thread
+        d.run();
+        
+        // Now wait for n-1 io threads to exit
+        for (int i=0; i<numIOThreads-1; ++i) {
+            t[i].join();
+        }
+    } else {
+        throw Exception((boost::format("Invalid value for worker-threads: %1%") % config.workerThreads).str());
     }
 }
 



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