image loaders and thread safety



Hi,

I'm working on Imsep more, and I made the image loader multithreaded.  I
also wrote a multithreaded torture test which sends the loader lots of
images at once.

It held up surprisingly well, but one problem that quickly became
apparent is that librsvg is not at all thread safe.  It calls into both
fontconfig and pango, neither of which are thread-aware, and both have
static global data structures.  

The best long term solution is to make fontconfig and pango threadsafe,
or at least thread-aware, but that doesn't solve the problem that exists
now.  Also, there is always the possibility of third-party loaders of
dubious threadsafeness.  

So what I'm thinking is to have a flag in the loader, say
GDK_PIXBUF_FORMAT_THREADSAFE.  If a loader didn't export this flag, then
gdk-pixbuf would transparently lock/unlock a global mutex for that
format around calls into it.  Once someone has inspected the code and
libraries used by a loader, the threadsafe flag could be added.  The
other alternative of course is a blacklist, but it seems better to be
safe than sorry to me.

Thoughts?

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]