[glib/glib-2-54] g_source_set_ready_time: Move no-op fast-path under the lock
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/glib-2-54] g_source_set_ready_time: Move no-op fast-path under the lock
- Date: Fri, 5 Jan 2018 21:37:20 +0000 (UTC)
commit b6629ef8501ada783e770aa191a5a05dd1c8f259
Author: Simon McVittie <smcv collabora com>
Date: Sun Dec 24 15:19:31 2017 +0000
g_source_set_ready_time: Move no-op fast-path under the lock
If we don't take the lock, then we don't have the necessary
"happens before" relationships to avoid this situation:
* source->priv->ready_time was equal to ready_time until recently
* another thread has set source->priv->ready_time to a different value
* that write hasn't become visible to this thread yet
* result: we should reset the ready_time, but we don't
Signed-off-by: Simon McVittie <smcv collabora com>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=791754
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=884654
(cherry picked from commit a4686b8ea18c585666edece7b92147a92fcfb841)
glib/gmain.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/glib/gmain.c b/glib/gmain.c
index d5b66bf..95b1943 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -1849,14 +1849,19 @@ g_source_set_ready_time (GSource *source,
g_return_if_fail (source != NULL);
g_return_if_fail (source->ref_count > 0);
- if (source->priv->ready_time == ready_time)
- return;
-
context = source->context;
if (context)
LOCK_CONTEXT (context);
+ if (source->priv->ready_time == ready_time)
+ {
+ if (context)
+ UNLOCK_CONTEXT (context);
+
+ return;
+ }
+
source->priv->ready_time = ready_time;
TRACE (GLIB_SOURCE_SET_READY_TIME (source, ready_time));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]