[Mesa-dev] Mesa garbage collection and threads

Andy Skinner Andy.Skinner at mathworks.com
Wed Feb 9 11:15:31 PST 2011

Hi.  We've had some problems with XMesaGarbageCollect with multiple threads.  For various reasons, we've had different Display pointers on different threads.  We have a problem when XSync is called on a Display in the list of Mesa buffers, on a thread where we weren't intending to handle that Display.  That's because XMesaGarbageCollect goes through every buffer and for each window with a valid Display*, does an XSync and then tests whether the window exists.  Various of these could cause some excitement for us, but we'd love to not XSync things on whatever thread.

One proposal we have is to have XMesaGarbageCollect accept a Display* argument.  The places where it is called all have a Display*, so it could just be passed in.  The condition just before the XSync could see whether the buffer's Display* is the same as the one passed in.  This, in our case, would prevent XSync on a Display* that we'd like to handle on a different thread.

There is a possibility of leaking a buffer, however, if we didn't ever call a function that calls XMesaGarbageCollect, like fake_glXDestroyContext() or fake_glXCreateNewContext(), for a particular Display*.  But anytime you call one of those for a Display, any abandoned buffers on that display would be cleaned up.

This isn't a thread-based approach, but would help our particular situation.

I know there were people concerned with XMesaGarbageCollect last fall, from looking at archives.  There were threading issues, concerns about pixmaps, etc.   I saw someone proposed a patch, but it wasn't in the archive.  Anything happening with this?

Would our proposal, having XMesaGarbageCollect accept a Display* and only calling XSync and testing buffers associated with that Display*, cause someone else problems?  Would it go far enough to help anyone else?

I could submit my patch, but I want someone familiar with this code to comment.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20110209/e926597c/attachment.htm>

More information about the mesa-dev mailing list