summaryrefslogtreecommitdiff
path: root/qpid/cpp/src
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2010-04-26 14:33:27 +0000
committerGordon Sim <gsim@apache.org>2010-04-26 14:33:27 +0000
commit4c59858e1688d8329304c0f57cae25b568f03cbe (patch)
tree9bffa251988b50dc1ad3c2dcc2b98d6451fe16c0 /qpid/cpp/src
parent7b5de19ea6cdb4e4351c9b2116d84b26f4053462 (diff)
downloadqpid-python-4c59858e1688d8329304c0f57cae25b568f03cbe.tar.gz
Handle incorrect values for worker-threads option more gracefully
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@938060 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
-rw-r--r--qpid/cpp/src/qpid/broker/Broker.cpp35
1 files changed, 20 insertions, 15 deletions
diff --git a/qpid/cpp/src/qpid/broker/Broker.cpp b/qpid/cpp/src/qpid/broker/Broker.cpp
index c95efaa1ef..df621fe4fb 100644
--- a/qpid/cpp/src/qpid/broker/Broker.cpp
+++ b/qpid/cpp/src/qpid/broker/Broker.cpp
@@ -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());
}
}