dix: remove caching of drawables and graphics contexts. The security checks

simply bypass the cached values so they are unused.
This commit is contained in:
Eamon Walsh 2007-08-14 11:39:26 -04:00 committed by Eamon Walsh
parent 2763056ab5
commit 9a183d7ba5
9 changed files with 10 additions and 103 deletions

View File

@ -235,7 +235,7 @@ MultibufferExtensionInit()
* create the resource types
*/
MultibufferDrawableResType =
CreateNewResourceType(MultibufferDrawableDelete)|RC_CACHED|RC_DRAWABLE;
CreateNewResourceType(MultibufferDrawableDelete)|RC_DRAWABLE;
MultibufferResType = CreateNewResourceType(MultibufferDelete);
MultibuffersResType = CreateNewResourceType(MultibuffersDelete);
OtherClientResType = CreateNewResourceType(OtherClientDelete);

View File

@ -1783,7 +1783,7 @@ DbeExtensionInit(void)
/* Create the resource types. */
dbeDrawableResType =
CreateNewResourceType(DbeDrawableDelete) | RC_CACHED | RC_DRAWABLE;
CreateNewResourceType(DbeDrawableDelete) | RC_DRAWABLE;
dbeWindowPrivResType =
CreateNewResourceType(DbeWindowPrivDelete);

View File

@ -258,34 +258,6 @@ InitSelections(void)
CurrentSelections = (Selection *)NULL;
NumCurrentSelections = 0;
}
void
FlushClientCaches(XID id)
{
int i;
ClientPtr client;
client = clients[CLIENT_ID(id)];
if (client == NullClient)
return ;
for (i=0; i<currentMaxClients; i++)
{
client = clients[i];
if (client != NullClient)
{
if (client->lastDrawableID == id)
{
client->lastDrawableID = WindowTable[0]->drawable.id;
client->lastDrawable = (DrawablePtr)WindowTable[0];
}
else if (client->lastGCID == id)
{
client->lastGCID = INVALID;
client->lastGC = (GCPtr)NULL;
}
}
}
}
#ifdef SMART_SCHEDULE
#undef SMART_DEBUG
@ -3702,20 +3674,7 @@ void InitClient(ClientPtr client, int i, pointer ospriv)
client->sequence = 0;
client->clientAsMask = ((Mask)i) << CLIENTOFFSET;
client->clientGone = FALSE;
if (i)
{
client->closeDownMode = DestroyAll;
client->lastDrawable = (DrawablePtr)WindowTable[0];
client->lastDrawableID = WindowTable[0]->drawable.id;
}
else
{
client->closeDownMode = RetainPermanent;
client->lastDrawable = (DrawablePtr)NULL;
client->lastDrawableID = INVALID;
}
client->lastGC = (GCPtr) NULL;
client->lastGCID = INVALID;
client->closeDownMode = i ? DestroyAll : RetainPermanent;
client->numSaved = 0;
client->saveSet = (SaveSetElt *)NULL;
client->noClientException = Success;

View File

@ -208,7 +208,6 @@ dixLookupDrawable(DrawablePtr *pDraw, XID id, ClientPtr client,
Mask type, Mask access)
{
DrawablePtr pTmp;
RESTYPE rtype;
int rc;
*pDraw = NULL;
@ -217,28 +216,15 @@ dixLookupDrawable(DrawablePtr *pDraw, XID id, ClientPtr client,
if (id == INVALID)
return BadDrawable;
if (id == client->lastDrawableID) {
pTmp = client->lastDrawable;
rc = dixLookupResource((pointer *)&pTmp, id, RC_DRAWABLE, client, access);
/* an access check is required for cached drawables */
rtype = (type & M_WINDOW) ? RT_WINDOW : RT_PIXMAP;
rc = XaceHook(XACE_RESOURCE_ACCESS, client, id, rtype, access, pTmp);
if (rc != Success)
return rc;
} else
dixLookupResource((void **)&pTmp, id, RC_DRAWABLE, client, access);
if (!pTmp)
if (rc == BadValue)
return BadDrawable;
if (rc != Success)
return rc;
if (!((1 << pTmp->type) & (type ? type : M_DRAWABLE)))
return BadMatch;
if (type & M_DRAWABLE) {
client->lastDrawable = pTmp;
client->lastDrawableID = id;
client->lastGCID = INVALID;
client->lastGC = (GCPtr)NULL;
}
*pDraw = pTmp;
return Success;
}

View File

@ -585,8 +585,6 @@ FreeResource(XID id, RESTYPE skipDeleteFuncType)
CallResourceStateCallback(ResourceStateFreeing, res);
if (rtype & RC_CACHED)
FlushClientCaches(res->id);
if (rtype != skipDeleteFuncType)
(*DeleteFuncs[rtype & TypeMask])(res->value, res->id);
xfree(res);
@ -597,11 +595,6 @@ FreeResource(XID id, RESTYPE skipDeleteFuncType)
else
prev = &res->next;
}
if(clients[cid] && (id == clients[cid]->lastDrawableID))
{
clients[cid]->lastDrawable = (DrawablePtr)WindowTable[0];
clients[cid]->lastDrawableID = WindowTable[0]->drawable.id;
}
}
if (!gotOne)
ErrorF("Freeing resource id=%lX which isn't there.\n",
@ -632,8 +625,6 @@ FreeResourceByType(XID id, RESTYPE type, Bool skipFree)
CallResourceStateCallback(ResourceStateFreeing, res);
if (type & RC_CACHED)
FlushClientCaches(res->id);
if (!skipFree)
(*DeleteFuncs[type & TypeMask])(res->value, res->id);
xfree(res);
@ -642,11 +633,6 @@ FreeResourceByType(XID id, RESTYPE type, Bool skipFree)
else
prev = &res->next;
}
if(clients[cid] && (id == clients[cid]->lastDrawableID))
{
clients[cid]->lastDrawable = (DrawablePtr)WindowTable[0];
clients[cid]->lastDrawableID = WindowTable[0]->drawable.id;
}
}
}
@ -669,8 +655,6 @@ ChangeResourceValue (XID id, RESTYPE rtype, pointer value)
for (; res; res = res->next)
if ((res->id == id) && (res->type == rtype))
{
if (rtype & RC_CACHED)
FlushClientCaches(res->id);
res->value = value;
return TRUE;
}
@ -801,8 +785,6 @@ FreeClientNeverRetainResources(ClientPtr client)
CallResourceStateCallback(ResourceStateFreeing, this);
if (rtype & RC_CACHED)
FlushClientCaches(this->id);
(*DeleteFuncs[rtype & TypeMask])(this->value, this->id);
xfree(this);
}
@ -854,8 +836,6 @@ FreeClientResources(ClientPtr client)
CallResourceStateCallback(ResourceStateFreeing, this);
if (rtype & RC_CACHED)
FlushClientCaches(this->id);
(*DeleteFuncs[rtype & TypeMask])(this->value, this->id);
xfree(this);
}

View File

@ -431,7 +431,6 @@ winProcSetSelectionOwner (ClientPtr client)
* and we currently own the Win32 clipboard.
*/
if (None == stuff->window
&& g_iClipboardWindow != client->lastDrawableID
&& (None == s_iOwners[CLIP_OWN_PRIMARY]
|| g_iClipboardWindow == s_iOwners[CLIP_OWN_PRIMARY])
&& (None == s_iOwners[CLIP_OWN_CLIPBOARD]

View File

@ -82,8 +82,6 @@ SOFTWARE.
}
#define VALIDATE_DRAWABLE_AND_GC(drawID, pDraw, pGC, client)\
if ((stuff->gc == INVALID) || (client->lastGCID != stuff->gc) ||\
(client->lastDrawableID != drawID))\
{\
int rc;\
rc = dixLookupDrawable(&(pDraw), drawID, client, M_ANY,\
@ -95,15 +93,6 @@ SOFTWARE.
return rc;\
if ((pGC->depth != pDraw->depth) || (pGC->pScreen != pDraw->pScreen))\
return (BadMatch);\
client->lastDrawable = pDraw;\
client->lastDrawableID = drawID;\
client->lastGC = pGC;\
client->lastGCID = stuff->gc;\
}\
else\
{\
pGC = client->lastGC;\
pDraw = client->lastDrawable;\
}\
if (pGC->serialNumber != pDraw->serialNumber)\
ValidateGC(pDraw, pGC);
@ -160,8 +149,6 @@ extern void UpdateCurrentTimeIf(void);
extern void InitSelections(void);
extern void FlushClientCaches(XID /*id*/);
extern int dixDestroyPixmap(
pointer /*value*/,
XID /*pid*/);

View File

@ -101,10 +101,6 @@ typedef struct _Client {
int clientGone;
int noClientException; /* this client died or needs to be
* killed */
DrawablePtr lastDrawable;
Drawable lastDrawableID;
GCPtr lastGC;
GContext lastGCID;
SaveSetElt *saveSet;
int numSaved;
pointer screenPrivate[MAXSCREENS];

View File

@ -72,9 +72,9 @@ typedef unsigned long RESTYPE;
/* types for Resource routines */
#define RT_WINDOW ((RESTYPE)1|RC_CACHED|RC_DRAWABLE)
#define RT_PIXMAP ((RESTYPE)2|RC_CACHED|RC_DRAWABLE)
#define RT_GC ((RESTYPE)3|RC_CACHED)
#define RT_WINDOW ((RESTYPE)1|RC_DRAWABLE)
#define RT_PIXMAP ((RESTYPE)2|RC_DRAWABLE)
#define RT_GC ((RESTYPE)3)
#undef RT_FONT
#undef RT_CURSOR
#define RT_FONT ((RESTYPE)4)