scaled-font: Prevent a recursive mutex lock for removing a failed glyph

If we fail to create a glyph, and it is the only one in the glyph page,
we then pluck that page out of the global glyph cache. The cache destroy
callback tries to take the scaled_font lock again, causing a lockup.
Rework the error path to avoid taking that lock in this case - still a
potential lock ordering issue remains.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2013-06-18 16:06:28 +01:00
parent df1ca22ada
commit 519dff51db

View file

@ -2905,8 +2905,12 @@ _cairo_scaled_font_free_last_glyph (cairo_scaled_font_t *scaled_font,
if (--page->num_glyphs == 0) {
CAIRO_MUTEX_LOCK (_cairo_scaled_glyph_page_cache_mutex);
/* Temporarily disconnect callback to avoid recursive locking */
cairo_scaled_glyph_page_cache.entry_destroy = NULL;
_cairo_cache_remove (&cairo_scaled_glyph_page_cache,
&page->cache_entry);
_cairo_scaled_glyph_page_destroy (scaled_font, page);
cairo_scaled_glyph_page_cache.entry_destroy = _cairo_scaled_glyph_page_pluck;
CAIRO_MUTEX_UNLOCK (_cairo_scaled_glyph_page_cache_mutex);
}
}