[gimp] Bug 790631 - C plug-ins instability when processing gegl graphs ...
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 790631 - C plug-ins instability when processing gegl graphs ...
- Date: Wed, 22 Nov 2017 09:38:26 +0000 (UTC)
commit b6cb1d167c8f52b550df624de7fd6265e6240be2
Author: Ell <ell_se yahoo com>
Date: Wed Nov 22 04:23:05 2017 -0500
Bug 790631 - C plug-ins instability when processing gegl graphs ...
... with several threads
Commit d8ae5817034582c5d41d4d0812c60dfd713d3840 didn't go far
enough in protecting GimpTileBackendPlugin against race conditions.
The underlying GimpTile cache is shared across all drawables, so we
must use a common lock for all instances of GimpTileBackendPlugin,
instead of one per instance.
Do just that -- replace the per-instance mutex of
GimpTileBackendPlugin with a global one. This makes
GimpTileBackendPlugin instances thread-safe w.r.t. themselves, and
w.r.t other GimpTileBackendPlugin instances. However, we don't aim
to make GimpTileBackendPlugin thread-safe w.r.t. other libgimp
functions at this point, since the original API has never been
thread-safe.
libgimp/gimptilebackendplugin.c | 20 +++++++++-----------
1 files changed, 9 insertions(+), 11 deletions(-)
---
diff --git a/libgimp/gimptilebackendplugin.c b/libgimp/gimptilebackendplugin.c
index 9791c72..233fffc 100644
--- a/libgimp/gimptilebackendplugin.c
+++ b/libgimp/gimptilebackendplugin.c
@@ -34,7 +34,6 @@
struct _GimpTileBackendPluginPrivate
{
- GMutex mutex;
GimpDrawable *drawable;
gboolean shadow;
gint mul;
@@ -85,6 +84,9 @@ G_DEFINE_TYPE (GimpTileBackendPlugin, _gimp_tile_backend_plugin,
#define parent_class _gimp_tile_backend_plugin_parent_class
+static GMutex backend_plugin_mutex;
+
+
static void
_gimp_tile_backend_plugin_class_init (GimpTileBackendPluginClass *klass)
{
@@ -107,8 +109,6 @@ _gimp_tile_backend_plugin_init (GimpTileBackendPlugin *backend)
GimpTileBackendPluginPrivate);
source->command = gimp_tile_backend_plugin_command;
-
- g_mutex_init (&backend->priv->mutex);
}
static void
@@ -119,8 +119,6 @@ gimp_tile_backend_plugin_finalize (GObject *object)
if (backend->priv->drawable) /* This also causes a flush */
gimp_drawable_detach (backend->priv->drawable);
- g_mutex_clear (&backend->priv->mutex);
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -138,28 +136,28 @@ gimp_tile_backend_plugin_command (GeglTileSource *tile_store,
switch (command)
{
case GEGL_TILE_GET:
- g_mutex_lock (&backend_plugin->priv->mutex);
+ g_mutex_lock (&backend_plugin_mutex);
result = gimp_tile_read_mul (backend_plugin, x, y);
- g_mutex_unlock (&backend_plugin->priv->mutex);
+ g_mutex_unlock (&backend_plugin_mutex);
break;
case GEGL_TILE_SET:
- g_mutex_lock (&backend_plugin->priv->mutex);
+ g_mutex_lock (&backend_plugin_mutex);
gimp_tile_write_mul (backend_plugin, x, y, gegl_tile_get_data (data));
gegl_tile_mark_as_stored (data);
- g_mutex_unlock (&backend_plugin->priv->mutex);
+ g_mutex_unlock (&backend_plugin_mutex);
break;
case GEGL_TILE_FLUSH:
- g_mutex_lock (&backend_plugin->priv->mutex);
+ g_mutex_lock (&backend_plugin_mutex);
gimp_drawable_flush (backend_plugin->priv->drawable);
- g_mutex_unlock (&backend_plugin->priv->mutex);
+ g_mutex_unlock (&backend_plugin_mutex);
break;
default:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]