[Xfce4-commits] [xfce/xfce4-session] 02/02: Introduce priority-group startup for FailSafe Session
noreply at xfce.org
noreply at xfce.org
Fri May 17 14:46:36 CEST 2019
This is an automated email from the git hooks/post-receive script.
o c h o s i p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository xfce/xfce4-session.
commit 0a915310582803296fbfb075e1ea1c045b20bfcc
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date: Fri May 17 14:41:33 2019 +0200
Introduce priority-group startup for FailSafe Session
The FailSafe Session previously simply started all applications listed
in the xfce4-sesion.xml file at once, leading to race conditions with
effects like unthemed xfce4-panels etc. (See Bug #15388)
The new FailSafe Session implementation introduces the feature of
"Priority Groups" that was already present for saved sessions and uses
the same startup mechanism. This means that all applications in one
priority group have to be launched until the applications from the next
priority group can get launched, thus mitigating the racy startup of the
old FailSafe Session.
As we cannot uniquely identify or track starting
applications in the FailSafe Session we simply count the amount of
applications per priority group and launch all applications per group at once.
---
settings/xfce4-session.xml | 5 ++++
xfce4-session/xfsm-global.c | 8 ------
xfce4-session/xfsm-global.h | 10 --------
xfce4-session/xfsm-manager.c | 58 +++++++++++++++++++++++++++++++-------------
xfce4-session/xfsm-manager.h | 3 ++-
xfce4-session/xfsm-startup.c | 39 +++++++----------------------
xfce4-session/xfsm-startup.h | 1 -
7 files changed, 57 insertions(+), 67 deletions(-)
diff --git a/settings/xfce4-session.xml b/settings/xfce4-session.xml
index acb5afe..66d28df 100644
--- a/settings/xfce4-session.xml
+++ b/settings/xfce4-session.xml
@@ -12,23 +12,28 @@
<property name="Client0_Command" type="array">
<value type="string" value="xfwm4"/>
</property>
+ <property name="Client0_Priority" type="int" value="15"/>
<property name="Client0_PerScreen" type="bool" value="false"/>
<property name="Client1_Command" type="array">
<value type="string" value="xfsettingsd"/>
</property>
+ <property name="Client1_Priority" type="int" value="20"/>
<property name="Client1_PerScreen" type="bool" value="false"/>
<property name="Client2_Command" type="array">
<value type="string" value="xfce4-panel"/>
</property>
+ <property name="Client2_Priority" type="int" value="25"/>
<property name="Client2_PerScreen" type="bool" value="false"/>
<property name="Client3_Command" type="array">
<value type="string" value="Thunar"/>
<value type="string" value="--daemon"/>
</property>
+ <property name="Client3_Priority" type="int" value="30"/>
<property name="Client3_PerScreen" type="bool" value="false"/>
<property name="Client4_Command" type="array">
<value type="string" value="xfdesktop"/>
</property>
+ <property name="Client4_Priority" type="int" value="35"/>
<property name="Client4_PerScreen" type="bool" value="false"/>
</property>
</property>
diff --git a/xfce4-session/xfsm-global.c b/xfce4-session/xfsm-global.c
index 41fdb66..1f8a182 100644
--- a/xfce4-session/xfsm-global.c
+++ b/xfce4-session/xfsm-global.c
@@ -59,14 +59,6 @@
/* global variables */
gboolean verbose = FALSE;
-void
-xfsm_failsafe_client_free (FailsafeClient *fclient)
-{
- if (fclient->command)
- g_strfreev (fclient->command);
- g_free (fclient);
-}
-
void
xfsm_enable_verbose (void)
diff --git a/xfce4-session/xfsm-global.h b/xfce4-session/xfsm-global.h
index abda5e7..f70884a 100644
--- a/xfce4-session/xfsm-global.h
+++ b/xfce4-session/xfsm-global.h
@@ -30,19 +30,9 @@
#include "settings/xfae-model.h" /* XfsmRunHook */
-typedef struct _FailsafeClient FailsafeClient;
-struct _FailsafeClient
-{
- gchar **command;
- GdkScreen *screen;
-};
-
-void xfsm_failsafe_client_free (FailsafeClient *fclient);
-
#define DEFAULT_SESSION_NAME "Default"
-
extern gboolean verbose;
#if defined(G_HAVE_ISO_VARARGS)
diff --git a/xfce4-session/xfsm-manager.c b/xfce4-session/xfsm-manager.c
index 456cae9..43659a9 100644
--- a/xfce4-session/xfsm-manager.c
+++ b/xfce4-session/xfsm-manager.c
@@ -93,7 +93,7 @@ struct _XfsmManager
GQueue *running_clients;
gboolean failsafe_mode;
- GQueue *failsafe_clients;
+ gint failsafe_clients_pending;
guint die_timeout_id;
guint name_owner_id;
@@ -190,7 +190,7 @@ xfsm_manager_init (XfsmManager *manager)
manager->starting_properties = g_queue_new ();
manager->restart_properties = g_queue_new ();
manager->running_clients = g_queue_new ();
- manager->failsafe_clients = g_queue_new ();
+ manager->failsafe_clients_pending = 0;
}
static void
@@ -217,9 +217,6 @@ xfsm_manager_finalize (GObject *obj)
g_queue_foreach (manager->running_clients, (GFunc) G_CALLBACK (g_object_unref), NULL);
g_queue_free (manager->running_clients);
- g_queue_foreach (manager->failsafe_clients, (GFunc) G_CALLBACK (xfsm_failsafe_client_free), NULL);
- g_queue_free (manager->failsafe_clients);
-
g_free (manager->session_name);
g_free (manager->session_file);
g_free (manager->checkpoint_session_name);
@@ -548,15 +545,20 @@ xfsm_manager_load_failsafe (XfsmManager *manager,
XfconfChannel *channel,
gchar **error)
{
- FailsafeClient *fclient;
+ XfsmProperties *properties;
gchar *failsafe_name;
gchar propbuf[4096];
+ gchar *hostname;
+ gchar *client_id = NULL;
gchar **command;
gchar command_entry[256];
- gchar screen_entry[256];
+ gchar priority_entry[256];
+ gint priority;
gint count;
gint i;
+ hostname = xfce_gethostname ();
+
failsafe_name = xfconf_channel_get_string (channel, "/general/FailsafeSessionName", NULL);
if (G_UNLIKELY (!failsafe_name))
{
@@ -584,22 +586,25 @@ xfsm_manager_load_failsafe (XfsmManager *manager,
for (i = 0; i < count; ++i)
{
+ properties = xfsm_properties_new (client_id, hostname);
g_snprintf (command_entry, sizeof (command_entry),
"/sessions/%s/Client%d_Command", failsafe_name, i);
command = xfconf_channel_get_string_list (channel, command_entry);
if (G_UNLIKELY (command == NULL))
continue;
- g_snprintf (screen_entry, sizeof (screen_entry),
- "/sessions/%s/Client%d_PerScreen", failsafe_name, i);
+ g_snprintf (priority_entry, sizeof (priority_entry),
+ "/sessions/%s/Client%d_Priority", failsafe_name, i);
+ priority = xfconf_channel_get_int (channel, priority_entry, 50);
- fclient = g_new0 (FailsafeClient, 1);
- fclient->command = command;
- fclient->screen = gdk_screen_get_default ();
- g_queue_push_tail (manager->failsafe_clients, fclient);
+ xfsm_properties_set_string (properties, SmProgram, command[0]);
+ xfsm_properties_set_strv (properties, SmRestartCommand, g_strdupv(command));
+ xfsm_properties_set_uchar (properties, GsmPriority, priority);
+ g_queue_push_tail (manager->pending_properties, properties);
}
+ g_queue_sort (manager->pending_properties, (GCompareDataFunc) G_CALLBACK (xfsm_properties_compare), NULL);
- if (g_queue_peek_head (manager->failsafe_clients) == NULL)
+ if (g_queue_peek_head (manager->pending_properties) == NULL)
{
if (error)
*error = g_strdup (_("The list of applications in the failsafe session is empty."));
@@ -974,6 +979,9 @@ xfsm_manager_register_client (XfsmManager *manager,
}
else
{
+ xfsm_verbose ("No previous_id found.\n");
+ if (manager->failsafe_mode)
+ xfsm_verbose ("Plus, we're obviously running in failsafe mode.\n");
if (sms_conn != NULL)
{
/* new sms client */
@@ -989,6 +997,9 @@ xfsm_manager_register_client (XfsmManager *manager,
/* this part is for dbus clients */
if (dbus_client_id != NULL)
{
+ xfsm_verbose ("dbus_client_id found: %s.\n", dbus_client_id);
+ if (manager->failsafe_mode)
+ xfsm_verbose ("Plus, we're obviously running in failsafe mode.\n");
properties = xfsm_manager_get_pending_properties (manager, dbus_client_id);
if (properties != NULL)
@@ -1008,6 +1019,8 @@ xfsm_manager_register_client (XfsmManager *manager,
g_free (hostname);
}
}
+ else
+ xfsm_verbose ("No dbus_client_id found.\n");
g_queue_push_tail (manager->running_clients, client);
@@ -1029,7 +1042,8 @@ xfsm_manager_register_client (XfsmManager *manager,
}
}
- if (previous_id != NULL && manager->state == XFSM_MANAGER_STARTUP)
+ if ((previous_id != NULL || manager->failsafe_mode)
+ && manager->state == XFSM_MANAGER_STARTUP)
{
/* Only continue the startup if the previous_id matched one of
* the starting_properties. If there was no match above,
@@ -1037,6 +1051,11 @@ xfsm_manager_register_client (XfsmManager *manager,
* in failsafe mode because in that case the failsafe session is
* started all at once.
*/
+ if (manager->failsafe_mode)
+ {
+ if (--manager->failsafe_clients_pending == 0)
+ g_queue_clear (manager->starting_properties);
+ }
if (g_queue_peek_head (manager->starting_properties) == NULL)
xfsm_startup_session_continue (manager);
}
@@ -1934,8 +1953,6 @@ xfsm_manager_get_queue (XfsmManager *manager,
return manager->restart_properties;
case XFSM_MANAGER_QUEUE_RUNNING_CLIENTS:
return manager->running_clients;
- case XFSM_MANAGER_QUEUE_FAILSAFE_CLIENTS:
- return manager->failsafe_clients;
default:
g_warning ("Requested invalid queue type %d", (gint)q_type);
return NULL;
@@ -1950,6 +1967,13 @@ xfsm_manager_get_use_failsafe_mode (XfsmManager *manager)
}
+void
+xfsm_manager_increase_failsafe_pending_clients (XfsmManager *manager)
+{
+ manager->failsafe_clients_pending++;
+}
+
+
gboolean
xfsm_manager_get_compat_startup (XfsmManager *manager,
XfsmManagerCompatType type)
diff --git a/xfce4-session/xfsm-manager.h b/xfce4-session/xfsm-manager.h
index 0691a0e..bc7e0ed 100644
--- a/xfce4-session/xfsm-manager.h
+++ b/xfce4-session/xfsm-manager.h
@@ -61,7 +61,6 @@ typedef enum
XFSM_MANAGER_QUEUE_STARTING_PROPS,
XFSM_MANAGER_QUEUE_RESTART_PROPS,
XFSM_MANAGER_QUEUE_RUNNING_CLIENTS,
- XFSM_MANAGER_QUEUE_FAILSAFE_CLIENTS,
} XfsmManagerQueueType;
typedef enum
@@ -157,6 +156,8 @@ GQueue *xfsm_manager_get_queue (XfsmManager *manager,
gboolean xfsm_manager_get_use_failsafe_mode (XfsmManager *manager);
+void xfsm_manager_increase_failsafe_pending_clients (XfsmManager *manager);
+
gboolean xfsm_manager_get_compat_startup (XfsmManager *manager,
XfsmManagerCompatType type);
diff --git a/xfce4-session/xfsm-startup.c b/xfce4-session/xfsm-startup.c
index 23084ae..c6855be 100644
--- a/xfce4-session/xfsm-startup.c
+++ b/xfce4-session/xfsm-startup.c
@@ -73,8 +73,6 @@ typedef struct
XfsmProperties *properties;
} XfsmStartupData;
-static void xfsm_startup_failsafe (XfsmManager *manager);
-
static gboolean xfsm_startup_session_next_prio_group (XfsmManager *manager);
static void xfsm_startup_data_free (XfsmStartupData *sdata);
@@ -521,32 +519,9 @@ xfsm_startup_begin (XfsmManager *manager)
xfsm_startup_at (manager);
if (xfsm_manager_get_use_failsafe_mode (manager))
- {
- xfsm_verbose ("Starting the session in failsafe mode.");
- xfsm_startup_failsafe (manager);
- xfsm_startup_autostart (manager);
- xfsm_manager_signal_startup_done (manager);
- }
- else
- {
- xfsm_startup_session_continue (manager);
- }
-}
-
-
-static void
-xfsm_startup_failsafe (XfsmManager *manager)
-{
- GQueue *failsafe_clients = xfsm_manager_get_queue (manager, XFSM_MANAGER_QUEUE_FAILSAFE_CLIENTS);
- FailsafeClient *fclient;
+ xfsm_verbose ("Starting the session in failsafe mode.\n");
- while ((fclient = g_queue_pop_head (failsafe_clients)))
- {
- /* start the application */
- xfsm_start_application (fclient->command, NULL, fclient->screen,
- NULL, NULL, NULL);
- xfsm_failsafe_client_free (fclient);
- }
+ xfsm_startup_session_continue (manager);
}
@@ -596,7 +571,7 @@ xfsm_startup_start_properties (XfsmProperties *properties,
if (xfsm_is_verbose_enabled ())
{
gchar *command = g_strjoinv (" ", argv);
- xfsm_verbose ("Launched command \"%s\" with PID %d\n", command, (gint) pid);
+ xfsm_verbose ("Launching command \"%s\" with PID %d\n", command, (gint) pid);
g_free (command);
}
@@ -669,7 +644,7 @@ xfsm_startup_session_next_prio_group (XfsmManager *manager)
cur_prio_group = xfsm_properties_get_uchar (properties, GsmPriority, 50);
- xfsm_verbose ("Starting apps in prio group %d\n", cur_prio_group);
+ xfsm_verbose ("Starting apps in prio group %d\n (%d)", cur_prio_group, g_queue_get_length (pending_properties));
while ((properties = g_queue_pop_head (pending_properties)))
{
@@ -681,11 +656,15 @@ xfsm_startup_session_next_prio_group (XfsmManager *manager)
break;
}
+ /* as clients cannot be uniquely identified in failsafe mode we at least count
+ how many per priority group have registered */
+ if (xfsm_manager_get_use_failsafe_mode (manager))
+ xfsm_manager_increase_failsafe_pending_clients (manager);
+
if (G_LIKELY (xfsm_startup_start_properties (properties, manager)))
{
g_queue_push_tail (starting_properties, properties);
client_started = TRUE;
- xfsm_verbose ("client id %s started\n", properties->client_id);
}
else
{
diff --git a/xfce4-session/xfsm-startup.h b/xfce4-session/xfsm-startup.h
index 03762e0..73f86b5 100644
--- a/xfce4-session/xfsm-startup.h
+++ b/xfce4-session/xfsm-startup.h
@@ -35,4 +35,3 @@ gboolean xfsm_startup_start_properties (XfsmProperties *properties,
XfsmManager *manager);
#endif /* !__XFSM_STARTUP_H__ */
-
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list