You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2008/07/07 16:35:50 UTC
svn commit: r674504 - in /incubator/qpid/trunk/qpid/cpp/src:
qpid/broker/Broker.cpp qpidd.cpp
Author: aconway
Date: Mon Jul 7 07:35:50 2008
New Revision: 674504
URL: http://svn.apache.org/viewvc?rev=674504&view=rev
Log:
Restore use of SignalHandler in qpidd.cpp, fixed errors in previous commit.
Modified:
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp
incubator/qpid/trunk/qpid/cpp/src/qpidd.cpp
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp?rev=674504&r1=674503&r2=674504&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp Mon Jul 7 07:35:50 2008
@@ -285,6 +285,7 @@
sasl_done();
#endif
}
+ QPID_LOG(notice, "Shut down");
}
ManagementObject::shared_ptr Broker::GetManagementObject(void) const
Modified: incubator/qpid/trunk/qpid/cpp/src/qpidd.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpidd.cpp?rev=674504&r1=674503&r2=674504&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpidd.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpidd.cpp Mon Jul 7 07:35:50 2008
@@ -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 @@
}
};
-// 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 @@
/** 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 @@
}
// 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 @@
}
// 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;
}