[PATCH 22/22] os: Cache result from LocalClient query
Pauli
ext-pauli.nieminen at nokia.com
Wed Dec 29 11:27:34 PST 2010
From: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
LocalClient is used for all DRI2 requests that makes it frequently
called function. Querying if connection is local or not takes 10-15us
depending on malloc speed.
Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
---
os/access.c | 15 ++++++++++++++-
os/connection.c | 1 +
os/osdep.h | 5 +++++
3 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/os/access.c b/os/access.c
index 3fc5896..ead8596 100644
--- a/os/access.c
+++ b/os/access.c
@@ -1039,8 +1039,18 @@ Bool LocalClient(ClientPtr client)
if (!client->osPrivate)
return FALSE;
oc = client->osPrivate;
- if (!oc->trans_conn)
+ switch (oc->local_client) {
+ case LOCAL_CLIENT_LOCAL:
+ return TRUE;
+ case LOCAL_CLIENT_REMOTE:
+ return FALSE;
+ case LOCAL_CLIENT_UNKNOWN:
+ break;
+ }
+ if (!oc->trans_conn) {
+ oc->local_client = LOCAL_CLIENT_REMOTE;
return FALSE;
+ }
if (!_XSERVTransGetPeerAddr (oc->trans_conn,
¬used, &alen, &from))
@@ -1049,17 +1059,20 @@ Bool LocalClient(ClientPtr client)
&alen, (pointer *)&addr);
if (family == -1)
{
+ oc->local_client = LOCAL_CLIENT_REMOTE;
free(from);
return FALSE;
}
if (family == FamilyLocal)
{
+ oc->local_client = LOCAL_CLIENT_LOCAL;
free(from);
return TRUE;
}
for (host = selfhosts; host; host = host->next)
{
if (addrEqual (family, addr, alen, host)) {
+ oc->local_client = LOCAL_CLIENT_LOCAL;
free(from);
return TRUE;
}
diff --git a/os/connection.c b/os/connection.c
index 5452ae1..7f9a284 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -741,6 +741,7 @@ AllocNewConnection (XtransConnInfo trans_conn, int fd, CARD32 conn_time)
oc->output = (ConnectionOutputPtr)NULL;
oc->auth_id = None;
oc->conn_time = conn_time;
+ oc->local_client = LOCAL_CLIENT_UNKNOWN;
if (!(client = NextAvailableClient((pointer)oc)))
{
free(oc);
diff --git a/os/osdep.h b/os/osdep.h
index 3c0e78f..675e453 100644
--- a/os/osdep.h
+++ b/os/osdep.h
@@ -172,6 +172,11 @@ typedef struct _osComm {
XID auth_id; /* authorization id */
CARD32 conn_time; /* timestamp if not established, else 0 */
struct _XtransConnInfo *trans_conn; /* transport connection object */
+ enum {
+ LOCAL_CLIENT_UNKNOWN,
+ LOCAL_CLIENT_LOCAL,
+ LOCAL_CLIENT_REMOTE,
+ } local_client;
} OsCommRec, *OsCommPtr;
extern int FlushClient(
--
1.7.0.4
More information about the xorg-devel
mailing list