summaryrefslogtreecommitdiff
path: root/cpp/src/qpidd.cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2008-07-07 14:35:50 +0000
committerAlan Conway <aconway@apache.org>2008-07-07 14:35:50 +0000
commitdc7a6dbde25cac3e94d9f1ee0184c417cafb6ed9 (patch)
treebfece89227454983daa54f5ba246b50b273a1616 /cpp/src/qpidd.cpp
parentd760485442f9874caee0c726a49030b7fd54faff (diff)
downloadqpid-python-dc7a6dbde25cac3e94d9f1ee0184c417cafb6ed9.tar.gz
Restore use of SignalHandler in qpidd.cpp, fixed errors in previous commit.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@674504 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpidd.cpp')
-rw-r--r--cpp/src/qpidd.cpp30
1 files changed, 6 insertions, 24 deletions
diff --git a/cpp/src/qpidd.cpp b/cpp/src/qpidd.cpp
index 64e64cab38..6b6d37c933 100644
--- a/cpp/src/qpidd.cpp
+++ b/cpp/src/qpidd.cpp
@@ -19,6 +19,7 @@
*
*/
#include "qpid/broker/Broker.h"
+#include "qpid/broker/SignalHandler.h"
#include "qpid/sys/posix/check.h"
#include "qpid/broker/Daemon.h"
#include "qpid/log/Statement.h"
@@ -127,16 +128,8 @@ struct BootstrapOptions : public qpid::Options {
}
};
-// Globals
-shared_ptr<Broker> brokerPtr;
auto_ptr<QpiddOptions> options;
-void shutdownHandler(int /*signal*/){
- // Note: do not call any async-signal unsafe functions here.
- // Do any extra shutdown actions in main() after broker->run()
- brokerPtr->shutdown();
-}
-
struct QpiddDaemon : public Daemon {
QpiddDaemon(std::string pidDir) : Daemon(pidDir) {}
@@ -149,11 +142,11 @@ struct QpiddDaemon : public Daemon {
/** Code for forked child process */
void child() {
- brokerPtr.reset(new Broker(options->broker));
+ shared_ptr<Broker> brokerPtr(new Broker(options->broker));
+ broker::SignalHandler::setBroker(brokerPtr);
uint16_t port=brokerPtr->getPort();
ready(port); // Notify parent.
brokerPtr->run();
- brokerPtr.reset();
}
};
@@ -240,17 +233,6 @@ int main(int argc, char* argv[])
}
// Starting the broker.
-
- // Signal handling
- signal(SIGINT,shutdownHandler);
- signal(SIGTERM,shutdownHandler);
- signal(SIGHUP,SIG_IGN); // TODO aconway 2007-07-18: reload config.
-
- signal(SIGCHLD,SIG_IGN);
- signal(SIGTSTP,SIG_IGN);
- signal(SIGTTOU,SIG_IGN);
- signal(SIGTTIN,SIG_IGN);
-
if (options->daemon.daemon) {
// For daemon mode replace default stderr with syslog.
if (options->log.outputs.size() == 1 && options->log.outputs[0] == "stderr") {
@@ -259,14 +241,14 @@ int main(int argc, char* argv[])
}
// Fork the daemon
QpiddDaemon d(options->daemon.piddir);
- d.fork();
+ d.fork(); // Broker is stared in QpiddDaemon::child()
}
else { // Non-daemon broker.
- brokerPtr.reset(new Broker(options->broker));
+ shared_ptr<Broker> brokerPtr(new Broker(options->broker));
+ broker::SignalHandler::setBroker(brokerPtr);
if (options->broker.port == 0)
cout << uint16_t(brokerPtr->getPort()) << endl;
brokerPtr->run();
- QPID_LOG(notice, "Shutting down.");
}
return 0;
}