AsComponent: Centralize GOnce guard to fix an assertion failure #385
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
trivial: Make as_component_create_token_cache static
It's no longer called from outside AsComponent, so it doesn't need to be
extern any more.
AsComponent: Centralize GOnce guard to fix an assertion failure
The token cache only needs to be created once per AsComponent.
Previously, each of the two callers of as_component_create_token_cache()
guarded it with an atomic (GOnce) access to priv->token_cache_valid,
but the implementation had a redundant non-atomic guard. This resulted
in a GLib assertion failure on leaving the function, because the atomic
boolean flag indicating whether initialization has completed is not
meant to be set non-null until g_once_init_leave().
In particular, this resolves test failures in Flatpak 1.13.x
(which has been ported from libappstream-glib to libappstream) when it
runs
flatpak searchfrom its test suite.Resolves:
flatpak searchassertion failure since port to libappstream: g_atomic_pointer_get (value_location) == 0 #384