[PATCH 22/22] os: Cache result from LocalClient query

Alan Coopersmith alan.coopersmith at oracle.com
Wed Dec 29 15:29:50 PST 2010


That seems to leave the the local_client flag set to UNKNOWN instead of
REMOTE for the case that LocalClient doesn't match anything and falls
through to the return FALSE; at the end.

I'd also be tempted to simplify the logic and reduce duplication a bit
while fixing that:

Bool LocalClient(ClientPtr client)
{
    int                 alen, family, notused;
    Xtransaddr          *from = NULL;
    pointer             addr;
    register HOST       *host;

    oc = client->osPrivate;
    if (!oc || !oc->trans_conn)
	return FALSE;

    if (oc->local_client == LOCAL_CLIENT_UNKNOWN)
    {
	oc->local_client = LOCAL_CLIENT_REMOTE;
	if (!_XSERVTransGetPeerAddr (oc->trans_conn, &notused, &alen, &from))
	{
	    family = ConvertAddr ((struct sockaddr *) from,
				  &alen, (pointer *)&addr);
	    if (family == FamilyLocal)
	    {
		oc->local_client = LOCAL_CLIENT_LOCAL;
	    }
	    else if (family != -1)
	    {
		for (host = selfhosts; host; host = host->next)
		{
		    if (addrEqual (family, addr, alen, host))
		    {
			oc->local_client = LOCAL_CLIENT_LOCAL;
			break;
		    }
		}
	    }
	    free(from);
        }
    }
    return (oc->local_client == LOCAL_CLIENT_LOCAL) ? TRUE : FALSE;
}


(Quickly thrown together in e-mail, not even checked to see if it compiles.)

-- 
	-Alan Coopersmith-        alan.coopersmith at oracle.com
	 Oracle Solaris Platform Engineering: X Window System



More information about the xorg-devel mailing list