Changes: Minor refactoring.

Details: Error messages improved / added, useless variables removed.
pull/1/head
Jussi Lind 15 years ago
parent f1871eeca2
commit 1d91fccf7f

@ -74,8 +74,10 @@ void Booster::initialize(int initialArgc, char ** initialArgv, int newPipeFd[2])
popPriority(); popPriority();
// Wait and read commands from the invoker // Wait and read commands from the invoker
Logger::logNotice("Daemon: Wait for message from invoker"); Logger::logNotice("Booster: Wait for message from invoker");
readCommand(); if (!readCommand()) {
Logger::logError("Booster: Couldn't read command\n");
}
// Give the process the real application name now that it // Give the process the real application name now that it
// has been read from invoker in readCommand(). // has been read from invoker in readCommand().
@ -84,15 +86,13 @@ void Booster::initialize(int initialArgc, char ** initialArgv, int newPipeFd[2])
// Signal the parent process that it can create a new // Signal the parent process that it can create a new
// waiting booster process and close write end // waiting booster process and close write end
const char msg = boosterType(); const char msg = boosterType();
ssize_t ret = write(pipeFd(1), reinterpret_cast<const void *>(&msg), 1); if (write(pipeFd(1), reinterpret_cast<const void *>(&msg), 1) == -1) {
if (ret == -1) {
Logger::logError("Booster: Couldn't send type message to launcher process\n"); Logger::logError("Booster: Couldn't send type message to launcher process\n");
} }
// Send to the parent process pid of invoker for tracking // Send to the parent process pid of invoker for tracking
pid_t pid = invokersPid(); pid_t pid = invokersPid();
ret = write(pipeFd(1), reinterpret_cast<const void *>(&pid), sizeof(pid_t)); if (write(pipeFd(1), reinterpret_cast<const void *>(&pid), sizeof(pid_t)) == -1) {
if (ret == -1) {
Logger::logError("Booster: Couldn't send invoker's pid to launcher process\n"); Logger::logError("Booster: Couldn't send invoker's pid to launcher process\n");
} }
@ -121,13 +121,15 @@ bool Booster::readCommand()
// Accept a new invocation. // Accept a new invocation.
if (m_conn->acceptConn(m_app)) if (m_conn->acceptConn(m_app))
{ {
bool res = m_conn->receiveApplicationData(m_app); // Receive application data from the invoker
if(!res) if(!m_conn->receiveApplicationData(m_app))
{ {
m_conn->closeConn(); m_conn->closeConn();
return false; return false;
} }
// Close the connection if exit status doesn't need
// to be sent back to invoker
if (!m_conn->isReportAppExitStatusNeeded()) if (!m_conn->isReportAppExitStatusNeeded())
{ {
m_conn->closeConn(); m_conn->closeConn();

@ -573,7 +573,7 @@ bool Connection::receiveActions()
return true; return true;
default: default:
Logger::logError("Connection: receiving invalid action (%08x)\n", action); Logger::logError("Connection: received invalid action (%08x)\n", action);
return false; return false;
} }
} }
@ -584,12 +584,18 @@ bool Connection::receiveApplicationData(AppData & rApp)
// Read magic number // Read magic number
rApp.setOptions(receiveMagic()); rApp.setOptions(receiveMagic());
if (rApp.options() == -1) if (rApp.options() == -1)
{
Logger::logError("Connection: receiving magic failed\n");
return false; return false;
}
// Read application name // Read application name
rApp.setAppName(receiveAppName()); rApp.setAppName(receiveAppName());
if (rApp.appName().empty()) if (rApp.appName().empty())
{
Logger::logError("Connection: receiving application name failed\n");
return false; return false;
}
// Read application parameters // Read application parameters
if (receiveActions()) if (receiveActions())
@ -604,13 +610,14 @@ bool Connection::receiveApplicationData(AppData & rApp)
} }
else else
{ {
Logger::logError("Connection: receiving application parameters failed\n");
return false; return false;
} }
return true; return true;
} }
bool Connection::isReportAppExitStatusNeeded() bool Connection::isReportAppExitStatusNeeded() const
{ {
return m_sendPid; return m_sendPid;
} }

@ -78,7 +78,7 @@ public:
bool receiveApplicationData(AppData & rApp); bool receiveApplicationData(AppData & rApp);
//! \brief Return true if invoker wait for process exit status //! \brief Return true if invoker wait for process exit status
bool isReportAppExitStatusNeeded(); bool isReportAppExitStatusNeeded() const;
//! \brief Send application exit status to invoker //! \brief Send application exit status to invoker
bool sendAppExitStatus(int status); bool sendAppExitStatus(int status);

Loading…
Cancel
Save