libs: fix ksysguard build after f1cfe7bd

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2016-04-30 16:43:46 +00:00
parent f1cfe7bdba
commit bc2d42f12a
2 changed files with 10 additions and 12 deletions

View file

@ -51,10 +51,10 @@ bool SensorShellAgent::start( const QString &host, const QString &shell,
{ {
mDaemon = new QProcess(); mDaemon = new QProcess();
mDaemon->setProcessChannelMode( QProcess::SeparateChannels ); mDaemon->setProcessChannelMode( QProcess::SeparateChannels );
mRetryCount=3;
setHostName( host ); setHostName( host );
mShell = shell; mShell = shell;
mCommand = command; mCommand = command;
mArgs.clear();
connect( mDaemon, SIGNAL(error(QProcess::ProcessError)), connect( mDaemon, SIGNAL(error(QProcess::ProcessError)),
SLOT(daemonError(QProcess::ProcessError)) ); SLOT(daemonError(QProcess::ProcessError)) );
@ -67,9 +67,11 @@ bool SensorShellAgent::start( const QString &host, const QString &shell,
if ( !command.isEmpty() ) { if ( !command.isEmpty() ) {
QStringList args = KShell::splitArgs(command); QStringList args = KShell::splitArgs(command);
mArgs = args.join(" ");
QString program = args.takeAt(0); QString program = args.takeAt(0);
mDaemon->start(program, args); mDaemon->start(program, args);
} else { } else {
mArgs = mShell + " " + hostName() + " ksysguardd";
mDaemon->start(mShell, QStringList() << hostName() << "ksysguardd"); mDaemon->start(mShell, QStringList() << hostName() << "ksysguardd");
} }
@ -88,7 +90,6 @@ void SensorShellAgent::hostInfo( QString &shell, QString &command,
void SensorShellAgent::msgRcvd( ) void SensorShellAgent::msgRcvd( )
{ {
QByteArray buffer = mDaemon->readAllStandardOutput(); QByteArray buffer = mDaemon->readAllStandardOutput();
mRetryCount = 3; //we received an answer, so reset our retry count back to 3
processAnswer( buffer.constData(), buffer.size()); processAnswer( buffer.constData(), buffer.size());
} }
@ -109,12 +110,9 @@ void SensorShellAgent::daemonExited( int exitCode, QProcess::ExitStatus exitSta
{ {
Q_UNUSED(exitCode); Q_UNUSED(exitCode);
kDebug(1215) << "daemon exited, exit status " << exitStatus; kDebug(1215) << "daemon exited, exit status " << exitStatus;
if ( mRetryCount-- <= 0 || (mDaemon->start(), !mDaemon->waitForStarted()) ) setDaemonOnLine( false );
{ if(sensorManager()) {
setDaemonOnLine( false ); sensorManager()->disengage( this ); //delete ourselves
if(sensorManager()) {
sensorManager()->disengage( this ); //delete ourselves
}
} }
} }
@ -123,15 +121,15 @@ void SensorShellAgent::daemonError( QProcess::ProcessError errorStatus )
QString error; QString error;
switch(errorStatus) { switch(errorStatus) {
case QProcess::FailedToStart: case QProcess::FailedToStart:
kDebug(1215) << "failed to run" << mDaemon->program().join(" "); kDebug(1215) << "failed to run" << mArgs;
error = i18n("Could not run daemon program '%1'.", mDaemon->program().join(" ")); error = i18n("Could not run daemon program '%1'.", mArgs);
break; break;
case QProcess::Crashed: case QProcess::Crashed:
case QProcess::Timedout: case QProcess::Timedout:
case QProcess::WriteError: case QProcess::WriteError:
case QProcess::ReadError: case QProcess::ReadError:
default: default:
error = i18n("The daemon program '%1' failed.", mDaemon->program().join(" ")); error = i18n("The daemon program '%1' failed.", mArgs);
} }
setReasonForOffline(error); setReasonForOffline(error);
kDebug(1215) << "Error received " << error << "(" << errorStatus << ")"; kDebug(1215) << "Error received " << error << "(" << errorStatus << ")";

View file

@ -62,10 +62,10 @@ class SensorShellAgent : public SensorAgent
private: private:
bool writeMsg( const char *msg, int len ); bool writeMsg( const char *msg, int len );
int mRetryCount;
QPointer<QProcess> mDaemon; QPointer<QProcess> mDaemon;
QString mShell; QString mShell;
QString mCommand; QString mCommand;
QString mArgs;
}; };
} }