[glib] Fix an invalid non-looping use of GCond
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Fix an invalid non-looping use of GCond
- Date: Tue, 4 Oct 2011 15:59:37 +0000 (UTC)
commit 449a1e8bfd0ea7e8db1e3a436cf182b5cc71aa75
Author: Ryan Lortie <desrt desrt ca>
Date: Tue Oct 4 11:07:15 2011 -0400
Fix an invalid non-looping use of GCond
The GIOScheduler was using a GCond in a way that didn't deal with the
possibility of spurious wakeups. Add an explicit predicate and a loop.
Problem caught by Matthias Clasen.
https://bugzilla.gnome.org/show_bug.cgi?id=660739
gio/gioscheduler.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/gio/gioscheduler.c b/gio/gioscheduler.c
index 9f83977..e75e330 100644
--- a/gio/gioscheduler.c
+++ b/gio/gioscheduler.c
@@ -278,6 +278,7 @@ typedef struct {
GMutex ack_lock;
GCond ack_condition;
+ gboolean ack;
} MainLoopProxy;
static gboolean
@@ -291,6 +292,7 @@ mainloop_proxy_func (gpointer data)
proxy->notify (proxy->data);
g_mutex_lock (&proxy->ack_lock);
+ proxy->ack = TRUE;
g_cond_signal (&proxy->ack_condition);
g_mutex_unlock (&proxy->ack_lock);
@@ -347,7 +349,8 @@ g_io_scheduler_job_send_to_mainloop (GIOSchedulerJob *job,
g_source_attach (source, job->context);
g_source_unref (source);
- g_cond_wait (&proxy->ack_condition, &proxy->ack_lock);
+ while (!proxy->ack)
+ g_cond_wait (&proxy->ack_condition, &proxy->ack_lock);
g_mutex_unlock (&proxy->ack_lock);
ret_val = proxy->ret_val;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]