Changes: Fixed crash of booster-m and booster-w / non-quitting booster-m caused by erroneous handling of SIGHUP.

No more QThread warnings related to QSocketNotifier. Removed SIGHUP handler from main.cpp
         (Set in mbooster.cpp and wrtbooster.cpp. Default behavior is always exit() anyway).

RevBy: TrustMe
pull/1/head
Jussi Lind 15 years ago
parent eea221ca59
commit 7768e742a2

@ -228,6 +228,7 @@ void Daemon::forkBooster(char type, int sleepTime)
{
// Reset used signal handlers
signal(SIGCHLD, SIG_DFL);
signal(SIGTERM, SIG_DFL);
// Will get this signal if applauncherd dies
prctl(PR_SET_PDEATHSIG, SIGHUP);

@ -37,12 +37,6 @@ void reapZombies(int)
}
}
//! Signal handler to kill booster
void exitBooster(int)
{
Logger::logErrorAndDie(EXIT_FAILURE, "due to parent process applauncherd died, booster exit too \n");
}
void exitLauncher(int)
{
exit(0);
@ -64,7 +58,6 @@ Q_DECL_EXPORT int main(int argc, char * argv[])
// Install signal handlers
signal(SIGCHLD, reapZombies);
signal(SIGHUP, exitBooster);
signal(SIGTERM, exitLauncher);
// Create main daemon instance

@ -36,23 +36,7 @@ int MBooster::m_sighupFd[2];
struct sigaction MBooster::m_oldSigAction;
MBooster::MBooster() : m_item(0)
{
// Install signals handler e.g. to exit cleanly if launcher dies.
// This is a problem because MBooster runs a Qt event loop.
setupUnixSignalHandlers();
// Create socket pair for SIGTERM
if (::socketpair(AF_UNIX, SOCK_STREAM, 0, m_sighupFd))
{
Logger::logError("Couldn't create HUP socketpair");
}
else
{
// Install a socket notifier on the socket
m_snHup.reset(new QSocketNotifier(m_sighupFd[1], QSocketNotifier::Read, this));
connect(m_snHup.get(), SIGNAL(activated(int)), this, SLOT(handleSigHup()));
}
}
{}
//
// All this signal handling code is taken from Qt's Best Practices:
@ -67,6 +51,7 @@ void MBooster::hupSignalHandler(int)
void MBooster::handleSigHup()
{
MApplication::quit();
::_exit(EXIT_SUCCESS);
}
@ -146,26 +131,48 @@ bool MBooster::receiveDataFromInvoker()
// Setup the conversation channel with the invoker.
setConnection(new Connection(socketId()));
// exit from event loop when invoker is ready to connect
// Exit from event loop when invoker is ready to connect
connect(this, SIGNAL(connectionAccepted()), MApplication::instance() , SLOT(quit()));
// enable theme change handler
// Enable theme change handler
m_item = new MGConfItem(MEEGOTOUCH_THEME_GCONF_KEY, 0);
connect(m_item, SIGNAL(valueChanged()), this, SLOT(notifyThemeChange()));
// start another thread to listen connection from invoker
// Start another thread to listen connection from invoker
QtConcurrent::run(this, &MBooster::accept);
// Create socket pair for SIGHUP
bool handlerIsSet = false;
if (::socketpair(AF_UNIX, SOCK_STREAM, 0, m_sighupFd))
{
Logger::logError("MBooster: Couldn't create HUP socketpair");
}
else
{
// Install signal handler e.g. to exit cleanly if launcher dies.
// This is a problem because MBooster runs a Qt event loop.
setupUnixSignalHandlers();
// Install a socket notifier on the socket
connect(new QSocketNotifier(m_sighupFd[1], QSocketNotifier::Read, this),
SIGNAL(activated(int)), this, SLOT(handleSigHup()));
handlerIsSet = true;
}
// Run event loop so MApplication and MApplicationWindow objects can receive notifications
MApplication::exec();
// disable theme change handler
// Disable theme change handler
disconnect(m_item, 0, this, 0);
delete m_item;
m_item = NULL;
// Restore signal handlers to previous values
restoreUnixSignalHandlers();
if (handlerIsSet)
{
restoreUnixSignalHandlers();
}
// Receive application data from the invoker
if(!connection()->receiveApplicationData(appData()))

@ -142,7 +142,6 @@ private slots:
//! Qt signal handler for theme change
void notifyThemeChange();
signals:
void connectionAccepted();

@ -25,7 +25,6 @@
#include <MApplication>
#include <sys/socket.h>
#ifdef HAVE_MCOMPONENTCACHE
#include <mcomponentcache.h>
#endif
@ -41,23 +40,7 @@ int WRTBooster::m_sighupFd[2];
struct sigaction WRTBooster::m_oldSigAction;
WRTBooster::WRTBooster() : m_item(0)
{
// Install signals handler e.g. to exit cleanly if launcher dies.
// This is a problem because WRTBooster runs a Qt event loop.
setupUnixSignalHandlers();
// Create socket pair for SIGTERM
if (::socketpair(AF_UNIX, SOCK_STREAM, 0, m_sighupFd))
{
Logger::logError("Couldn't create HUP socketpair");
}
else
{
// Install a socket notifier on the socket
m_snHup.reset(new QSocketNotifier(m_sighupFd[1], QSocketNotifier::Read, this));
connect(m_snHup.get(), SIGNAL(activated(int)), this, SLOT(handleSigHup()));
}
}
{}
//
// All this signal handling code is taken from Qt's Best Practices:
@ -72,6 +55,7 @@ void WRTBooster::hupSignalHandler(int)
void WRTBooster::handleSigHup()
{
MApplication::quit();
::_exit(EXIT_SUCCESS);
}
@ -163,6 +147,25 @@ bool WRTBooster::receiveDataFromInvoker()
// Start another thread to listen connection from invoker
QtConcurrent::run(this, &WRTBooster::accept);
// Create socket pair for SIGHUP
bool handlerIsSet = false;
if (::socketpair(AF_UNIX, SOCK_STREAM, 0, m_sighupFd))
{
Logger::logError("WRTBooster: Couldn't create HUP socketpair");
}
else
{
// Install signal handler e.g. to exit cleanly if launcher dies.
// This is a problem because MBooster runs a Qt event loop.
setupUnixSignalHandlers();
// Install a socket notifier on the socket
connect(new QSocketNotifier(m_sighupFd[1], QSocketNotifier::Read, this),
SIGNAL(activated(int)), this, SLOT(handleSigHup()));
handlerIsSet = true;
}
// Run event loop so MApplication and MApplicationWindow objects can receive notifications
MApplication::exec();
@ -172,7 +175,10 @@ bool WRTBooster::receiveDataFromInvoker()
m_item = NULL;
// Restore signal handlers to previous values
restoreUnixSignalHandlers();
if (handlerIsSet)
{
restoreUnixSignalHandlers();
}
// Receive application data from the invoker
if(!connection()->receiveApplicationData(appData()))

@ -1,11 +1,10 @@
set(LAUNCHER ${CMAKE_HOME_DIRECTORY}/src/launcherlib)
# Set sources
set(SRC ut_mbooster.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp ${LAUNCHER}/connection.cpp
${LAUNCHER}/logger.cpp ${LAUNCHER}/mbooster.cpp)
set(SRC ut_mbooster.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp ${LAUNCHER}/connection.cpp ${LAUNCHER}/logger.cpp ${LAUNCHER}/mbooster.cpp)
# Set moc headers
set(MOC_HDRS ut_mbooster.h ${LAUNCHER}/mbooster.h)
set(MOC_HDRS ut_mbooster.h ${LAUNCHER}/mbooster.h)
# Run moc
qt4_wrap_cpp(MOC_SRC ${MOC_HDRS})

@ -1,11 +1,10 @@
set(LAUNCHER ${CMAKE_HOME_DIRECTORY}/src/launcherlib)
# Set sources
set(SRC ut_wrtbooster.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp ${LAUNCHER}/connection.cpp
${LAUNCHER}/logger.cpp ${LAUNCHER}/wrtbooster.cpp)
set(SRC ut_wrtbooster.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp ${LAUNCHER}/connection.cpp ${LAUNCHER}/logger.cpp ${LAUNCHER}/wrtbooster.cpp)
# Set moc headers
set(MOC_HDRS ut_wrtbooster.h ${LAUNCHER}/wrtbooster.h)
set(MOC_HDRS ut_wrtbooster.h ${LAUNCHER}/wrtbooster.h)
# Run moc
qt4_wrap_cpp(MOC_SRC ${MOC_HDRS})

Loading…
Cancel
Save