summaryrefslogtreecommitdiff
path: root/mate-session/gsm-app.c
diff options
context:
space:
mode:
Diffstat (limited to 'mate-session/gsm-app.c')
-rw-r--r--mate-session/gsm-app.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/mate-session/gsm-app.c b/mate-session/gsm-app.c
index 0260b21..c37480e 100644
--- a/mate-session/gsm-app.c
+++ b/mate-session/gsm-app.c
@@ -30,11 +30,15 @@
#include "gsm-app.h"
#include "org.gnome.SessionManager.App.h"
+/* If a component crashes twice within a minute, we count that as a fatal error */
+#define _GSM_APP_RESPAWN_RATELIMIT_SECONDS 60
+
typedef struct {
char *id;
char *app_id;
int phase;
char *startup_id;
+ gint64 last_restart_time;
GDBusConnection *connection;
GsmExportedApp *skeleton;
} GsmAppPrivate;
@@ -522,9 +526,24 @@ gsm_app_restart (GsmApp *app,
GError **error)
{
GsmAppPrivate *priv;
+ gint64 current_time;
priv = gsm_app_get_instance_private (app);
+ current_time = g_get_real_time ();
+
+ if (priv->last_restart_time > 0
+ && (current_time - priv->last_restart_time) < _GSM_APP_RESPAWN_RATELIMIT_SECONDS * G_USEC_PER_SEC) {
+ g_warning ("App '%s' respawning too quickly", priv->app_id ? priv->app_id : priv->id);
+ g_set_error (error,
+ GSM_APP_ERROR,
+ GSM_APP_ERROR_GENERAL,
+ "Component '%s' crashing too quickly",
+ priv->app_id ? priv->app_id : priv->id);
+ return FALSE;
+ }
+ priv->last_restart_time = current_time;
+
g_debug ("Re-starting app: %s", priv->id);
return GSM_APP_GET_CLASS (app)->impl_restart (app, error);