[gdm/multi-stack: 2/46] Rename session worker to the service it's managing
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm/multi-stack: 2/46] Rename session worker to the service it's managing
- Date: Fri, 26 Mar 2010 13:33:47 +0000 (UTC)
commit f7575f20a831dc9b195abddf78404477225cb299
Author: Ray Strode <rstrode redhat com>
Date: Wed Feb 4 10:55:03 2009 -0500
Rename session worker to the service it's managing
This way when we're running multiple PAM conversations at once
it will be obvious which worker is managing which conversation.
daemon/gdm-session-direct.c | 7 ++++-
daemon/gdm-session-worker-job.c | 63 ++++++++++++++++++++++++++++++--------
daemon/gdm-session-worker-job.h | 3 +-
3 files changed, 57 insertions(+), 16 deletions(-)
---
diff --git a/daemon/gdm-session-direct.c b/daemon/gdm-session-direct.c
index dff3e68..abc3c9d 100644
--- a/daemon/gdm-session-direct.c
+++ b/daemon/gdm-session-direct.c
@@ -1700,6 +1700,7 @@ start_conversation (GdmSessionDirect *session,
const char *service_name)
{
GdmSessionConversation *conversation;
+ char *job_name;
conversation = g_new0 (GdmSessionConversation, 1);
conversation->session = session;
@@ -1720,12 +1721,16 @@ start_conversation (GdmSessionDirect *session,
G_CALLBACK (worker_died),
conversation);
- if (!gdm_session_worker_job_start (conversation->job)) {
+ job_name = g_strdup_printf ("pam: %s", service_name);
+ if (!gdm_session_worker_job_start (conversation->job,
+ job_name)) {
g_object_unref (conversation->job);
g_free (conversation->service_name);
g_free (conversation);
+ g_free (job_name);
return NULL;
}
+ g_free (job_name);
conversation->worker_pid = gdm_session_worker_job_get_pid (conversation->job);
diff --git a/daemon/gdm-session-worker-job.c b/daemon/gdm-session-worker-job.c
index 9c020fa..0327d77 100644
--- a/daemon/gdm-session-worker-job.c
+++ b/daemon/gdm-session-worker-job.c
@@ -149,6 +149,37 @@ copy_environment_to_hash (GHashTable *hash)
}
static GPtrArray *
+get_job_arguments (GdmSessionWorkerJob *job,
+ const char *name)
+{
+ GPtrArray *args;
+ GError *error;
+ char **argv;
+ int i;
+
+ args = NULL;
+ argv = NULL;
+ error = NULL;
+ if (! g_shell_parse_argv (job->priv->command, NULL, &argv, &error)) {
+ g_warning ("Could not parse command: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ args = g_ptr_array_new ();
+ g_ptr_array_add (args, g_strdup (argv[0]));
+ g_ptr_array_add (args, g_strdup (name));
+ for (i = 1; argv[i] != NULL; i++) {
+ g_ptr_array_add (args, g_strdup (argv[i]));
+ }
+ g_strfreev (argv);
+
+ g_ptr_array_add (args, NULL);
+out:
+ return args;
+}
+
+static GPtrArray *
get_job_environment (GdmSessionWorkerJob *job)
{
GPtrArray *env;
@@ -171,31 +202,31 @@ get_job_environment (GdmSessionWorkerJob *job)
}
static gboolean
-gdm_session_worker_job_spawn (GdmSessionWorkerJob *session_worker_job)
+gdm_session_worker_job_spawn (GdmSessionWorkerJob *session_worker_job,
+ const char *name)
{
- gchar **argv;
GError *error;
gboolean ret;
+ GPtrArray *args;
GPtrArray *env;
ret = FALSE;
- g_debug ("GdmSessionWorkerJob: Running session_worker_job process: %s", session_worker_job->priv->command);
+ g_debug ("GdmSessionWorkerJob: Running session_worker_job process: %s %s",
+ name != NULL? name : "", session_worker_job->priv->command);
- argv = NULL;
- if (! g_shell_parse_argv (session_worker_job->priv->command, NULL, &argv, &error)) {
- g_warning ("Could not parse command: %s", error->message);
- g_error_free (error);
- goto out;
- }
+ args = get_job_arguments (session_worker_job, name);
+ if (args == NULL) {
+ return FALSE;
+ }
env = get_job_environment (session_worker_job);
error = NULL;
ret = g_spawn_async_with_pipes (NULL,
- argv,
+ (char **) args->pdata,
(char **)env->pdata,
- G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
+ G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_FILE_AND_ARGV_ZERO,
(GSpawnChildSetupFunc)session_worker_job_child_setup,
session_worker_job,
&session_worker_job->priv->pid,
@@ -204,6 +235,9 @@ gdm_session_worker_job_spawn (GdmSessionWorkerJob *session_worker_job)
NULL,
&error);
+ g_ptr_array_foreach (args, (GFunc)g_free, NULL);
+ g_ptr_array_free (args, TRUE);
+
g_ptr_array_foreach (env, (GFunc)g_free, NULL);
g_ptr_array_free (env, TRUE);
@@ -220,7 +254,6 @@ gdm_session_worker_job_spawn (GdmSessionWorkerJob *session_worker_job)
(GChildWatchFunc)session_worker_job_child_watch,
session_worker_job);
- g_strfreev (argv);
out:
return ret;
@@ -233,13 +266,14 @@ gdm_session_worker_job_spawn (GdmSessionWorkerJob *session_worker_job)
* Starts a local X session_worker_job. Handles retries and fatal errors properly.
*/
gboolean
-gdm_session_worker_job_start (GdmSessionWorkerJob *session_worker_job)
+gdm_session_worker_job_start (GdmSessionWorkerJob *session_worker_job,
+ const char *name)
{
gboolean res;
g_debug ("GdmSessionWorkerJob: Starting worker...");
- res = gdm_session_worker_job_spawn (session_worker_job);
+ res = gdm_session_worker_job_spawn (session_worker_job, name);
if (res) {
@@ -287,6 +321,7 @@ gdm_session_worker_job_stop (GdmSessionWorkerJob *session_worker_job)
g_debug ("GdmSessionWorkerJob: Stopping job pid:%d", session_worker_job->priv->pid);
res = gdm_signal_pid (session_worker_job->priv->pid, SIGTERM);
+
if (res < 0) {
g_warning ("Unable to kill session worker process");
} else {
diff --git a/daemon/gdm-session-worker-job.h b/daemon/gdm-session-worker-job.h
index d24f025..4833f23 100644
--- a/daemon/gdm-session-worker-job.h
+++ b/daemon/gdm-session-worker-job.h
@@ -57,7 +57,8 @@ GType gdm_session_worker_job_get_type (void);
GdmSessionWorkerJob * gdm_session_worker_job_new (void);
void gdm_session_worker_job_set_server_address (GdmSessionWorkerJob *session_worker_job,
const char *server_address);
-gboolean gdm_session_worker_job_start (GdmSessionWorkerJob *session_worker_job);
+gboolean gdm_session_worker_job_start (GdmSessionWorkerJob *session_worker_job,
+ const char *name);
gboolean gdm_session_worker_job_stop (GdmSessionWorkerJob *session_worker_job);
GPid gdm_session_worker_job_get_pid (GdmSessionWorkerJob *session_worker_job);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]