[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/runtime/nepomuk/server
From: Sebastian Trueg <sebastian () trueg ! de>
Date: 2008-07-07 9:08:33
Message-ID: 1215421713.790910.14639.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 829017 by trueg:
Only restart a crashing service N times
M +4 -7 processcontrol.cpp
M +9 -9 processcontrol.h
--- trunk/KDE/kdebase/runtime/nepomuk/server/processcontrol.cpp #829016:829017
@@ -42,13 +42,14 @@
stop();
}
-bool ProcessControl::start( const QString &application, const QStringList \
&arguments, CrashPolicy policy ) +bool ProcessControl::start( const QString \
&application, const QStringList &arguments, CrashPolicy policy, int maxCrash ) {
mFailedToStart = false;
mApplication = application;
mArguments = arguments;
mPolicy = policy;
+ mCrashCount = maxCrash;
return start();
}
@@ -87,7 +88,8 @@
{
if ( exitStatus == QProcess::CrashExit ) {
if ( mPolicy == RestartOnCrash ) {
- if ( !mFailedToStart ) // don't try to start an unstartable application
+ // don't try to start an unstartable application
+ if ( !mFailedToStart && --mCrashCount >= 0 )
start();
else
emit finished(false);
@@ -129,11 +131,6 @@
qDebug() << mApplication << "[out]" << message;
}
-void ProcessControl::resetCrashCount()
-{
- mCrashCount = 0;
-}
-
bool ProcessControl::isRunning() const
{
return mProcess.state() == QProcess::Running;
--- trunk/KDE/kdebase/runtime/nepomuk/server/processcontrol.h #829016:829017
@@ -1,5 +1,6 @@
/***************************************************************************
* Copyright (C) 2006 by Tobias Koenig <tokoe@kde.org> *
+ * Copyright (C) 2008 by Sebastian Trueg <trueg@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License as *
@@ -30,9 +31,9 @@
*/
class ProcessControl : public QObject
{
- Q_OBJECT
+ Q_OBJECT
- public:
+public:
/**
* Theses enums describe the behaviour when the observed
* application crashed.
@@ -42,8 +43,8 @@
*/
enum CrashPolicy
{
- StopOnCrash,
- RestartOnCrash
+ StopOnCrash,
+ RestartOnCrash
};
/**
@@ -62,7 +63,7 @@
* Starts the @p application with the given list of @p arguments.
*/
bool start( const QString &application, const QStringList &arguments = \
QStringList(),
- CrashPolicy policy = RestartOnCrash );
+ CrashPolicy policy = RestartOnCrash, int maxCrashes = 5 );
/**
* Stops the currently running application.
@@ -76,7 +77,7 @@
bool isRunning() const;
- Q_SIGNALS:
+Q_SIGNALS:
/**
* This signal is emitted whenever the observed application
* writes something to stderr.
@@ -87,14 +88,13 @@
void finished( bool clean );
- private Q_SLOTS:
+private Q_SLOTS:
void slotError( QProcess::ProcessError );
void slotFinished( int, QProcess::ExitStatus );
void slotErrorMessages();
void slotStdoutMessages();
- void resetCrashCount();
- private:
+private:
bool start();
QProcess mProcess;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic