diff options
author | Pauli Nieminen <ext-pauli.nieminen@nokia.com> | 2010-12-30 19:19:43 +0200 |
---|---|---|
committer | Daniel Stone <daniel@fooishbar.org> | 2010-12-31 12:52:51 +0000 |
commit | 2d67ada3c4079a11c52024a9c3d4138becca5171 (patch) | |
tree | 5763fe3654e4165af07ddad710b549aa504c4bd5 /os | |
parent | 617b7d22115ccaaaa7ec69c99885054d33a3bc37 (diff) |
os: always check if client is local when connection is accepted
LocalClient is used for all DRI2 requests that makes it frequently
called function. Querying if connection is local or not takes 10-15us
(on ARM) depending on malloc speed.
Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Diffstat (limited to 'os')
-rw-r--r-- | os/access.c | 18 | ||||
-rw-r--r-- | os/connection.c | 1 | ||||
-rw-r--r-- | os/osdep.h | 4 |
3 files changed, 17 insertions, 6 deletions
diff --git a/os/access.c b/os/access.c index 494986e1e..eb1a21d42 100644 --- a/os/access.c +++ b/os/access.c @@ -1028,20 +1028,19 @@ ResetHosts (char *display) } /* Is client on the local host */ -Bool LocalClient(ClientPtr client) +Bool +ComputeLocalClient(ClientPtr client) { int alen, family, notused; Xtransaddr *from = NULL; pointer addr; register HOST *host; + OsCommPtr oc = (OsCommPtr) client->osPrivate; - if (!client->osPrivate) - return FALSE; - if (!((OsCommPtr)client->osPrivate)->trans_conn) + if (!oc->trans_conn) return FALSE; - if (!_XSERVTransGetPeerAddr (((OsCommPtr)client->osPrivate)->trans_conn, - ¬used, &alen, &from)) + if (!_XSERVTransGetPeerAddr (oc->trans_conn, ¬used, &alen, &from)) { family = ConvertAddr ((struct sockaddr *) from, &alen, (pointer *)&addr); @@ -1067,6 +1066,13 @@ Bool LocalClient(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 * diff --git a/os/connection.c b/os/connection.c index 5452ae112..5580fabf9 100644 --- a/os/connection.c +++ b/os/connection.c @@ -746,6 +746,7 @@ AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time) free(oc); return NullClient; } + oc->local_client = ComputeLocalClient(client); #if !defined(WIN32) ConnectionTranslation[fd] = client->index; #else diff --git a/os/osdep.h b/os/osdep.h index 3c0e78f06..087e36d06 100644 --- a/os/osdep.h +++ b/os/osdep.h @@ -172,6 +172,7 @@ 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( @@ -217,6 +218,9 @@ typedef long int fd_mask; #define ffs mffs extern int mffs(fd_mask); +/* in access.c */ +extern Bool ComputeLocalClient(ClientPtr client); + /* in auth.c */ extern void GenerateRandomData (int len, char *buf); |