gs-plugin-loader: Run old-style plugin jobs in a custom thread pool

Rather than running them in the thread pool shared between all GTasks in a process.

Using the GTask thread pool can lead to livelocks if too many tasks are running at once and all of them end up blocking on another operation which also uses the GTask thread pool. The combination of the following factors can commonly reproduce this livelock problem:

  1. GTask thread pool only has 14 spaces.
  2. DNS lookups via GResolver are run in the GTask thread pool (unless using a version of GLib with glib!3397 (merged)).
  3. All pending tasks depend on network I/O at some point, which is the case for most gnome-software jobs.

Eventually, this will be fixed by no longer using old-style plugin jobs: new-style plugin jobs either execute asynchronously in the main thread or run in plugin-specific worker threads, and hence don’t consume unbounded GTask resources. See #1472.

It’s going to take a few more cycles to finish off #1472, however, so in the meantime we can eliminate the bottleneck on the constrained GTask thread pool by running old-style plugin jobs in a custom thread pool.

Signed-off-by: Philip Withnall

Fixes: #2105 (closed)

Merge request reports