[PATCH 1/4] dix: Update element count in FreeResourceByType()

Keith Packard keithp at keithp.com
Sun May 2 16:48:38 PDT 2010


On Sun, 2 May 2010 17:26:58 -0400, Kristian Høgsberg <krh at bitplanet.net> wrote:
> On Sun, May 2, 2010 at 5:02 PM, Keith Packard <keithp at keithp.com> wrote:
> > On Sat,  1 May 2010 13:31:57 -0400, Kristian Høgsberg <krh at bitplanet.net> wrote:
> >
> >> All resource functions keep clientTable[cid].elements up to date with the
> >> number of resources allocated to the client.  Except
> >> FreeResourceByType().
> >
> > How about FreeClientNeverRetainResources and FreeClientResources?
> 
> I guess they don't do it either... bad assumption on my part.  But it
> *is* a bug, right?  I can fix those too and resend, but I'm just still
> surprised that this bug was in there all the time and not sure if
> instead I'm missing something subtle in the resource code.

FreeResourceByType was added for X11R4 with this bug in place, long
after the authors of the resource code were gone, so I suspect the whole
'elements' invariant was lost. I'd love to know why it was added then;
the server didn't use it at all then, and the core code still does not.

To make sure you're maintaining the invariant correctly, I'd strongly
recommend writing a debug function that walks the resource table and
verifies the number of elements along each hash chain, then simply call
that in every function that modifies the resource DB. Run the server
through a battery of tests that include damage and glx (two heavy users
of FreeReourceByType) and make sure you never break the invariant.

-- 
keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20100502/83614546/attachment.pgp>


More information about the xorg-devel mailing list