Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions cinnamon-session/csm-app.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,18 +510,23 @@ csm_app_restart (CsmApp *app,
GTimeVal current_time;
g_debug ("Re-starting app: %s", app->priv->id);

g_get_current_time (&current_time);
if (app->priv->last_restart_time.tv_sec > 0
&& (current_time.tv_sec - app->priv->last_restart_time.tv_sec) < _CSM_APP_RESPAWN_RATELIMIT_SECONDS) {
g_warning ("App '%s' respawning too quickly", csm_app_peek_app_id (app));
g_set_error (error,
CSM_APP_ERROR,
CSM_APP_ERROR_RESTART_LIMIT,
"Component '%s' crashing too quickly",
csm_app_peek_app_id (app));
return FALSE;
// Cinnamon is *not* autorestart, we will only force it to via dbus RestartCinnamonLauncher
// and don't want that to be skipped for some reason if it happens multiple times within a minute.
// (This shouldn't ever happen anyhow).
if (g_strcmp0 (app->priv->app_id, "cinnamon.desktop") != 0) {
g_get_current_time (&current_time);
if (app->priv->last_restart_time.tv_sec > 0
&& (current_time.tv_sec - app->priv->last_restart_time.tv_sec) < _CSM_APP_RESPAWN_RATELIMIT_SECONDS) {
g_warning ("App '%s' respawning too quickly", csm_app_peek_app_id (app));
g_set_error (error,
CSM_APP_ERROR,
CSM_APP_ERROR_RESTART_LIMIT,
"Component '%s' crashing too quickly",
csm_app_peek_app_id (app));
return FALSE;
}
app->priv->last_restart_time = current_time;
}
app->priv->last_restart_time = current_time;

return CSM_APP_GET_CLASS (app)->impl_restart (app, error);
}
Expand Down
7 changes: 7 additions & 0 deletions cinnamon-session/csm-consolekit.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@
{
CsmConsolekit *manager = CSM_CONSOLEKIT (system);

/* Use Stop insetad of PowerOff because it will work with

Check failure on line 401 in cinnamon-session/csm-consolekit.c

View workflow job for this annotation

GitHub Actions / build / build (mint22, linuxmintd/mint22-amd64, Mint 22, true) / Mint 22

insetad ==> instead
* Ck and CK2. */
g_dbus_proxy_call (manager->priv->ck_proxy,
"Stop",
Expand Down Expand Up @@ -859,6 +859,12 @@
return FALSE;
}

static gchar *
csm_consolekit_get_login_session_id (CsmSystem *system)
{
return NULL;
}

static void
csm_consolekit_system_init (CsmSystemInterface *iface)
{
Expand All @@ -876,6 +882,7 @@
iface->add_inhibitor = csm_consolekit_add_inhibitor;
iface->remove_inhibitor = csm_consolekit_remove_inhibitor;
iface->is_last_session_for_user = csm_consolekit_is_last_session_for_user;
iface->get_login_session_id = csm_consolekit_get_login_session_id;
}

CsmConsolekit *
Expand Down
61 changes: 60 additions & 1 deletion cinnamon-session/csm-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
* want to wait, at least for something happening more than once.
* We can get deployed on very slow media though like CDROM devices,
* often with complex stacking/compressing filesystems on top, which
* is not a recipie for speed. Particularly now that we throw up

Check failure on line 70 in cinnamon-session/csm-manager.c

View workflow job for this annotation

GitHub Actions / build / build (mint22, linuxmintd/mint22-amd64, Mint 22, true) / Mint 22

recipie ==> recipe
* a fail whale if required components don't show up quickly enough,
* let's make this fairly long.
*/
Expand Down Expand Up @@ -1598,6 +1598,17 @@
session_name);
}

void
_csm_manager_export_login_session_id (CsmManager *manager)
{
g_autofree gchar *session_id = NULL;

session_id = csm_system_get_login_session_id (manager->priv->system);

csm_exported_manager_set_session_id (manager->priv->skeleton,
session_id);
}

static gboolean
_app_has_app_id (const char *id,
CsmApp *app,
Expand Down Expand Up @@ -1695,6 +1706,29 @@
return found_app;
}

static gboolean
restart_cinnamon_launcher (CsmManager *manager)
{
CsmApp *app;

app = find_app_for_app_id (manager, "cinnamon.desktop");

if (app) {
GError *error = NULL;

g_debug ("CsmManager: Restarting cinnamon-launcher");

if (!csm_app_restart (app, &error)) {
g_warning ("CsmManager: Unable to restart cinnamon-launcher: %s", error->message);
g_error_free (error);
}
} else {
g_warning ("CsmManager: Unable to find the cinnamon-launcher");
}

return G_SOURCE_REMOVE;
}

static gboolean
csm_manager_setenv (CsmExportedManager *skeleton,
GDBusMethodInvocation *invocation,
Expand Down Expand Up @@ -2348,6 +2382,30 @@
return TRUE;
}

static gboolean
csm_manager_restart_cinnamon_launcher (CsmExportedManager *skeleton,
GDBusMethodInvocation *invocation,
CsmManager *manager)
{
g_debug ("CsmManager: RestartCinnamonLauncher called");

if (manager->priv->phase != CSM_MANAGER_PHASE_RUNNING) {
g_dbus_method_invocation_return_error (invocation,
CSM_MANAGER_ERROR,
CSM_MANAGER_ERROR_NOT_IN_RUNNING,
"RestartCinnamonLauncher interface is only available during the Running phase");

return TRUE;
}

g_idle_add ((GSourceFunc)restart_cinnamon_launcher, manager);

csm_exported_manager_complete_restart_cinnamon_launcher (skeleton,
invocation);

return TRUE;
}

static void
_disconnect_client (CsmManager *manager,
CsmClient *client)
Expand Down Expand Up @@ -2759,7 +2817,8 @@
{ "handle-logout", csm_manager_logout_dbus },
{ "handle-is-session-running", csm_manager_is_session_running },
{ "handle-request-shutdown", csm_manager_request_shutdown },
{ "handle-request-reboot", csm_manager_request_reboot }
{ "handle-request-reboot", csm_manager_request_reboot },
{ "handle-restart-cinnamon-launcher", csm_manager_restart_cinnamon_launcher }
};

static SkeletonSignal dialog_skeleton_signals[] = {
Expand Down
2 changes: 2 additions & 0 deletions cinnamon-session/csm-manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ void _csm_manager_set_active_session (CsmManager *
const char *session_name,
gboolean is_fallback);

void _csm_manager_export_login_session_id (CsmManager *manager);

gboolean csm_manager_set_phase (CsmManager *manager,
CsmManagerPhase phase);

Expand Down
1 change: 1 addition & 0 deletions cinnamon-session/csm-session-fill.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ csm_session_fill (CsmManager *manager,
}

_csm_manager_set_active_session (manager, actual_session, is_fallback);
_csm_manager_export_login_session_id (manager);

g_free (actual_session);

Expand Down
6 changes: 6 additions & 0 deletions cinnamon-session/csm-system.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ csm_system_is_last_session_for_user (CsmSystem *system)
return CSM_SYSTEM_GET_IFACE (system)->is_last_session_for_user (system);
}

gchar *
csm_system_get_login_session_id (CsmSystem *system)
{
return CSM_SYSTEM_GET_IFACE (system)->get_login_session_id (system);
}

CsmSystem *
csm_get_system (void)
{
Expand Down
3 changes: 2 additions & 1 deletion cinnamon-session/csm-system.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct _CsmSystemInterface
void (* remove_inhibitor) (CsmSystem *system,
const gchar *id);
gboolean (* is_last_session_for_user) (CsmSystem *system);
gchar * (* get_login_session_id) (CsmSystem *system);
};

enum _CsmSystemError {
Expand Down Expand Up @@ -119,7 +120,7 @@ void csm_system_add_inhibitor (CsmSystem *system,

void csm_system_remove_inhibitor (CsmSystem *system,
const gchar *id);

gchar *csm_system_get_login_session_id (CsmSystem *system);
G_END_DECLS

#endif /* __CSM_SYSTEM_H__ */
21 changes: 21 additions & 0 deletions cinnamon-session/csm-systemd.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,26 @@ csm_systemd_is_last_session_for_user (CsmSystem *system)
return is_last_session;
}

static gchar *
csm_systemd_get_login_session_id (CsmSystem *system)
{
CsmSystemd *manager = CSM_SYSTEMD (system);

gchar *pid_session;
gint ret;

ret = sd_pid_get_session (getpid (), &pid_session);

if (ret < 0) {
g_printerr ("can't get login session id for cinnamon-session. errno: %d\n", -ret);
return NULL;
}

g_debug ("Login session ID is: %s\n", pid_session);

return pid_session;
}

static void
csm_systemd_system_init (CsmSystemInterface *iface)
{
Expand All @@ -737,6 +757,7 @@ csm_systemd_system_init (CsmSystemInterface *iface)
iface->add_inhibitor = csm_systemd_add_inhibitor;
iface->remove_inhibitor = csm_systemd_remove_inhibitor;
iface->is_last_session_for_user = csm_systemd_is_last_session_for_user;
iface->get_login_session_id = csm_systemd_get_login_session_id;
}

CsmSystemd *
Expand Down
15 changes: 15 additions & 0 deletions cinnamon-session/org.gnome.SessionManager.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
</arg>
<arg type="u" name="flags" direction="in">
<doc:doc>
<doc:summary>Flags that spefify what should be inhibited</doc:summary>

Check failure on line 100 in cinnamon-session/org.gnome.SessionManager.xml

View workflow job for this annotation

GitHub Actions / build / build (mint22, linuxmintd/mint22-amd64, Mint 22, true) / Mint 22

spefify ==> specify
</doc:doc>
</arg>
<arg type="u" name="inhibit_cookie" direction="out">
Expand Down Expand Up @@ -175,7 +175,7 @@
<method name="IsInhibited">
<arg type="u" name="flags" direction="in">
<doc:doc>
<doc:summary>Flags that spefify what should be inhibited</doc:summary>

Check failure on line 178 in cinnamon-session/org.gnome.SessionManager.xml

View workflow job for this annotation

GitHub Actions / build / build (mint22, linuxmintd/mint22-amd64, Mint 22, true) / Mint 22

spefify ==> specify
</doc:doc>
</arg>
<arg type="b" name="is_inhibited" direction="out">
Expand Down Expand Up @@ -431,5 +431,20 @@
</doc:doc>
</property>

<property name="SessionId" type="s" access="read">
<doc:doc>
<doc:description>
<doc:para>The login session ID of cinnamon-session.</doc:para>
</doc:description>
</doc:doc>
</property>

<method name="RestartCinnamonLauncher">
<doc:doc>
<doc:description>
<doc:para>Launches cinnamon-launcher for current session.</doc:para>
</doc:description>
</doc:doc>
</method>
</interface>
</node>
Loading