summaryrefslogtreecommitdiff
path: root/cpp
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
commit037596ef68e1533da08ec0bd1262c4e00666e1f7 (patch)
tree6b0c2f315c86ab35d6b001f1eba313acda3be34d /cpp
parentff0fe9fcb9c0e82e57d7b1146701fc2861271ce2 (diff)
downloadqpid-python-037596ef68e1533da08ec0bd1262c4e00666e1f7.tar.gz
Handle incorrect values for worker-threads option more gracefully
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@938060 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/qpid/broker/Broker.cpp35
1 files changed, 20 insertions, 15 deletions
diff --git a/cpp/src/qpid/broker/Broker.cpp b/cpp/src/qpid/broker/Broker.cpp
index c95efaa1ef..df621fe4fb 100644
--- a/cpp/src/qpid/broker/Broker.cpp
+++ b/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());
}
}