mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02:00
Revert "gcancellable: Reference the object before locking when doing signal emission"
This reverts commit 54d9c26b34
.
Merge request !2765 has caused a thread safety regression in
`GCancellableSource` disposal. It landed too late in the cycle to fix
with any confidence before the 2.82 release, so the changes are being
reverted for the `glib-2-82` branch and 2.82.0 release.
Fixes: #3448
Re-opens: #774, #2309, #2313
This commit is contained in:
@@ -495,16 +495,11 @@ g_cancellable_cancel (GCancellable *cancellable)
|
||||
|
||||
priv = cancellable->priv;
|
||||
|
||||
/* We add a reference before locking, to avoid that potential toggle
|
||||
* notifications on the object might happen while we're locked.
|
||||
*/
|
||||
g_object_ref (cancellable);
|
||||
g_mutex_lock (&priv->mutex);
|
||||
|
||||
if (!g_atomic_int_compare_and_exchange (&priv->cancelled, FALSE, TRUE))
|
||||
{
|
||||
g_mutex_unlock (&priv->mutex);
|
||||
g_object_unref (cancellable);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -513,6 +508,7 @@ g_cancellable_cancel (GCancellable *cancellable)
|
||||
if (priv->wakeup)
|
||||
GLIB_PRIVATE_CALL (g_wakeup_signal) (priv->wakeup);
|
||||
|
||||
g_object_ref (cancellable);
|
||||
g_signal_emit (cancellable, signals[CANCELLED], 0);
|
||||
|
||||
if (g_atomic_int_dec_and_test (&priv->cancelled_running))
|
||||
|
Reference in New Issue
Block a user