From: Pauli Nieminen <[email protected]> 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 <[email protected]> Reviewed-by: Daniel Stone <[email protected]> --- include/os.h | 1 + os/access.c | 18 ++++++++++++------ os/connection.c | 1 + os/osdep.h | 1 + 4 files changed, 15 insertions(+), 6 deletions(-) v3: Moved ComputeLocalClient back into access.c so it would actually compile, two typo fixes (ComputerLocalClient and OsCommmPtr), line-wrapping fix, and move os->local_client assignment to after client->osPrivate gets set. -ds diff --git a/include/os.h b/include/os.h index d747040..99a7002 100644 --- a/include/os.h +++ b/include/os.h @@ -353,6 +353,7 @@ typedef struct sockaddr * sockaddrPtr; extern _X_EXPORT int InvalidHost(sockaddrPtr /*saddr*/, int /*len*/, ClientPtr client); +extern Bool ComputeLocalClient(ClientPtr /* client */); extern _X_EXPORT int LocalClient(ClientPtr /* client */); extern _X_EXPORT int LocalClientCred(ClientPtr, int *, int *); diff --git a/os/access.c b/os/access.c index 494986e..eb1a21d 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 5452ae1..5580fab 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 3c0e78f..b47605e 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( -- 1.7.2.3 _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
