Commit 3d36e449 authored by Brian Cameron's avatar Brian Cameron Committed by Brian Cameron

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.
parent 11c28082
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.
2005-12-21 Brian Cameron <brian.cameron@sun.com>
Patch by Padraig O'Briain <Padraig.OBriain@sun.com>, modified by myself
......
......@@ -511,6 +511,13 @@ Gestures=false
name=Standard server
command=@X_SERVER@ @X_CONFIG_OPTIONS@ @XEVIE_OPTION@
flexible=true
# Indicates that the X server should be started at a different process
# priority. Values can be any integer value accepted by the setpriority C
# library function (normally between -20 and 20) with 0 being the default. For
# highly interactive applications, -5 yields good responsiveness. The default
# value is 0 and the setpriority function is not called if the value is 0.
#priority=0
# To use this server type you should add -query host or -indirect host to the
# command line.
......
......@@ -11,7 +11,7 @@ AC_PROG_INTLTOOL([0.28])
GNOME_DOC_INIT
GLIB_REQUIRED=2.6.0
GTK_REQUIRED=2.3.0
GTK_REQUIRED=2.6.0
PANGO_REQUIRED=1.3.0
LIBGLADE_REQUIRED=1.99.2
LIBGNOME_REQUIRED=1.96.0
......
......@@ -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
......
......@@ -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>
......
......@@ -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);
}
}
......
......@@ -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;
......
......@@ -3530,6 +3530,22 @@ XKeepsCrashing
</listitem>
</varlistentry>
<varlistentry>
<term>priority</term>
<listitem>
<synopsis>priority=0</synopsis>
<para>
Indicates that the X server should be started at a
different process priority. Values can be any integer
value accepted by the setpriority C library function
(normally between -20 and 20) with 0 being the default.
For highly interactive applications, -5 yields good
responsiveness. The default value is 0 and the
setpriority function is not called if the value is 0.
</para>
</listitem>
</varlistentry>
</variablelist>
</sect3>
......@@ -3971,6 +3987,7 @@ Arguments: &lt;server&gt; &lt;key&gt;
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 &lt;value&gt;
ERROR &lt;err number&gt; &lt;english error description&gt;
......
This diff is collapsed.
......@@ -1719,6 +1719,14 @@ XKeepsCrashing
</listitem>
</varlistentry>
<varlistentry>
<term>priority</term>
<listitem>
<synopsis>priority=-5</synopsis>
<para>Indicates that the X server should be started at a different process priority. This value can be between -20 and 20, with 0 being the default. For highly interactive applications, -5 yields good responsiveness.</para>
</listitem>
</varlistentry>
</variablelist>
</sect3>
......@@ -2053,6 +2061,7 @@ Arguments: &lt;server&gt; &lt;key&gt;
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 &lt;value&gt;
ERROR &lt;err number&gt; &lt;english error description&gt;
......
......@@ -12,6 +12,7 @@ BuildRoot: %{_tmppath}/gdm-%{version}-root
Prereq: /usr/sbin/useradd
Requires: pam >= 0.68
Requires: gnome-libs >= 1.0.17
Requires: gtk2 >= 2.6.0
BuildRequires: usermode, libglade-devel
BuildRequires: gnome-libs-devel >= 1.0.17
BuildRequires: gdk-pixbuf-devel >= 0.7.0
......
......@@ -130,6 +130,7 @@ gdmsetup_LDFLAGS = -export-dynamic
gdmsetup_LDADD = \
libgdmcommon.a \
$(GUI_LIBS) \
$(X_LIBS) \
-lXau \
-lX11 \
$(INTLLIBS) \
......@@ -156,6 +157,7 @@ gdmphotosetup_LDADD = \
gdmXnestchooser_LDADD = \
libgdmcommon.a \
$(GUI_LIBS) \
$(X_LIBS) \
-lXau \
-lX11 \
-lpopt \
......@@ -169,6 +171,7 @@ gdmXnestchooser_LDADD = \
gdmflexiserver_LDADD = \
libgdmcommon.a \
$(GUI_LIBS) \
$(X_LIBS) \
-lXau \
-lpopt \
$(INTLLIBS) \
......@@ -181,6 +184,7 @@ gdmflexiserver_LDADD = \
gdmdynamic_LDADD = \
libgdmcommon.a \
$(GUI_LIBS) \
$(X_LIBS) \
-lXau \
$(INTLLIBS) \
$(GLIB_LIBS) \
......
......@@ -20,6 +20,7 @@
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <string.h>
#include <stdio.h>
#include "misc.h"
#include "gdmconfig.h"
......
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