[pango/threadsafe-failed-attempt: 7/11] Make fontset cache threadsafe
- From: Behdad Esfahbod <behdad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/threadsafe-failed-attempt: 7/11] Make fontset cache threadsafe
- Date: Thu, 15 Nov 2012 19:18:10 +0000 (UTC)
commit 8fe4d29b944e7cfcc9d7a998be9fbadcbe0c3fb9
Author: Behdad Esfahbod <behdad behdad org>
Date: Mon Oct 15 21:07:59 2012 -0500
Make fontset cache threadsafe
I still see crashes in there though. Investigating.
pango/pangofc-fontmap.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index 6e47d08..84f2b94 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -109,6 +109,7 @@ struct _PangoFcFontMapPrivate
{
PHashTable *fontset_hash; /* Maps PangoFcFontsetKey -> PangoFcFontset */
GQueue *fontset_cache; /* Recently used fontsets */
+ GMutex fontset_cache_lock;
PHashTable *font_hash; /* Maps PangoFcFontKey -> PangoFcFont */
@@ -1081,6 +1082,9 @@ pango_fc_font_map_fini (PangoFcFontMap *fcfontmap)
g_queue_free (priv->fontset_cache);
priv->fontset_cache = NULL;
+ if (priv->fontset_cache_lock.p) /* Work around bug 686192 */
+ g_mutex_clear (&priv->fontset_cache_lock);
+
p_hash_table_destroy (priv->fontset_hash);
priv->fontset_hash = NULL;
@@ -1702,10 +1706,12 @@ pango_fc_fontset_cache (PangoFcFontset *fontset,
PangoFcFontMapPrivate *priv = fcfontmap->priv;
GQueue *cache = priv->fontset_cache;
+ g_mutex_lock (&priv->fontset_cache_lock);
+
if (fontset->cache_link)
{
if (fontset->cache_link == cache->head)
- return;
+ goto done;
/* Already in cache, move to head
*/
@@ -1730,6 +1736,9 @@ pango_fc_fontset_cache (PangoFcFontset *fontset,
}
g_queue_push_head_link (cache, fontset->cache_link);
+
+done:
+ g_mutex_unlock (&priv->fontset_cache_lock);
}
static PangoFontset *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]