aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2016-06-20 14:24:15 +0100
committerPatrik Flykt <patrik.flykt@linux.intel.com>2016-06-23 10:11:53 +0300
commitc57a6d3985944edbb0579187273f0051676eee3b (patch)
treeaec27957faa6a3e652cb931531bafc3f6bd6a133
parentba18cf534d77efc8352104a7e5409bd921784c1f (diff)
downloadpacrunner-c57a6d3985944edbb0579187273f0051676eee3b.tar.gz
proxy: Fix handling of proxy->domains
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.
-rw-r--r--src/proxy.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/proxy.c b/src/proxy.c
index 2ebc75d..536345f 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,9 @@ void pacrunner_proxy_unref(struct pacrunner_proxy *proxy)
reset_proxy(proxy);
+ g_list_free_full(proxy->domains, proxy_domain_destroy);
+ proxy->domains = NULL;
+
g_free(proxy->interface);
g_free(proxy);
}
@@ -168,8 +167,11 @@ int pacrunner_proxy_set_domains(struct pacrunner_proxy *proxy, char **domains)
if (!proxy)
return -EINVAL;
+ 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;