summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/posix/QpiddBroker.cpp
diff options
context:
space:
mode:
authorCharles E. Rolke <chug@apache.org>2012-09-20 13:48:40 +0000
committerCharles E. Rolke <chug@apache.org>2012-09-20 13:48:40 +0000
commite20a23b370e64c6f09a57b4ddefd6f650e89ba13 (patch)
tree9a8c05e15b071bc7fd3f78017d76b8ffb4824e32 /qpid/cpp/src/posix/QpiddBroker.cpp
parenta848dc683403f7f2cb26c693b561d3aa70506efb (diff)
downloadqpid-python-e20a23b370e64c6f09a57b4ddefd6f650e89ba13.tar.gz
QPID-3500 C++ qpidd broker --help should work despite parse errors
This patch finds and processes --version before anything else. Then it finds --help before fully parsing command line options. In the event of a parse error, help usage may be shown as requested. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1388032 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/posix/QpiddBroker.cpp')
-rw-r--r--qpid/cpp/src/posix/QpiddBroker.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/qpid/cpp/src/posix/QpiddBroker.cpp b/qpid/cpp/src/posix/QpiddBroker.cpp
index 76e3bb6674..f1f9009568 100644
--- a/qpid/cpp/src/posix/QpiddBroker.cpp
+++ b/qpid/cpp/src/posix/QpiddBroker.cpp
@@ -48,6 +48,10 @@ BootstrapOptions::BootstrapOptions(const char* argv0)
add(log);
}
+void BootstrapOptions::usage() const {
+ cout << "Usage: qpidd [OPTIONS]" << endl << endl << *this << endl;
+}
+
namespace {
const std::string TCP = "tcp";
}
@@ -111,17 +115,17 @@ void QpiddOptions::usage() const {
// Set the broker pointer on the signal handler, then reset at end of scope.
// This is to ensure that the signal handler doesn't keep a broker
// reference after main() has returned.
-//
+//
struct ScopedSetBroker {
ScopedSetBroker(const boost::intrusive_ptr<Broker>& broker) {
qpid::broker::SignalHandler::setBroker(broker.get());
}
~ScopedSetBroker() { qpid::broker::SignalHandler::setBroker(0); }
};
-
+
struct QpiddDaemon : public Daemon {
QpiddPosixOptions *options;
-
+
QpiddDaemon(std::string pidDir, QpiddPosixOptions *opts)
: Daemon(pidDir), options(opts) {}
@@ -129,7 +133,7 @@ struct QpiddDaemon : public Daemon {
void parent() {
uint16_t port = wait(options->daemon.wait);
if (options->parent->broker.port == 0 || options->daemon.transport != TCP)
- cout << port << endl;
+ cout << port << endl;
}
/** Code for forked child process */
@@ -162,12 +166,12 @@ int QpiddBroker::execute (QpiddOptions *options) {
QPID_LOG(notice, "Cannot stop broker: " << e.what());
return 1;
}
- if (pid < 0)
+ if (pid < 0)
return 1;
if (myOptions->daemon.check)
cout << pid << endl;
if (myOptions->daemon.quit) {
- if (kill(pid, SIGINT) < 0)
+ if (kill(pid, SIGINT) < 0)
throw Exception("Failed to stop daemon: " + qpid::sys::strError(errno));
// Wait for the process to die before returning
int retry=10000; // Try up to 10 seconds