gmain: Go back to using the standard unref logic if the final unref failed

If going from 1 -> 0 references failed, then we should restart the unref
process, by potentially re-entering in the dispose function again if
instead something else re-references us and we're going to drop the last
one again.
This commit is contained in:
Marco Trevisan (Treviño) 2025-02-19 16:28:12 +01:00
parent 7b61cc8277
commit 6052374c78

View File

@ -2255,12 +2255,13 @@ retry_beginning:
/* At this point the source can have been revived by any of the threads
* acting on it or it's really ready for being finalized.
*/
if (!g_atomic_int_dec_and_test (&source->ref_count))
if (!g_atomic_int_compare_and_exchange_full ((int *) &source->ref_count,
1, 0, &old_ref))
{
if (!have_lock && context)
UNLOCK_CONTEXT (context);
return;
goto retry_beginning;
}
TRACE (GLIB_SOURCE_BEFORE_FREE (source, context,