Author: benny Date: 2006-09-13 15:52:01 +0000 (Wed, 13 Sep 2006) New Revision: 23142
Modified: xfce4-session/trunk/ChangeLog xfce4-session/trunk/configure.in.in xfce4-session/trunk/xfce4-session/xfsm-manager.c xfce4-session/trunk/xfce4-session/xfsm-manager.h xfce4-session/trunk/xfce4-session/xfsm-splash-screen.c xfce4-session/trunk/xfce4-session/xfsm-startup.c Log: 2006-09-13 Benedikt Meurer <[EMAIL PROTECTED]> * xfce4-session/xfsm-splash-screen.c: Drop GLib 2.2 compat code. * configure.in.in, xfce4-session/xfsm-manager.{c,h}, xfce4-session/xfsm-startup.c: Handle failed applications faster on session startup and reduce the overhead caused by handing them over to init. Modified: xfce4-session/trunk/ChangeLog =================================================================== --- xfce4-session/trunk/ChangeLog 2006-09-13 13:58:14 UTC (rev 23141) +++ xfce4-session/trunk/ChangeLog 2006-09-13 15:52:01 UTC (rev 23142) @@ -1,3 +1,11 @@ +2006-09-13 Benedikt Meurer <[EMAIL PROTECTED]> + + * xfce4-session/xfsm-splash-screen.c: Drop GLib 2.2 compat code. + * configure.in.in, xfce4-session/xfsm-manager.{c,h}, + xfce4-session/xfsm-startup.c: Handle failed applications faster on + session startup and reduce the overhead caused by handing them over + to init. + 2006-09-09 Benedikt Meurer <[EMAIL PROTECTED]> * README, configure.in.in, xfce4-session/: Merge the sudo and the HAL Modified: xfce4-session/trunk/configure.in.in =================================================================== --- xfce4-session/trunk/configure.in.in 2006-09-13 13:58:14 UTC (rev 23141) +++ xfce4-session/trunk/configure.in.in 2006-09-13 15:52:01 UTC (rev 23142) @@ -50,7 +50,8 @@ AC_CHECK_HEADERS([errno.h fcntl.h limits.h netdb.h signal.h stdarg.h \ sys/param.h sys/resource.h sys/socket.h sys/time.h sys/wait.h sys/utsname.h \ time.h unistd.h]) -AC_CHECK_FUNCS([getaddrinfo gethostbyname gethostname sigaction strdup sync]) +AC_CHECK_FUNCS([getaddrinfo gethostbyname gethostname sigaction strdup sync \ + vfork]) dnl Check for X11 installed XDT_CHECK_LIBX11_REQUIRE() Modified: xfce4-session/trunk/xfce4-session/xfsm-manager.c =================================================================== --- xfce4-session/trunk/xfce4-session/xfsm-manager.c 2006-09-13 13:58:14 UTC (rev 23141) +++ xfce4-session/trunk/xfce4-session/xfsm-manager.c 2006-09-13 15:52:01 UTC (rev 23142) @@ -70,7 +70,6 @@ */ static gboolean xfsm_manager_startup (void); static void xfsm_manager_handle_failed (void); -static void xfsm_manager_startup_continue (const gchar *previous_id); static gboolean xfsm_manager_startup_timedout (gpointer user_data); static void xfsm_manager_load_settings (XfceRc *rc); static gboolean xfsm_manager_load_session (void); @@ -159,73 +158,7 @@ } -static void -xfsm_manager_startup_continue (const gchar *previous_id) -{ - gboolean startup_done = FALSE; - gchar buffer[1024]; - XfceRc *rc; - - xfsm_verbose ("Manager startup continues [Previous Id = %s]\n\n", - previous_id != NULL ? previous_id : "None"); - - if (startup_timeout_id != 0) - { - g_source_remove (startup_timeout_id); - startup_timeout_id = 0; - - /* work around broken clients */ - if (state != XFSM_MANAGER_STARTUP) - return; - } - - startup_done = xfsm_startup_continue (previous_id); - - if (startup_done) - { - xfsm_verbose ("Manager finished startup, entering IDLE mode now\n\n"); - state = XFSM_MANAGER_IDLE; - - if (!failsafe_mode) - { - /* handle apps that failed to start */ - xfsm_manager_handle_failed (); - - /* restore active workspace, this has to be done after the - * window manager is up, so we do it last. - */ - g_snprintf (buffer, 1024, "Session: %s", session_name); - rc = xfce_rc_simple_open (session_file, TRUE); - xfce_rc_set_group (rc, buffer); - xfsm_manager_restore_active_workspace (rc); - xfce_rc_close (rc); - - /* start legacy applications now */ - xfsm_legacy_startup (); - } - } - else - { - startup_timeout_id = g_timeout_add (STARTUP_TIMEOUT, - xfsm_manager_startup_timedout, - NULL); - } -} - - static gboolean -xfsm_manager_startup_timedout (gpointer user_data) -{ - xfsm_verbose ("Manager startup timed out\n\n"); - - startup_timeout_id = 0; /* will be removed automagically once we return */ - xfsm_manager_startup_continue (NULL); - - return FALSE; -} - - -static gboolean xfsm_manager_choose_session (XfceRc *rc) { XfsmSessionInfo *session; @@ -501,6 +434,72 @@ } +void +xfsm_manager_startup_continue (const gchar *previous_id) +{ + gboolean startup_done = FALSE; + gchar buffer[1024]; + XfceRc *rc; + + xfsm_verbose ("Manager startup continues [Previous Id = %s]\n\n", + previous_id != NULL ? previous_id : "None"); + + if (startup_timeout_id != 0) + { + g_source_remove (startup_timeout_id); + startup_timeout_id = 0; + + /* work around broken clients */ + if (state != XFSM_MANAGER_STARTUP) + return; + } + + startup_done = xfsm_startup_continue (previous_id); + + if (startup_done) + { + xfsm_verbose ("Manager finished startup, entering IDLE mode now\n\n"); + state = XFSM_MANAGER_IDLE; + + if (!failsafe_mode) + { + /* handle apps that failed to start */ + xfsm_manager_handle_failed (); + + /* restore active workspace, this has to be done after the + * window manager is up, so we do it last. + */ + g_snprintf (buffer, 1024, "Session: %s", session_name); + rc = xfce_rc_simple_open (session_file, TRUE); + xfce_rc_set_group (rc, buffer); + xfsm_manager_restore_active_workspace (rc); + xfce_rc_close (rc); + + /* start legacy applications now */ + xfsm_legacy_startup (); + } + } + else + { + startup_timeout_id = g_timeout_add (STARTUP_TIMEOUT, + xfsm_manager_startup_timedout, + NULL); + } +} + + +static gboolean +xfsm_manager_startup_timedout (gpointer user_data) +{ + xfsm_verbose ("Manager startup timed out\n\n"); + + startup_timeout_id = 0; /* will be removed automagically once we return */ + xfsm_manager_startup_continue (NULL); + + return FALSE; +} + + gchar* xfsm_manager_generate_client_id (SmsConn sms_conn) { Modified: xfce4-session/trunk/xfce4-session/xfsm-manager.h =================================================================== --- xfce4-session/trunk/xfce4-session/xfsm-manager.h 2006-09-13 13:58:14 UTC (rev 23141) +++ xfce4-session/trunk/xfce4-session/xfsm-manager.h 2006-09-13 15:52:01 UTC (rev 23142) @@ -1,6 +1,6 @@ /* $Id$ */ /*- - * Copyright (c) 2003-2004 Benedikt Meurer <[EMAIL PROTECTED]> + * Copyright (c) 2003-2006 Benedikt Meurer <[EMAIL PROTECTED]> * All rights reserved. * * This program is free software; you can redistribute it and/or modify @@ -45,6 +45,8 @@ gboolean xfsm_manager_restart (void); +void xfsm_manager_startup_continue (const gchar *previous_id); + gchar* xfsm_manager_generate_client_id (SmsConn sms_conn) G_GNUC_PURE; XfsmClient* xfsm_manager_new_client (SmsConn sms_conn, Modified: xfce4-session/trunk/xfce4-session/xfsm-splash-screen.c =================================================================== --- xfce4-session/trunk/xfce4-session/xfsm-splash-screen.c 2006-09-13 13:58:14 UTC (rev 23141) +++ xfce4-session/trunk/xfce4-session/xfsm-splash-screen.c 2006-09-13 15:52:01 UTC (rev 23142) @@ -1,6 +1,6 @@ /* $Id$ */ /*- - * Copyright (c) 2003-2004 Benedikt Meurer <[EMAIL PROTECTED]> + * Copyright (c) 2003-2006 Benedikt Meurer <[EMAIL PROTECTED]> * All rights reserved. * * This program is free software; you can redistribute it and/or modify @@ -281,11 +281,7 @@ gchar *filename; filename = g_module_build_path (LIBDIR "/xfce4/splash/engines", engine); -#if GLIB_CHECK_VERSION(2,4,0) splash->module = g_module_open (filename, G_MODULE_BIND_LOCAL); -#else - splash->module = g_module_open (filename, 0); -#endif g_free (filename); if (G_LIKELY (splash->module != NULL)) Modified: xfce4-session/trunk/xfce4-session/xfsm-startup.c =================================================================== --- xfce4-session/trunk/xfce4-session/xfsm-startup.c 2006-09-13 13:58:14 UTC (rev 23141) +++ xfce4-session/trunk/xfce4-session/xfsm-startup.c 2006-09-13 15:52:01 UTC (rev 23142) @@ -1,6 +1,6 @@ /* $Id$ */ /*- - * Copyright (c) 2003-2005 Benedikt Meurer <[EMAIL PROTECTED]> + * Copyright (c) 2003-2006 Benedikt Meurer <[EMAIL PROTECTED]> * All rights reserved. * * This program is free software; you can redistribute it and/or modify @@ -45,8 +45,6 @@ #include <glib/gstdio.h> -#include <gtk/gtk.h> - #include <libxfcegui4/libxfcegui4.h> #include <libxfsm/xfsm-util.h> @@ -62,8 +60,12 @@ /* Prototypes */ -static gboolean xfsm_startup_continue_failsafe (void); -static gboolean xfsm_startup_continue_session (const gchar *previous_id); +static gboolean xfsm_startup_continue_failsafe (void); +static gboolean xfsm_startup_continue_session (const gchar *previous_id); +static void xfsm_startup_child_watch (GPid pid, + gint status, + gpointer user_data); +static void xfsm_startup_child_watch_destroy (gpointer user_data); void @@ -480,7 +482,12 @@ xfsm_startup_continue_session (const gchar *previous_id) { XfsmProperties *properties; + gchar **argv; + gint argc; + GPid pid; + gint n; +again: properties = (XfsmProperties *) g_list_nth_data (pending_properties, 0); if (properties != NULL) { @@ -490,12 +497,53 @@ figure_app_name (properties->program)); } - /* restart the application */ - xfsm_start_application (properties->restart_command, NULL, NULL, - NULL, NULL, NULL); + /* drop the properties from the pending list */ pending_properties = g_list_remove (pending_properties, properties); + + /* generate the argument vector for the application (expanding variables) */ + argc = g_strv_length (properties->restart_command); + argv = g_new (gchar *, argc); + for (n = 0; n < argc; ++n) + argv[n] = xfce_expand_variables (properties->restart_command[n], NULL); + argv[n] = NULL; + + /* fork a new process for the application */ +#ifdef HAVE_VFORK + pid = vfork (); +#else + pid = fork (); +#endif + + /* handle the child process */ + if (pid == 0) + { + /* execute the application here */ + execvp (argv[0], argv); + _exit (127); + } + + /* check if we failed to fork */ + if (G_UNLIKELY (pid < 0)) + { + /* tell the user that we failed to fork */ + perror ("Failed to fork new process"); + } + else + { + /* watch the child process */ + g_child_watch_add_full (G_PRIORITY_LOW, pid, xfsm_startup_child_watch, g_strdup (properties->client_id), xfsm_startup_child_watch_destroy); + } + + /* cleanup */ + g_strfreev (argv); + + /* move the properties to the list of starting applications */ starting_properties = g_list_append (starting_properties, properties); + /* try with the next pending if fork() failed */ + if (G_UNLIKELY (pid < 0)) + goto again; + /* more to come... */ return FALSE; } @@ -503,3 +551,38 @@ return TRUE; } + +static void +xfsm_startup_child_watch (GPid pid, + gint status, + gpointer user_data) +{ + XfsmProperties *properties; + const gchar *client_id = user_data; + GList *lp; + + /* check if we have a starting process with the given client_id */ + for (lp = starting_properties; lp != NULL; lp = lp->next) + { + /* check if this properties matches */ + properties = (XfsmProperties *) lp->data; + if (strcmp (properties->client_id, client_id) == 0) + { + /* continue startup, this client failed most probably */ + xfsm_manager_startup_continue (NULL); + break; + } + } +} + + +static void +xfsm_startup_child_watch_destroy (gpointer user_data) +{ + /* release the client_id */ + g_free (user_data); +} + + + + _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits