After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 157306 - [patch] gdk-pixbuf initialization thread safety
[patch] gdk-pixbuf initialization thread safety
Status: RESOLVED FIXED
Product: gdk-pixbuf
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2004-11-04 04:21 UTC by Colin Walters
Modified: 2010-07-10 04:06 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
thread safe initialization (459 bytes, patch)
2004-11-04 04:21 UTC, Colin Walters
none Details | Review
thread safe initialization, take 2 (1.87 KB, patch)
2004-11-04 04:37 UTC, Colin Walters
needs-work Details | Review
thread safe initialization, take 3 (1.67 KB, patch)
2004-11-05 03:48 UTC, Colin Walters
none Details | Review

Description Colin Walters 2004-11-04 04:21:32 UTC
Per our lunchtime conversation, here's a little patch to make gdk-pixbuf's
initalization threadsafe.

I did a quick analysis for other possible thread issues in the gdk-pixbuf core
code as well as the io-* files; as far as I can tell, this appears to be the
only issue.
Comment 1 Colin Walters 2004-11-04 04:21:56 UTC
Created attachment 33415 [details] [review]
thread safe initialization
Comment 2 Colin Walters 2004-11-04 04:27:41 UTC
Hm, actually I take that back - things may not be as simple as this, because two
threads may load a module later.  I'll see if I can cook up a patch for that.
Comment 3 Colin Walters 2004-11-04 04:37:52 UTC
Created attachment 33416 [details] [review]
thread safe initialization, take 2
Comment 4 Colin Walters 2004-11-04 18:56:44 UTC
Matthias pointed out that in the non-G_MODULE_SUPPORTED case, we could get
double locking because gdk_pixbuf_io_init does locking and calls
_gdk_pixbuf_load_module, which itself does locking.  The fix is just to have a
_gdk_pixbuf_load_module_unlocked call.  I'll update this patch tonight.
Comment 5 Colin Walters 2004-11-05 03:48:38 UTC
Created attachment 33456 [details] [review]
thread safe initialization, take 3
Comment 6 Matthias Clasen 2004-11-12 05:43:25 UTC
2004-11-12  Matthias Clasen  <mclasen@redhat.com>

	Changes to make gdk-pixbuf threadsafe  (#157310, #157306, 
	Colin Walters):
	
	* gdk-pixbuf-io.h (enum GdkPixbufFormatFlags): Add 
	GDK_PIXBUF_FORMAT_THREADSAFE to indicate that an image loader
	is threadsafe.

	* gdk-pixbuf-io.c (get_file_formats, _gdk_pixbuf_load_module): 
	Use a lock to make initialization of global data structures 
	threadsafe.
	* gdk-pixbuf-private.h: 
	* gdk-pixbuf-io.c (_gdk_pixbuf_lock, _gdk_pixbuf_unlock): 
	Auxiliary functions which use another lock to protect 
	threadunsafe image loaders.
	
	* gdk-pixbuf-io.c (gdk_pixbuf_real_save): 
	(save_to_callback_with_tmp_file): 
	(gdk_pixbuf_real_save_to_callback): 
	(gdk_pixbuf_new_from_xpm_data): 
	(_gdk_pixbuf_generic_image_load): 
	* gdk-pixbuf-animation.c (gdk_pixbuf_animation_new_from_file): 
	* gdk-pixbuf-loader.c (gdk_pixbuf_loader_load_module): 
	(gdk_pixbuf_loader_close): 
	(gdk_pixbuf_loader_finalize): 
	Use _gdk_pixbuf_lock() and _gdk_pixbuf_unlock().

	* io-ani.c, io-bmp.c, io-gif.c, io-ico.c:
	* io-jpeg.c, io-pcx.c, io-png.c, io-pnm.c:
	* io-ras.c, io-tga.c, io-wbmp.c, io-xbm.c:
	* io-xpm.c: Mark as threadsafe.
	
	* io-tiff.c: Remove pointless locking, mark as 
	threadunsafe.