This commit is contained in:
Keith Packard 2012-01-09 13:07:25 -08:00
commit 0b113f7cdf
20 changed files with 95 additions and 128 deletions

View file

@ -1045,13 +1045,6 @@ ComputeLocalClient(ClientPtr client)
return FALSE;
}
Bool LocalClient(ClientPtr client)
{
if (!client->osPrivate)
return FALSE;
return ((OsCommPtr)client->osPrivate)->local_client;
}
/*
* Return the uid and gid of a connected local client
*
@ -1209,7 +1202,7 @@ AuthorizedClient(ClientPtr client)
if (rc != Success)
return rc;
return LocalClient(client) ? Success : BadAccess;
return client->local ? Success : BadAccess;
}
/* Add a host to the access control list. This is the external interface

View file

@ -745,7 +745,7 @@ AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time)
free(oc);
return NullClient;
}
oc->local_client = ComputeLocalClient(client);
client->local = ComputeLocalClient(client);
#if !defined(WIN32)
ConnectionTranslation[fd] = client->index;
#else
@ -873,6 +873,8 @@ EstablishNewConnections(ClientPtr clientUnused, pointer closure)
* Fail a connection due to lack of client or file descriptor space
************/
#define BOTIMEOUT 200 /* in milliseconds */
static void
ErrorConnMax(XtransConnInfo trans_conn)
{
@ -880,7 +882,7 @@ ErrorConnMax(XtransConnInfo trans_conn)
xConnSetupPrefix csp;
char pad[3];
struct iovec iov[3];
char byteOrder = 0;
char order = 0;
int whichbyte = 1;
struct timeval waittime;
fd_set mask;
@ -893,16 +895,16 @@ ErrorConnMax(XtransConnInfo trans_conn)
FD_SET(fd, &mask);
(void)Select(fd + 1, &mask, NULL, NULL, &waittime);
/* try to read the byte-order of the connection */
(void)_XSERVTransRead(trans_conn, &byteOrder, 1);
if ((byteOrder == 'l') || (byteOrder == 'B'))
(void)_XSERVTransRead(trans_conn, &order, 1);
if (order == 'l' || order == 'B' || order == 'r' || order == 'R')
{
csp.success = xFalse;
csp.lengthReason = sizeof(NOROOM) - 1;
csp.length = (sizeof(NOROOM) + 2) >> 2;
csp.majorVersion = X_PROTOCOL;
csp.minorVersion = X_PROTOCOL_REVISION;
if (((*(char *) &whichbyte) && (byteOrder == 'B')) ||
(!(*(char *) &whichbyte) && (byteOrder == 'l')))
if (((*(char *) &whichbyte) && (order == 'B' || order == 'R')) ||
(!(*(char *) &whichbyte) && (order == 'l' || order == 'r')))
{
swaps(&csp.majorVersion);
swaps(&csp.minorVersion);
@ -1030,7 +1032,7 @@ CloseDownConnection(ClientPtr client)
if (FlushCallback)
CallCallbacks(&FlushCallback, NULL);
if (oc->output && oc->output->count)
if (oc->output)
FlushClient(client, oc, (char *)NULL, 0);
#ifdef XDMCP
XdmcpCloseDisplay(oc->fd);

21
os/io.c
View file

@ -84,6 +84,23 @@ SOFTWARE.
CallbackListPtr ReplyCallback;
CallbackListPtr FlushCallback;
typedef struct _connectionInput {
struct _connectionInput *next;
char *buffer; /* contains current client input */
char *bufptr; /* pointer to current start of data */
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 {
struct _connectionOutput *next;
unsigned char *buf;
int size;
int count;
} ConnectionOutput, *ConnectionOutputPtr;
static ConnectionInputPtr AllocateInputBuffer(void);
static ConnectionOutputPtr AllocateOutputBuffer(void);
@ -112,6 +129,8 @@ static OsCommPtr AvailableInput = (OsCommPtr)NULL;
((xBigReq *)(req))->length)
#define MAX_TIMES_PER 10
#define BUFSIZE 4096
#define BUFWATERMARK 8192
/*
* A lot of the code in this file manipulates a ConnectionInputPtr:
@ -889,7 +908,7 @@ FlushClient(ClientPtr who, OsCommPtr oc, const void *__extraBuf, int extraCount)
long notWritten;
long todo;
if (!oco)
if (!oco || !oco->count)
return 0;
written = 0;
padsize = padlength[extraCount & 3];

View file

@ -52,10 +52,6 @@ SOFTWARE.
#ifndef _OSDEP_H_
#define _OSDEP_H_ 1
#define BOTIMEOUT 200 /* in milliseconds */
#define BUFSIZE 4096
#define BUFWATERMARK 8192
#if defined(XDMCP) || defined(HASXDMAUTH)
#include <X11/Xdmcp.h>
#endif
@ -112,22 +108,8 @@ typedef Bool (*AddAuthorFunc)(unsigned name_length, const char *name,
unsigned data_length, char *data);
#endif
typedef struct _connectionInput {
struct _connectionInput *next;
char *buffer; /* contains current client input */
char *bufptr; /* pointer to current start of data */
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 {
struct _connectionOutput *next;
int size;
unsigned char *buf;
int count;
} ConnectionOutput, *ConnectionOutputPtr;
typedef struct _connectionInput *ConnectionInputPtr;
typedef struct _connectionOutput *ConnectionOutputPtr;
struct _osComm;
@ -166,7 +148,6 @@ typedef struct _osComm {
XID auth_id; /* authorization id */
CARD32 conn_time; /* timestamp if not established, else 0 */
struct _XtransConnInfo *trans_conn; /* transport connection object */
Bool local_client;
} OsCommRec, *OsCommPtr;
extern int FlushClient(