mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-24 11:12:11 +01:00
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
This commit is contained in:
parent
ca1aaccbff
commit
a4686b8ea1
11
glib/gmain.c
11
glib/gmain.c
@ -1848,14 +1848,19 @@ g_source_set_ready_time (GSource *source,
|
|||||||
g_return_if_fail (source != NULL);
|
g_return_if_fail (source != NULL);
|
||||||
g_return_if_fail (source->ref_count > 0);
|
g_return_if_fail (source->ref_count > 0);
|
||||||
|
|
||||||
if (source->priv->ready_time == ready_time)
|
|
||||||
return;
|
|
||||||
|
|
||||||
context = source->context;
|
context = source->context;
|
||||||
|
|
||||||
if (context)
|
if (context)
|
||||||
LOCK_CONTEXT (context);
|
LOCK_CONTEXT (context);
|
||||||
|
|
||||||
|
if (source->priv->ready_time == ready_time)
|
||||||
|
{
|
||||||
|
if (context)
|
||||||
|
UNLOCK_CONTEXT (context);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
source->priv->ready_time = ready_time;
|
source->priv->ready_time = ready_time;
|
||||||
|
|
||||||
TRACE (GLIB_SOURCE_SET_READY_TIME (source, ready_time));
|
TRACE (GLIB_SOURCE_SET_READY_TIME (source, ready_time));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user