[pango/fix-deadlocks] Try to fix hands that people have observed
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/fix-deadlocks] Try to fix hands that people have observed
- Date: Wed, 31 Mar 2021 20:22:38 +0000 (UTC)
commit 8485934c47abaf864f45d0c5b39463cbd1fcb90d
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Mar 31 16:21:55 2021 -0400
Try to fix hands that people have observed
Sadly, adding memory barriers by going all atomic
on fc_initialized does not fix the hang of gnome-text-editor
yet.
pango/pangofc-fontmap.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index 813b6c78..45a81142 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -1357,7 +1357,7 @@ init_in_thread (GTask *task,
pango_trace_mark (before, "FcInit", NULL);
g_mutex_lock (&fc_init_mutex);
- fc_initialized = 2;
+ g_atomic_int_set (&fc_initialized, 2);
g_cond_broadcast (&fc_init_cond);
g_mutex_unlock (&fc_init_mutex);
}
@@ -1367,17 +1367,17 @@ start_init_in_thread (PangoFcFontMap *fcfontmap)
{
g_mutex_lock (&fc_init_mutex);
- if (fc_initialized == 0)
+ if (g_atomic_int_compare_and_exchange (&fc_initialized, 0, 1))
{
GTask *task;
- fc_initialized = 1;
-
task = g_task_new (fcfontmap, NULL, NULL, NULL);
g_task_set_name (task, "[pango] FcInit");
g_task_run_in_thread (task, init_in_thread);
g_object_unref (task);
}
+ else
+ g_cond_broadcast (&fc_init_cond);
g_mutex_unlock (&fc_init_mutex);
}
@@ -1389,7 +1389,7 @@ wait_for_fc_init (void)
gboolean waited = FALSE;
g_mutex_lock (&fc_init_mutex);
- while (fc_initialized < 2)
+ while (g_atomic_int_get (&fc_initialized) < 2)
{
waited = TRUE;
g_cond_wait (&fc_init_cond, &fc_init_mutex);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]