In create_proxy_config() we were calling pacrunner_proxy_set_domains(),
which was returning an error if passed a NULL list of domains.
Then we were calling pacrunner_proxy_set_auto() or one of its friends,
which all call reset_proxy() and *delete* the list of domains, if one
was set.
Treat proxy->domains like proxy->interface, and don't reset it in
reset_proxy(). And fix up pacrunner_proxy_set_domains() so that it
happily accepts a NULL domains list and behaves appropriately. As
a side-effect, this stops pacrunner_proxy_set_domains() from being
additive — if you call it a second time it'll clear the original set
and set just the ones you've just passed, instead of adding new
domains to the list. Which is a much saner semantic.
---
src/proxy.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/proxy.c b/src/proxy.c
index 2ebc75d..95ee75c 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -115,10 +115,6 @@ static void reset_proxy(struct pacrunner_proxy *proxy)
__pacrunner_manual_destroy_excludes(proxy->excludes);
proxy->excludes = NULL;
-
- if (proxy->domains)
- g_list_free_full(proxy->domains, proxy_domain_destroy);
- proxy->domains = NULL;
}
void pacrunner_proxy_unref(struct pacrunner_proxy *proxy)
@@ -133,6 +129,10 @@ void pacrunner_proxy_unref(struct pacrunner_proxy *proxy)
reset_proxy(proxy);
+ if (proxy->domains)
+ g_list_free_full(proxy->domains, proxy_domain_destroy);
+ proxy->domains = NULL;
+
g_free(proxy->interface);
g_free(proxy);
}
@@ -168,8 +168,12 @@ int pacrunner_proxy_set_domains(struct pacrunner_proxy *proxy, char
**domains)
if (!proxy)
return -EINVAL;
+ if (proxy->domains)
+ g_list_free_full(proxy->domains, proxy_domain_destroy);
+ proxy->domains = NULL;
+
if (!domains)
- return -EINVAL;
+ return 0;
for (domain = domains; *domain; domain++) {
struct proxy_domain *data;
--
2.7.4
--
David Woodhouse Open Source Technology Centre
David.Woodhouse(a)intel.com Intel Corporation
Attachments:
- smime.p7s
(application/x-pkcs7-signature — 5.6 KB)
Show replies by date