Commit fa358d85 authored by Vincent Untz's avatar Vincent Untz Committed by Vincent Untz

Let all processes cleanly exit on exit.

2009-03-24  Vincent Untz  <vuntz@gnome.org>

	Let all processes cleanly exit on exit.

	* gnome-session/gsm-manager.c: (end_phase): rework with a switch so
	that it's easy to see what's going on for which phases. We also don't
	exit immediately when we reach the exit phase, and instead let
	start_phase() do its work
	(_client_stop): stop a client
	(do_phase_exit): create a 10 second timeout that will force the end of
	the phase, and tells each client to stop via _client_stop() so they can
	have a chance to properly exit before we quit.
	(start_phase): call do_phase_exit() on exit phase

svn path=/trunk/; revision=5346
parent ee0708cb
2009-03-24 Vincent Untz <vuntz@gnome.org>
Let all processes cleanly exit on exit.
* gnome-session/gsm-manager.c: (end_phase): rework with a switch so
that it's easy to see what's going on for which phases. We also don't
exit immediately when we reach the exit phase, and instead let
start_phase() do its work
(_client_stop): stop a client
(do_phase_exit): create a 10 second timeout that will force the end of
the phase, and tells each client to stop via _client_stop() so they can
have a chance to properly exit before we quit.
(start_phase): call do_phase_exit() on exit phase
2009-03-18 Vincent Untz <vuntz@gnome.org>
* configure.in:
......
......@@ -373,12 +373,25 @@ end_phase (GsmManager *manager)
manager->priv->phase_timeout_id = 0;
}
manager->priv->phase++;
if (manager->priv->phase == GSM_MANAGER_PHASE_EXIT) {
gtk_main_quit ();
} else {
switch (manager->priv->phase) {
case GSM_MANAGER_PHASE_STARTUP:
case GSM_MANAGER_PHASE_INITIALIZATION:
case GSM_MANAGER_PHASE_WINDOW_MANAGER:
case GSM_MANAGER_PHASE_PANEL:
case GSM_MANAGER_PHASE_DESKTOP:
case GSM_MANAGER_PHASE_APPLICATION:
case GSM_MANAGER_PHASE_RUNNING:
case GSM_MANAGER_PHASE_QUERY_END_SESSION:
case GSM_MANAGER_PHASE_END_SESSION:
manager->priv->phase++;
start_phase (manager);
break;
case GSM_MANAGER_PHASE_EXIT:
gtk_main_quit ();
break;
default:
g_assert_not_reached ();
break;
}
}
......@@ -567,6 +580,43 @@ do_phase_end_session (GsmManager *manager)
}
}
static gboolean
_client_stop (const char *id,
GsmClient *client,
gpointer user_data)
{
gboolean ret;
GError *error;
error = NULL;
ret = gsm_client_stop (client, &error);
if (! ret) {
g_warning ("Unable to stop client: %s", error->message);
g_error_free (error);
/* FIXME: what should we do if we can't communicate with client? */
} else {
g_debug ("GsmManager: stopped client: %s", gsm_client_peek_id (client));
}
return FALSE;
}
static void
do_phase_exit (GsmManager *manager)
{
if (gsm_store_size (manager->priv->clients) > 0) {
manager->priv->phase_timeout_id = g_timeout_add_seconds (10,
(GSourceFunc)on_phase_timeout,
manager);
gsm_store_foreach (manager->priv->clients,
(GsmStoreFunc)_client_stop,
NULL);
} else {
end_phase (manager);
}
}
static gboolean
_client_query_end_session (const char *id,
GsmClient *client,
......@@ -1043,6 +1093,7 @@ start_phase (GsmManager *manager)
do_phase_end_session (manager);
break;
case GSM_MANAGER_PHASE_EXIT:
do_phase_exit (manager);
break;
default:
g_assert_not_reached ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment