This prevents a livelock of the UI thread, because it’s possible for the
UI (main) thread to call gs_fedora_third_party_is_available()
while
a worker thread is calling gs_fedora_third_party_query_thread()
.
The worker thread may take a long time to run, and currently all the
time it’s running it’s holding the lock in GsFedoraThirdParty
.
Unfortunately, gs_fedora_third_party_is_available()
needs to be able
to take that lock.
This results in freezing the main thread until the worker thread returns.
Fix that by reducing the size of the locked sections, and moving all the subprocess spawning outside the locked sections.
Two main changes are needed to do this:
- Make
gs_fedora_third_party_ensure_executable_locked()
return a copy of the executable path, so that callers can use that and drop their lock, rather than subsequently referring toself->executable
with the lock held. - Split the locked section in
gs_fedora_third_party_list_sync()
in two: once to check whether an update ofself->repos
is needed, then the subprocess is spawned without the lock held, then the lock is taken again to write the results to theGsFedoraThirdParty
object.
Signed-off-by: Philip Withnall pwithnall@endlessos.org