gthreadedresolver: Switch to using a separate thread pool and support timeouts
Rather than running lookups in the global shared thread pool belonging
to GTask, run them in a private thread pool.
This is needed because the global shared thread pool is constrained to
only 14 threads. If there are 14 ongoing calls to
g_task_run_in_thread() from any library/code in the process, and then
one of them asks to do a DNS lookup, the lookup will block forever.
Under certain circumstances, particularly where there are a couple of
deep chains of dependent tasks running with g_task_run_in_thread(),
this can livelock the program.
Since GResolver is likely to be called as a frequent leaf call in
certain workloads, and in particular there are likely to be several
lookups requested at the same time, it makes sense to move resolver
lookups to a private thread pool.
At the same time, add timeout support as GResolver:timeout.
Without a timeout, some lookup requests can go on forever, typically due to bugs in underlying systems.
This can have particularly significant effects on the Happy Eyeballs
algorithm in GSocketClient, which relies on multiple name lookups as
its first step.
Signed-off-by: Philip Withnall pwithnall@endlessos.org