diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2008-06-15 00:17:34 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2008-06-15 00:17:34 +0000 |
commit | 86fc487fbc0e5e6f7146a43099dc7ce1791c84f0 (patch) | |
tree | 86479ce8d7fc54c515b1aac90f960401587caef0 /xserver/os | |
parent | f629cb662c6469d23587f9dffc2352a8b6505b7b (diff) |
Update to xserver 1.4.2. Tested by landry@, ckuethe@, jsing@ mbalmer@.
Diffstat (limited to 'xserver/os')
-rw-r--r-- | xserver/os/connection.c | 3 | ||||
-rw-r--r-- | xserver/os/io.c | 35 | ||||
-rw-r--r-- | xserver/os/privsep.c | 3 | ||||
-rw-r--r-- | xserver/os/utils.c | 28 |
4 files changed, 49 insertions, 20 deletions
diff --git a/xserver/os/connection.c b/xserver/os/connection.c index d963bb184..ba723d308 100644 --- a/xserver/os/connection.c +++ b/xserver/os/connection.c @@ -353,7 +353,8 @@ InitConnectionLimits(void) #endif #if !defined(WIN32) - ConnectionTranslation = (int *)xnfalloc(sizeof(int)*(lastfdesc + 1)); + if (!ConnectionTranslation) + ConnectionTranslation = (int *)xnfalloc(sizeof(int)*(lastfdesc + 1)); #else InitConnectionTranslation(); #endif diff --git a/xserver/os/io.c b/xserver/os/io.c index f6c666c0f..a8b84fb82 100644 --- a/xserver/os/io.c +++ b/xserver/os/io.c @@ -70,7 +70,7 @@ SOFTWARE. #include <X11/Xtrans/Xtrans.h> #include <X11/Xmd.h> #include <errno.h> -#if !defined(__UNIXOS2__) && !defined(WIN32) +#if !defined(WIN32) #ifndef Lynx #include <sys/uio.h> #else @@ -90,10 +90,14 @@ SOFTWARE. _X_EXPORT CallbackListPtr ReplyCallback; _X_EXPORT CallbackListPtr FlushCallback; +static ConnectionInputPtr AllocateInputBuffer(void); +static ConnectionOutputPtr AllocateOutputBuffer(void); +static xReqPtr PeekNextRequest(xReqPtr req, ClientPtr client, Bool readmore); +static void SkipRequests(xReqPtr req, ClientPtr client, int numskipped); + /* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX * systems are broken and return EWOULDBLOCK when they should return EAGAIN */ -#ifndef __UNIXOS2__ #ifndef WIN32 #if defined(EAGAIN) && defined(EWOULDBLOCK) #define ETEST(err) (err == EAGAIN || err == EWOULDBLOCK) @@ -107,15 +111,12 @@ _X_EXPORT CallbackListPtr FlushCallback; #else /* WIN32 The socket errorcodes differ from the normal errors*/ #define ETEST(err) (err == EAGAIN || err == WSAEWOULDBLOCK) #endif -#else /* __UNIXOS2__ Writing to full pipes may return ENOSPC */ -#define ETEST(err) (err == EAGAIN || err == EWOULDBLOCK || err == ENOSPC) -#endif -Bool CriticalOutputPending; -int timesThisConnection = 0; -ConnectionInputPtr FreeInputs = (ConnectionInputPtr)NULL; -ConnectionOutputPtr FreeOutputs = (ConnectionOutputPtr)NULL; -OsCommPtr AvailableInput = (OsCommPtr)NULL; +static Bool CriticalOutputPending; +static int timesThisConnection = 0; +static ConnectionInputPtr FreeInputs = (ConnectionInputPtr)NULL; +static ConnectionOutputPtr FreeOutputs = (ConnectionOutputPtr)NULL; +static OsCommPtr AvailableInput = (OsCommPtr)NULL; #define get_req_len(req,cli) ((cli)->swapped ? \ lswaps((req)->length) : (req)->length) @@ -303,12 +304,14 @@ ReadRequestFromClient(ClientPtr client) */ oci->lenLastReq = 0; - if (needed > MAXBUFSIZE) +#ifdef BIGREQS + if (needed > maxBigRequestSize << 2) { /* request is too big for us to handle */ YieldControlDeath(); return -1; } +#endif if ((gotnow == 0) || ((oci->bufptr - oci->buffer + needed) > oci->size)) { @@ -635,7 +638,7 @@ ResetCurrentRequest(ClientPtr client) * **********************/ -xReqPtr +static xReqPtr PeekNextRequest( xReqPtr req, /* request we're starting from */ ClientPtr client, /* client whose requests we're skipping */ @@ -697,7 +700,7 @@ PeekNextRequest( _X_EXPORT CallbackListPtr SkippedRequestsCallback = NULL; -void +static void SkipRequests( xReqPtr req, /* last request being skipped */ ClientPtr client, /* client whose requests we're skipping */ @@ -1165,7 +1168,7 @@ FlushClient(ClientPtr who, OsCommPtr oc, char *extraBuf, int extraCount) return extraCount; /* return only the amount explicitly requested */ } -ConnectionInputPtr +static ConnectionInputPtr AllocateInputBuffer(void) { ConnectionInputPtr oci; @@ -1186,7 +1189,7 @@ AllocateInputBuffer(void) return oci; } -ConnectionOutputPtr +static ConnectionOutputPtr AllocateOutputBuffer(void) { ConnectionOutputPtr oco; @@ -1194,7 +1197,7 @@ AllocateOutputBuffer(void) oco = (ConnectionOutputPtr)xalloc(sizeof(ConnectionOutput)); if (!oco) return (ConnectionOutputPtr)NULL; - oco->buf = (unsigned char *) xalloc(BUFSIZE); + oco->buf = (unsigned char *) xcalloc(1, BUFSIZE); if (!oco->buf) { xfree(oco); diff --git a/xserver/os/privsep.c b/xserver/os/privsep.c index 0d018616a..e8f617a2b 100644 --- a/xserver/os/privsep.c +++ b/xserver/os/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.8 2008/06/14 21:37:13 mbalmer Exp $ */ +/* $OpenBSD: privsep.c,v 1.9 2008/06/15 00:17:33 matthieu Exp $ */ /* * Copyright 2001 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -298,6 +298,7 @@ int priv_open_device(const char *path) { priv_cmd_t cmd; + struct okdev *dev; if (priv_fd != -1) { cmd.cmd = PRIV_OPEN_DEVICE; diff --git a/xserver/os/utils.c b/xserver/os/utils.c index d0f6d4f3b..4772be8cf 100644 --- a/xserver/os/utils.c +++ b/xserver/os/utils.c @@ -285,7 +285,8 @@ OsSignal(sig, handler) sigaddset(&act.sa_mask, sig); act.sa_flags = 0; act.sa_handler = handler; - sigaction(sig, &act, &oact); + if (sigaction(sig, &act, &oact)) + perror("sigaction"); return oact.sa_handler; #endif } @@ -1703,6 +1704,10 @@ System(char *command) #ifdef SIGCHLD csig = signal(SIGCHLD, SIG_DFL); + if (csig == SIG_ERR) { + perror("signal"); + return -1; + } #endif #ifdef DEBUG @@ -1727,7 +1732,10 @@ System(char *command) } #ifdef SIGCHLD - signal(SIGCHLD, csig); + if (signal(SIGCHLD, csig) == SIG_ERR) { + perror("signal"); + return -1; + } #endif return p == -1 ? -1 : status; @@ -1739,6 +1747,8 @@ static struct pid { int pid; } *pidlist; +void (*old_alarm)(int) = NULL; /* XXX horrible awful hack */ + pointer Popen(char *command, char *type) { @@ -1760,11 +1770,20 @@ Popen(char *command, char *type) return NULL; } + /* Ignore the smart scheduler while this is going on */ + old_alarm = signal(SIGALRM, SIG_IGN); + if (old_alarm == SIG_ERR) { + perror("signal"); + return NULL; + } + switch (pid = fork()) { case -1: /* error */ close(pdes[0]); close(pdes[1]); xfree(cur); + if (signal(SIGALRM, old_alarm) == SIG_ERR) + perror("signal"); return NULL; case 0: /* child */ if (setgid(getgid()) == -1) @@ -1940,6 +1959,11 @@ Pclose(pointer iop) /* allow EINTR again */ OsReleaseSignals (); + if (old_alarm && signal(SIGALRM, old_alarm) == SIG_ERR) { + perror("signal"); + return -1; + } + return pid == -1 ? -1 : pstat; } |