aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/os
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/os')
-rw-r--r--xorg-server/os/connection.c4
-rw-r--r--xorg-server/os/io.c27
-rw-r--r--xorg-server/os/osdep.h1
-rw-r--r--xorg-server/os/osinit.c10
-rw-r--r--xorg-server/os/utils.c56
5 files changed, 44 insertions, 54 deletions
diff --git a/xorg-server/os/connection.c b/xorg-server/os/connection.c
index 58bc87bf1..cc3873f9a 100644
--- a/xorg-server/os/connection.c
+++ b/xorg-server/os/connection.c
@@ -153,6 +153,8 @@ Bool NewOutputPending; /* not yet attempted to write some new output */
Bool AnyClientsWriteBlocked; /* true if some client blocked on write */
static Bool RunFromSmartParent; /* send SIGUSR1 to parent process */
+Bool RunFromSigStopParent; /* send SIGSTOP to our own process; Upstart (or
+ equivalent) will send SIGCONT back. */
Bool PartialNetwork; /* continue even if unable to bind all addrs */
static Pid_t ParentProcess;
@@ -381,6 +383,8 @@ NotifyParentProcess(void)
kill (ParentProcess, SIGUSR1);
}
}
+ if (RunFromSigStopParent)
+ raise (SIGSTOP);
#endif
}
diff --git a/xorg-server/os/io.c b/xorg-server/os/io.c
index c9019357b..21d2cf75c 100644
--- a/xorg-server/os/io.c
+++ b/xorg-server/os/io.c
@@ -251,7 +251,14 @@ ReadRequestFromClient(ClientPtr client)
need_header = FALSE;
move_header = FALSE;
gotnow = oci->bufcnt + oci->buffer - oci->bufptr;
- if (gotnow < sizeof(xReq))
+
+ if (oci->ignoreBytes > 0) {
+ if (oci->ignoreBytes > oci->size)
+ needed = oci->size;
+ else
+ needed = oci->ignoreBytes;
+ }
+ else if (gotnow < sizeof(xReq))
{
/* We don't have an entire xReq yet. Can't tell how big
* the request will be until we get the whole xReq.
@@ -294,8 +301,13 @@ ReadRequestFromClient(ClientPtr client)
if (needed > maxBigRequestSize << 2)
{
/* request is too big for us to handle */
- YieldControlDeath();
- return -1;
+ /*
+ * Mark the rest of it as needing to be ignored, and then return
+ * the full size. Dispatch() will turn it into a BadLength error.
+ */
+ oci->ignoreBytes = needed - gotnow;
+ oci->lenLastReq = gotnow;
+ return needed;
}
if ((gotnow == 0) ||
((oci->bufptr - oci->buffer + needed) > oci->size))
@@ -400,6 +412,14 @@ ReadRequestFromClient(ClientPtr client)
}
oci->lenLastReq = needed;
+ /* If there are bytes to ignore, ignore them now. */
+
+ if (oci->ignoreBytes > 0) {
+ assert(needed == oci->ignoreBytes || needed == oci->size);
+ oci->ignoreBytes -= gotnow;
+ needed = gotnow = 0;
+ }
+
/*
* Check to see if client has at least one whole request in the
* buffer beyond the request we're returning to the caller.
@@ -1031,6 +1051,7 @@ AllocateInputBuffer(void)
oci->bufptr = oci->buffer;
oci->bufcnt = 0;
oci->lenLastReq = 0;
+ oci->ignoreBytes = 0;
return oci;
}
diff --git a/xorg-server/os/osdep.h b/xorg-server/os/osdep.h
index 32b4a6763..491a746d4 100644
--- a/xorg-server/os/osdep.h
+++ b/xorg-server/os/osdep.h
@@ -125,6 +125,7 @@ typedef struct _connectionInput {
int bufcnt; /* count of bytes in buffer */
int lenLastReq;
int size;
+ unsigned int ignoreBytes; /* bytes to ignore before the next request */
} ConnectionInput, *ConnectionInputPtr;
typedef struct _connectionOutput {
diff --git a/xorg-server/os/osinit.c b/xorg-server/os/osinit.c
index d04ac6636..6ecf0821c 100644
--- a/xorg-server/os/osinit.c
+++ b/xorg-server/os/osinit.c
@@ -169,15 +169,9 @@ OsInit(void)
struct sigaction act, oact;
int i;
int siglist[] = { SIGSEGV, SIGQUIT, SIGILL, SIGFPE, SIGBUS,
-#ifdef SIGSYS
SIGSYS,
-#endif
-#ifdef SIGXCPU
SIGXCPU,
-#endif
-#ifdef SIGXFSZ
SIGXFSZ,
-#endif
#ifdef SIGEMT
SIGEMT,
#endif
@@ -314,9 +308,7 @@ OsInit(void)
* log file name if logging to a file is desired.
*/
LogInit(NULL, NULL);
- if (!SmartScheduleDisable)
- if (!SmartScheduleInit ())
- SmartScheduleDisable = TRUE;
+ SmartScheduleInit ();
}
void
diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c
index 9919fba83..8858c9f33 100644
--- a/xorg-server/os/utils.c
+++ b/xorg-server/os/utils.c
@@ -540,6 +540,7 @@ void UseMsg(void)
#endif
ErrorF("-dumbSched Disable smart scheduling, enable old behavior\n");
ErrorF("-schedInterval int Set scheduler interval in msec\n");
+ ErrorF("-sigstop Enable SIGSTOP based startup\n");
ErrorF("+extension name Enable extension\n");
ErrorF("-extension name Disable extension\n");
#ifdef XDMCP
@@ -935,6 +936,10 @@ ProcessCommandLine(int argc, char *argv[])
else
UseMsg ();
}
+ else if ( strcmp( argv[i], "-sigstop") == 0)
+ {
+ RunFromSigStopParent = TRUE;
+ }
else if ( strcmp( argv[i], "+extension") == 0)
{
if (++i < argc)
@@ -1129,20 +1134,10 @@ XNFstrdup(const char *s)
return ret;
}
-
-#if defined(SIGVTALRM) && !defined(__CYGWIN__)
-#define SMART_SCHEDULE_POSSIBLE
-#endif
-
-#ifdef SMART_SCHEDULE_POSSIBLE
-#define SMART_SCHEDULE_SIGNAL SIGALRM
-#define SMART_SCHEDULE_TIMER ITIMER_REAL
-#endif
-
void
SmartScheduleStopTimer (void)
{
-#ifdef SMART_SCHEDULE_POSSIBLE
+#ifndef _MSC_VER
struct itimerval timer;
if (SmartScheduleDisable)
@@ -1158,7 +1153,7 @@ SmartScheduleStopTimer (void)
void
SmartScheduleStartTimer (void)
{
-#ifdef SMART_SCHEDULE_POSSIBLE
+#ifndef _MSC_VER
struct itimerval timer;
if (SmartScheduleDisable)
@@ -1171,37 +1166,32 @@ SmartScheduleStartTimer (void)
#endif
}
-#ifdef SMART_SCHEDULE_POSSIBLE
static void
SmartScheduleTimer (int sig)
{
SmartScheduleTime += SmartScheduleInterval;
}
-#endif
-Bool
+void
SmartScheduleInit (void)
{
-#ifdef SMART_SCHEDULE_POSSIBLE
+#ifndef _MSC_VER
struct sigaction act;
if (SmartScheduleDisable)
- return TRUE;
-
+ return;
+
memset((char *) &act, 0, sizeof(struct sigaction));
/* Set up the timer signal function */
act.sa_handler = SmartScheduleTimer;
sigemptyset (&act.sa_mask);
- sigaddset (&act.sa_mask, SMART_SCHEDULE_SIGNAL);
- if (sigaction (SMART_SCHEDULE_SIGNAL, &act, 0) < 0)
+ sigaddset (&act.sa_mask, SIGALRM);
+ if (sigaction (SIGALRM, &act, 0) < 0)
{
perror ("sigaction for smart scheduler");
- return FALSE;
+ SmartScheduleDisable = TRUE;
}
- return TRUE;
-#else
- return FALSE;
#endif
}
@@ -1219,30 +1209,18 @@ OsBlockSignals (void)
sigset_t set;
sigemptyset (&set);
-#ifdef SIGALRM
sigaddset (&set, SIGALRM);
-#endif
-#ifdef SIGVTALRM
sigaddset (&set, SIGVTALRM);
-#endif
#ifdef SIGWINCH
sigaddset (&set, SIGWINCH);
#endif
#ifdef SIGIO
sigaddset (&set, SIGIO);
#endif
-#ifdef SIGTSTP
sigaddset (&set, SIGTSTP);
-#endif
-#ifdef SIGTTIN
sigaddset (&set, SIGTTIN);
-#endif
-#ifdef SIGTTOU
sigaddset (&set, SIGTTOU);
-#endif
-#ifdef SIGCHLD
sigaddset (&set, SIGCHLD);
-#endif
sigprocmask (SIG_BLOCK, &set, &PreviousSignalMask);
}
#endif
@@ -1288,21 +1266,17 @@ int
System(char *command)
{
int pid, p;
-#ifdef SIGCHLD
void (*csig)(int);
-#endif
int status;
if (!command)
return 1;
-#ifdef SIGCHLD
csig = signal(SIGCHLD, SIG_DFL);
if (csig == SIG_ERR) {
perror("signal");
return -1;
}
-#endif
#ifdef DEBUG
ErrorF("System: `%s'\n", command);
@@ -1325,12 +1299,10 @@ System(char *command)
}
-#ifdef SIGCHLD
if (signal(SIGCHLD, csig) == SIG_ERR) {
perror("signal");
return -1;
}
-#endif
return p == -1 ? -1 : status;
}