summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorBrian Cameron <brian.cameron@sun.com>2005-12-21 02:22:37 +0000
committerBrian Cameron <bcameron@src.gnome.org>2005-12-21 02:22:37 +0000
commit3d36e44966611733172799ebaa8ecb8d021309eb (patch)
tree74e48c84785f75fc678eb33a0dd5081732e4a6b4 /daemon
parent11c28082c288b2a0aad2ef182ee738965b93ed08 (diff)
downloadgdm-3d36e44966611733172799ebaa8ecb8d021309eb.tar.gz
Add new priority configuration option for setting xserver priority.
2005-12-21 Brian Cameron <brian.cameron@sun.com> * daemon/gdm.[ch], daemon/gdmconfig.c, daemon/server.c: Add new priority configuration option for setting xserver priority. * config/gdm.conf.in, docs/C/gdm.xml: Updated docs with information about the new priority [server-foo] configuration option. * configure.ac, gdm.spec.in: Fix gtk dependency so 2.6.0 is listed as the requirement. * gui/Makefile.am: Add X_LIBS when building GUI programs. * gui/misc.c: Add needed stdio.h include.
Diffstat (limited to 'daemon')
-rw-r--r--daemon/gdm.c27
-rw-r--r--daemon/gdm.h5
-rw-r--r--daemon/gdmconfig.c26
-rw-r--r--daemon/server.c11
4 files changed, 58 insertions, 11 deletions
diff --git a/daemon/gdm.c b/daemon/gdm.c
index 80583ba2..49e87eea 100644
--- a/daemon/gdm.c
+++ b/daemon/gdm.c
@@ -3022,34 +3022,39 @@ gdm_handle_user_message (GdmConnection *conn, const char *msg, gpointer data)
GdmXserver *svr = gdm_find_xserver ((char *)splitstr[0]);
if (svr != NULL) {
- if (g_strncasecmp (splitstr[1], "ID", 4) == 0)
+ if (g_strcasecmp (splitstr[1], "ID") == 0)
gdm_connection_printf (conn, "OK %s\n", svr->id);
- else if (g_strncasecmp (splitstr[1], "NAME", 4) == 0)
+ else if (g_strcasecmp (splitstr[1], "NAME") == 0)
gdm_connection_printf (conn, "OK %s\n", svr->name);
- else if (g_strncasecmp (splitstr[1], "COMMAND", 7) == 0)
+ else if (g_strcasecmp (splitstr[1], "COMMAND") == 0)
gdm_connection_printf (conn, "OK %s\n", svr->command);
- else if (g_strncasecmp (splitstr[1], "FLEXIBLE", 8) == 0 &&
+ else if (g_strcasecmp (splitstr[1], "PRIORITY") == 0)
+ gdm_connection_printf (conn, "OK %d\n", svr->priority);
+ else if (g_strcasecmp (splitstr[1], "FLEXIBLE") == 0 &&
svr->flexible)
gdm_connection_printf (conn, "OK true\n");
- else if (g_strncasecmp (splitstr[1], "FLEXIBLE", 8) == 0 &&
+ else if (g_strcasecmp (splitstr[1], "FLEXIBLE") == 0 &&
!svr->flexible)
gdm_connection_printf (conn, "OK false\n");
- else if (g_strncasecmp (splitstr[1], "CHOOSABLE", 9) == 0 &&
+ else if (g_strcasecmp (splitstr[1], "CHOOSABLE") == 0 &&
svr->choosable)
gdm_connection_printf (conn, "OK true\n");
- else if (g_strncasecmp (splitstr[1], "CHOOSABLE", 9) == 0 &&
+ else if (g_strcasecmp (splitstr[1], "CHOOSABLE") == 0 &&
!svr->choosable)
gdm_connection_printf (conn, "OK false\n");
- else if (g_strncasecmp (splitstr[1], "HANDLED", 7) == 0 &&
+ else if (g_strcasecmp (splitstr[1], "HANDLED") == 0 &&
svr->handled)
gdm_connection_printf (conn, "OK true\n");
- else if (g_strncasecmp (splitstr[1], "HANDLED", 7) == 0 &&
+ else if (g_strcasecmp (splitstr[1], "HANDLED") == 0 &&
!svr->handled)
gdm_connection_printf (conn, "OK false\n");
- else if (g_strncasecmp (splitstr[1], "CHOOSER", 7) == 0 &&
+ else if (g_strcasecmp (splitstr[1], "CHOOSER") == 0 &&
svr->chooser)
gdm_connection_printf (conn, "OK true\n");
- else if (g_strncasecmp (splitstr[1], "CHOOSER", 7) == 0 &&
+ else if (g_strcasecmp (splitstr[1], "CHOOSER") == 0 &&
+ !svr->chooser)
+ gdm_connection_printf (conn, "OK false\n");
+ else if (g_strcasecmp (splitstr[1], "PRIORITY") == 0 &&
!svr->chooser)
gdm_connection_printf (conn, "OK false\n");
else
diff --git a/daemon/gdm.h b/daemon/gdm.h
index e28f84ae..21efeb36 100644
--- a/daemon/gdm.h
+++ b/daemon/gdm.h
@@ -260,6 +260,8 @@ enum {
#define GDM_KEY_SERVER_HANDLED "handled=true"
/* Instead of the greeter run the chooser */
#define GDM_KEY_SERVER_CHOOSER "chooser=false"
+/* select a nice level to run the X server at */
+#define GDM_KEY_SERVER_PRIORITY "priority=0"
#define GDM_KEY_ALLOW_ROOT "security/AllowRoot=true"
#define GDM_KEY_ALLOW_REMOTE_ROOT "security/AllowRemoteRoot=true"
@@ -479,6 +481,7 @@ struct _GdmDisplay {
gboolean handled;
gboolean tcp_disallowed;
+ int priority;
int vt;
gboolean busy_display;
@@ -553,6 +556,7 @@ struct _GdmXserver {
gboolean choosable; /* not implemented yet */
gboolean chooser; /* instead of greeter, run chooser */
gboolean handled;
+ int priority;
};
typedef struct _GdmIndirectDisplay GdmIndirectDisplay;
@@ -948,6 +952,7 @@ void gdm_final_cleanup (void);
* CHOOSABLE - Returns "true" if choosable, "false" otherwise
* HANDLED - Returns "true" if handled, "false" otherwise
* CHOOSER - Returns "true" if chooser, "false" otherwise
+ * PRIORITY - Returns process priority
* Answers:
* OK <value>
* ERROR <err number> <english error description>
diff --git a/daemon/gdmconfig.c b/daemon/gdmconfig.c
index 6501bb4a..e9139462 100644
--- a/daemon/gdmconfig.c
+++ b/daemon/gdmconfig.c
@@ -1251,6 +1251,16 @@ gdm_get_xservers (void)
return retval;
}
+/* PRIO_MIN and PRIO_MAX are not defined on Solaris, but are -20 and 20 */
+#if sun
+#ifndef PRIO_MIN
+#define PRIO_MIN -20
+#endif
+#ifndef PRIO_MAX
+#define PRIO_MAX 20
+#endif
+#endif
+
/**
* gdm_load_xservers
*
@@ -1281,6 +1291,7 @@ gdm_load_xservers (VeConfig *cfg)
} else {
GdmXserver *svr = g_new0 (GdmXserver, 1);
gchar buf[256];
+ int n;
svr->id = id;
@@ -1296,6 +1307,20 @@ gdm_load_xservers (VeConfig *cfg)
svr->handled = ve_config_get_bool (cfg, buf);
g_snprintf (buf, sizeof (buf), "%s/" GDM_KEY_SERVER_CHOOSER, sec);
svr->chooser = ve_config_get_bool (cfg, buf);
+ g_snprintf (buf, sizeof (buf), "%s/" GDM_KEY_SERVER_PRIORITY, sec);
+ svr->priority = ve_config_get_int (cfg, buf);
+
+ /* do some bounds checking */
+ n = svr->priority;
+ if (n < PRIO_MIN)
+ n = PRIO_MIN;
+ else if (n > PRIO_MAX)
+ n = PRIO_MAX;
+ if (n != svr->priority) {
+ gdm_error (_("%s: Priority out of bounds; changed to %d"),
+ "gdm_config_parse", n);
+ svr->priority = n;
+ }
if (ve_string_empty (svr->command)) {
gdm_error (_("%s: Empty server command; "
@@ -1351,6 +1376,7 @@ gdm_update_xservers (VeConfig *cfg, VeConfig *custom_cfg)
svr->flexible = TRUE;
svr->choosable = TRUE;
svr->handled = TRUE;
+ svr->priority = 0;
xservers = g_slist_append (xservers, svr);
}
}
diff --git a/daemon/server.c b/daemon/server.c
index c66dc18a..7c4a4eb9 100644
--- a/daemon/server.c
+++ b/daemon/server.c
@@ -1003,6 +1003,7 @@ gdm_server_resolve_command_line (GdmDisplay *disp,
us by the master */
if (svr->chooser)
disp->use_chooser = TRUE;
+ disp->priority = svr->priority;
}
}
} else {
@@ -1041,6 +1042,7 @@ gdm_server_resolve_command_line (GdmDisplay *disp,
disp->handled = FALSE;
/* never ever ever use chooser here */
disp->use_chooser = FALSE;
+ disp->priority = 0;
/* run just one session */
argv[len++] = g_strdup ("-terminate");
argv[len++] = g_strdup ("-query");
@@ -1231,6 +1233,14 @@ gdm_server_spawn (GdmDisplay *d, const char *vtarg)
gdm_debug ("gdm_server_spawn: '%s'", command);
+ if (d->priority != 0) {
+ if (setpriority (PRIO_PROCESS, 0, d->priority)) {
+ gdm_error (_("%s: Server priority couldn't be set to %d: %s"),
+ "gdm_server_spawn", d->priority,
+ strerror (errno));
+ }
+ }
+
setpgid (0, 0);
if (d->server_uid != 0) {
@@ -1417,6 +1427,7 @@ gdm_server_alloc (gint id, const gchar *command)
d->handled = TRUE;
d->tcp_disallowed = FALSE;
+ d->priority = 0;
d->vt = -1;
d->x_servers_order = -1;