summaryrefslogtreecommitdiff
path: root/os
diff options
context:
space:
mode:
authorEamon Walsh <ewalsh@tycho.nsa.gov>2007-11-05 19:08:36 -0500
committerEamon Walsh <ewalsh@moss-charon.epoch.ncsc.mil>2007-11-05 19:08:36 -0500
commita52c9b2a59f27266557ff9d5d2c08492e04135a6 (patch)
tree705f11c54e8a31a07dde9ab6835032e2849e132b /os
parentc7e18beb3c87eb1ada9b21c4ffacd11c1939c087 (diff)
parent58332894c061ae96d6a457f65266660f5f65e88b (diff)
Merge branch 'master' into XACE-SELINUX
Conflicts: dix/dispatch.c dix/property.c hw/xfree86/common/xf86VidMode.c include/xkbsrv.h render/glyph.c xkb/xkbActions.c
Diffstat (limited to 'os')
-rw-r--r--os/WaitFor.c11
-rw-r--r--os/connection.c87
-rw-r--r--os/oscolor.c169
-rw-r--r--os/utils.c36
4 files changed, 66 insertions, 237 deletions
diff --git a/os/WaitFor.c b/os/WaitFor.c
index 1ef79bc34..9281ba8ea 100644
--- a/os/WaitFor.c
+++ b/os/WaitFor.c
@@ -217,7 +217,8 @@ WaitForSomething(int *pClientsReady)
XFD_COPYSET(&AllSockets, &LastSelectMask);
#ifdef SMART_SCHEDULE
}
- SmartScheduleIdle = TRUE;
+ SmartScheduleStopTimer ();
+
#endif
BlockHandler((pointer)&wt, (pointer)&LastSelectMask);
if (NewOutputPending)
@@ -237,13 +238,7 @@ WaitForSomething(int *pClientsReady)
selecterr = GetErrno();
WakeupHandler(i, (pointer)&LastSelectMask);
#ifdef SMART_SCHEDULE
- if (i >= 0)
- {
- SmartScheduleIdle = FALSE;
- SmartScheduleIdleCount = 0;
- if (SmartScheduleTimerStopped)
- (void) SmartScheduleStartTimer ();
- }
+ SmartScheduleStartTimer ();
#endif
if (i <= 0) /* An error or timeout occurred */
{
diff --git a/os/connection.c b/os/connection.c
index 357878100..e0bc18a3c 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -359,6 +359,52 @@ InitConnectionLimits(void)
#endif
}
+/*
+ * If SIGUSR1 was set to SIG_IGN when the server started, assume that either
+ *
+ * a- The parent process is ignoring SIGUSR1
+ *
+ * or
+ *
+ * b- The parent process is expecting a SIGUSR1
+ * when the server is ready to accept connections
+ *
+ * In the first case, the signal will be harmless, in the second case,
+ * the signal will be quite useful.
+ */
+static void
+InitParentProcess(void)
+{
+#if !defined(WIN32)
+ OsSigHandlerPtr handler;
+ handler = OsSignal (SIGUSR1, SIG_IGN);
+ if ( handler == SIG_IGN)
+ RunFromSmartParent = TRUE;
+ OsSignal(SIGUSR1, handler);
+ ParentProcess = getppid ();
+#ifdef __UNIXOS2__
+ /*
+ * fg030505: under OS/2, xinit is not the parent process but
+ * the "grant parent" process of the server because execvpe()
+ * presents us an additional process number;
+ * GetPPID(pid) is part of libemxfix
+ */
+ ParentProcess = GetPPID (ParentProcess);
+#endif /* __UNIXOS2__ */
+#endif
+}
+
+void
+NotifyParentProcess(void)
+{
+#if !defined(WIN32)
+ if (RunFromSmartParent) {
+ if (ParentProcess > 1) {
+ kill (ParentProcess, SIGUSR1);
+ }
+ }
+#endif
+}
/*****************
* CreateWellKnownSockets
@@ -371,7 +417,6 @@ CreateWellKnownSockets(void)
int i;
int partial;
char port[20];
- OsSigHandlerPtr handler;
FD_ZERO(&AllSockets);
FD_ZERO(&AllClients);
@@ -425,33 +470,9 @@ CreateWellKnownSockets(void)
OsSignal (SIGTERM, GiveUp);
XFD_COPYSET (&WellKnownConnections, &AllSockets);
ResetHosts(display);
- /*
- * Magic: If SIGUSR1 was set to SIG_IGN when
- * the server started, assume that either
- *
- * a- The parent process is ignoring SIGUSR1
- *
- * or
- *
- * b- The parent process is expecting a SIGUSR1
- * when the server is ready to accept connections
- *
- * In the first case, the signal will be harmless,
- * in the second case, the signal will be quite
- * useful
- */
-#if !defined(WIN32)
- handler = OsSignal (SIGUSR1, SIG_IGN);
- if ( handler == SIG_IGN)
- RunFromSmartParent = TRUE;
- OsSignal(SIGUSR1, handler);
- ParentProcess = getppid ();
- if (RunFromSmartParent) {
- if (ParentProcess > 1) {
- kill (ParentProcess, SIGUSR1);
- }
- }
-#endif
+
+ InitParentProcess();
+
#ifdef XDMCP
XdmcpInit ();
#endif
@@ -501,16 +522,6 @@ ResetWellKnownSockets (void)
ResetAuthorization ();
ResetHosts(display);
/*
- * See above in CreateWellKnownSockets about SIGUSR1
- */
-#if !defined(WIN32)
- if (RunFromSmartParent) {
- if (ParentProcess > 1) {
- kill (ParentProcess, SIGUSR1);
- }
- }
-#endif
- /*
* restart XDMCP
*/
#ifdef XDMCP
diff --git a/os/oscolor.c b/os/oscolor.c
index e1756926d..f3ff9beac 100644
--- a/os/oscolor.c
+++ b/os/oscolor.c
@@ -49,13 +49,20 @@ SOFTWARE.
#include <dix-config.h>
#endif
-#define USE_RGB_BUILTIN 1
-
-#if USE_RGB_BUILTIN
-
#include <X11/keysym.h>
#include "os.h"
+typedef struct _builtinColor {
+ unsigned char red;
+ unsigned char green;
+ unsigned char blue;
+ unsigned short name;
+} BuiltinColor;
+
+/* These have to come after the struct definition because despair. */
+#include "oscolor.h"
+#define NUM_BUILTIN_COLORS (sizeof (BuiltinColors) / sizeof (BuiltinColors[0]))
+
static unsigned char
OsToLower (unsigned char a)
{
@@ -90,17 +97,6 @@ OsStrCaseCmp (const unsigned char *s1, const unsigned char *s2, int l2)
return c2 - c1;
}
-typedef struct _builtinColor {
- unsigned char red;
- unsigned char green;
- unsigned char blue;
- unsigned short name;
-} BuiltinColor;
-
-#include "oscolor.h"
-
-#define NUM_BUILTIN_COLORS (sizeof (BuiltinColors) / sizeof (BuiltinColors[0]))
-
Bool
OsInitColors(void)
{
@@ -141,146 +137,3 @@ OsLookupColor(int screen,
}
return FALSE;
}
-
-#else
-
-/*
- * This file builds the server's internal database mapping color names to
- * RGB tuples by reading in an rgb.txt file. This is still slightly foolish,
- * rgb.txt hasn't changed in years, we should really include a precompiled
- * version into the server.
- */
-
-#include <stdio.h>
-#include "os.h"
-#include "opaque.h"
-
-#define HASHSIZE 63
-
-typedef struct _dbEntry * dbEntryPtr;
-typedef struct _dbEntry {
- dbEntryPtr link;
- unsigned short red;
- unsigned short green;
- unsigned short blue;
- char name[1]; /* some compilers complain if [0] */
-} dbEntry;
-
-extern void CopyISOLatin1Lowered(
- unsigned char * /*dest*/,
- unsigned char * /*source*/,
- int /*length*/);
-
-static dbEntryPtr hashTab[HASHSIZE];
-
-static dbEntryPtr
-lookup(char *name, int len, Bool create)
-{
- unsigned int h = 0, g;
- dbEntryPtr entry, *prev = NULL;
- char *str = name;
-
- if (!(name = (char*)ALLOCATE_LOCAL(len +1))) return NULL;
- CopyISOLatin1Lowered((unsigned char *)name, (unsigned char *)str, len);
- name[len] = '\0';
-
- for(str = name; *str; str++) {
- h = (h << 4) + *str;
- if ((g = h) & 0xf0000000) h ^= (g >> 24);
- h &= g;
- }
- h %= HASHSIZE;
-
- if ( (entry = hashTab[h]) )
- {
- for( ; entry; prev = (dbEntryPtr*)entry, entry = entry->link )
- if (! strcmp(name, entry->name) ) break;
- }
- else
- prev = &(hashTab[h]);
-
- if (!entry && create && (entry = (dbEntryPtr)xalloc(sizeof(dbEntry) +len)))
- {
- *prev = entry;
- entry->link = NULL;
- strcpy( entry->name, name );
- }
-
- DEALLOCATE_LOCAL(name);
-
- return entry;
-}
-
-Bool
-OsInitColors(void)
-{
- FILE *rgb;
- char *path;
- char line[BUFSIZ];
- char name[BUFSIZ];
- int red, green, blue, lineno = 0;
- dbEntryPtr entry;
-
- static Bool was_here = FALSE;
-
- if (!was_here)
- {
- path = (char*)ALLOCATE_LOCAL(strlen(rgbPath) +5);
- strcpy(path, rgbPath);
- strcat(path, ".txt");
- if (!(rgb = fopen(path, "r")))
- {
- ErrorF( "Couldn't open RGB_DB '%s'\n", rgbPath );
- DEALLOCATE_LOCAL(path);
- return FALSE;
- }
-
- while(fgets(line, sizeof(line), rgb))
- {
- lineno++;
- if (sscanf(line,"%d %d %d %[^\n]\n", &red, &green, &blue, name) == 4)
- {
- if (red >= 0 && red <= 0xff &&
- green >= 0 && green <= 0xff &&
- blue >= 0 && blue <= 0xff)
- {
- if ((entry = lookup(name, strlen(name), TRUE)))
- {
- entry->red = (red * 65535) / 255;
- entry->green = (green * 65535) / 255;
- entry->blue = (blue * 65535) / 255;
- }
- }
- else
- ErrorF("Value out of range: %s:%d\n", path, lineno);
- }
- else if (*line && *line != '#' && *line != '!')
- ErrorF("Syntax Error: %s:%d\n", path, lineno);
- }
-
- fclose(rgb);
- DEALLOCATE_LOCAL(path);
-
- was_here = TRUE;
- }
- return TRUE;
-}
-
-Bool
-OsLookupColor(int screen, char *name, unsigned int len,
- unsigned short *pred, unsigned short *pgreen, unsigned short *pblue)
-{
- dbEntryPtr entry;
-
- if ((entry = lookup(name, len, FALSE)))
- {
- *pred = entry->red;
- *pgreen = entry->green;
- *pblue = entry->blue;
- return TRUE;
- }
-
- return FALSE;
-}
-
-#endif /* USE_RGB_BUILTIN */
diff --git a/os/utils.c b/os/utils.c
index 31cb0af92..322814669 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -577,7 +577,6 @@ void UseMsg(void)
ErrorF("-c turns off key-click\n");
ErrorF("c # key-click volume (0-100)\n");
ErrorF("-cc int default color visual class\n");
- ErrorF("-co file color database file\n");
#ifdef COMMANDLINE_CHALLENGED_OPERATING_SYSTEMS
ErrorF("-config file read options from file\n");
#endif
@@ -783,13 +782,6 @@ ProcessCommandLine(int argc, char *argv[])
else
UseMsg();
}
- else if ( strcmp( argv[i], "-co") == 0)
- {
- if(++i < argc)
- rgbPath = argv[i];
- else
- UseMsg();
- }
else if ( strcmp( argv[i], "-core") == 0)
{
CoreDump = TRUE;
@@ -1513,10 +1505,6 @@ XNFstrdup(const char *s)
#ifdef SMART_SCHEDULE
-unsigned long SmartScheduleIdleCount;
-Bool SmartScheduleIdle;
-Bool SmartScheduleTimerStopped;
-
#ifdef SIGVTALRM
#define SMART_SCHEDULE_POSSIBLE
#endif
@@ -1526,7 +1514,7 @@ Bool SmartScheduleTimerStopped;
#define SMART_SCHEDULE_TIMER ITIMER_REAL
#endif
-static void
+void
SmartScheduleStopTimer (void)
{
#ifdef SMART_SCHEDULE_POSSIBLE
@@ -1537,38 +1525,28 @@ SmartScheduleStopTimer (void)
timer.it_value.tv_sec = 0;
timer.it_value.tv_usec = 0;
(void) setitimer (ITIMER_REAL, &timer, 0);
- SmartScheduleTimerStopped = TRUE;
#endif
}
-Bool
+void
SmartScheduleStartTimer (void)
{
#ifdef SMART_SCHEDULE_POSSIBLE
struct itimerval timer;
- SmartScheduleTimerStopped = FALSE;
timer.it_interval.tv_sec = 0;
timer.it_interval.tv_usec = SmartScheduleInterval * 1000;
timer.it_value.tv_sec = 0;
timer.it_value.tv_usec = SmartScheduleInterval * 1000;
- return setitimer (ITIMER_REAL, &timer, 0) >= 0;
+ setitimer (ITIMER_REAL, &timer, 0);
#endif
- return FALSE;
}
#ifdef SMART_SCHEDULE_POSSIBLE
static void
SmartScheduleTimer (int sig)
{
- int olderrno = errno;
-
SmartScheduleTime += SmartScheduleInterval;
- if (SmartScheduleIdle)
- {
- SmartScheduleStopTimer ();
- }
- errno = olderrno;
}
#endif
@@ -1592,14 +1570,6 @@ SmartScheduleInit (void)
perror ("sigaction for smart scheduler");
return FALSE;
}
- /* Set up the virtual timer */
- if (!SmartScheduleStartTimer ())
- {
- perror ("scheduling timer");
- return FALSE;
- }
- /* stop the timer and wait for WaitForSomething to start it */
- SmartScheduleStopTimer ();
return TRUE;
#else
return FALSE;