gresolver: Set timeout on default resolver to 30s

The default for the class is still to have no timeout, but it seems more
practical for most use cases to set a non-infinite timeout on the
default resolver.

If applications have a more specific use case, they can change the
timeout or replace the default resolver.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3397#note_1731387

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2023-04-26 12:53:37 +01:00
parent 1c4384aec5
commit e73c5ed5e1

View File

@ -55,6 +55,10 @@
* #GNetworkAddress and #GNetworkService provide wrappers around
* #GResolver functionality that also implement #GSocketConnectable,
* making it easy to connect to a remote host/service.
*
* The default resolver (see g_resolver_get_default()) has a timeout of 30s set
* on it since GLib 2.78. Earlier versions of GLib did not support resolver
* timeouts.
*/
typedef enum {
@ -299,7 +303,9 @@ g_resolver_get_default (void)
G_LOCK (default_resolver);
if (!default_resolver)
default_resolver = g_object_new (G_TYPE_THREADED_RESOLVER, NULL);
default_resolver = g_object_new (G_TYPE_THREADED_RESOLVER,
"timeout", 30000,
NULL);
ret = g_object_ref (default_resolver);
G_UNLOCK (default_resolver);