Skip to content

Backport !2742 “proxyaddressenumerator: set error parameter more thoughtfully” to glib-2-72

It doesn't make sense for a proxy resolver to return NULL without an error on the first call. Whereas a DNS resolver would do this to indicate that a query completed successfully but found no results, a proxy resolver should return "direct://" instead. Therefore, if we are going to return NULL, we ought to have an error as well. Let's make sure this actually happens by adding some fallback errors just in case GProxyResolver feeds us weird results.

Additionally, we should not return any errors except G_IO_ERROR_CANCELLED after the very first iteration. This is an API contract of GSocketAddressEnumerator. Let's add some checks to ensure this.

Note that we have inadequate test coverage for GProxyAddressEnumerator. It's tested here only via GSocketClient. We could do a bit better by testing it directly as well. For example, I've added tests to see what happens when GProxyResolver returns both a valid and an invalid URI, but it's not so interesting here because GSocketClient always uses the valid result and ignores the error from GProxyAddressEnumerator.

(Backport to 2.72: Dropped new translatable strings in error messages to avoid additional translation work on a stable branch. The error messages are unlikely to be seen by users.)

Fixes #2597 (closed)


This was a trivial cherry-pick from !2742 (merged) (only one out of five commits, as suggested by @mcatanzaro). I then tweaked it to unmark the two new translatable strings as translatable, in order to avoid breaking the stable branch string freeze. No other changes.

Merge request reports