diff options
author | David Woodhouse <dwmw2@infradead.org> | 2016-06-20 14:25:27 +0100 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2016-06-23 10:11:53 +0300 |
commit | 80d234fc23f3cb0011788a4af2ba4e8ebf13eb65 (patch) | |
tree | df68f6379f5369a8caacefddaceca3fc906e27e5 | |
parent | 3fd8f63041a5e26ec90c67317f0f30f7d74598d0 (diff) | |
download | pacrunner-80d234fc23f3cb0011788a4af2ba4e8ebf13eb65.tar.gz |
proxy: Add pacrunner_js_clear_proxy()
We'll want this for a sane per-proxy-config cleanup of the JS context.
-rw-r--r-- | plugins/v8.cc | 1 | ||||
-rw-r--r-- | src/js.c | 16 | ||||
-rw-r--r-- | src/js.h | 1 | ||||
-rw-r--r-- | src/pacrunner.h | 1 | ||||
-rw-r--r-- | src/proxy.c | 2 |
5 files changed, 21 insertions, 0 deletions
diff --git a/plugins/v8.cc b/plugins/v8.cc index e947bed..93a1ea5 100644 --- a/plugins/v8.cc +++ b/plugins/v8.cc @@ -302,6 +302,7 @@ static struct pacrunner_js_driver v8_driver = { "v8", PACRUNNER_JS_PRIORITY_HIGH, v8_set_proxy, + NULL, v8_execute, }; @@ -69,6 +69,22 @@ int __pacrunner_js_set_proxy(struct pacrunner_proxy *proxy) return -ENXIO; } +int __pacrunner_js_clear_proxy(struct pacrunner_proxy *proxy) +{ + GSList *list; + + for (list = js_driver_list; list; list = list->next) { + struct pacrunner_js_driver *driver = list->data; + + if (driver->clear_proxy) + return driver->clear_proxy(proxy); + else + return 0; + } + + return -ENXIO; +} + char *__pacrunner_js_execute(struct pacrunner_proxy *proxy, const char *url, const char *host) { @@ -27,6 +27,7 @@ struct pacrunner_js_driver { const char *name; int priority; int (*set_proxy) (struct pacrunner_proxy *proxy); + int (*clear_proxy) (struct pacrunner_proxy *proxy); char *(*execute)(struct pacrunner_proxy *proxy, const char *url, const char *host); }; diff --git a/src/pacrunner.h b/src/pacrunner.h index 7b7ad15..87c51da 100644 --- a/src/pacrunner.h +++ b/src/pacrunner.h @@ -113,5 +113,6 @@ char *__pacrunner_mozjs_execute(const char *url, const char *host); int __pacrunner_js_init(void); void __pacrunner_js_cleanup(void); int __pacrunner_js_set_proxy(struct pacrunner_proxy *proxy); +int __pacrunner_js_clear_proxy(struct pacrunner_proxy *proxy); char *__pacrunner_js_execute(struct pacrunner_proxy *proxy, const char *url, const char *host); diff --git a/src/proxy.c b/src/proxy.c index 47be08a..08ae3dd 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -128,6 +128,8 @@ void pacrunner_proxy_unref(struct pacrunner_proxy *proxy) if (!g_atomic_int_dec_and_test(&proxy->refcount)) return; + __pacrunner_js_clear_proxy(proxy); + reset_proxy(proxy); g_list_free_full(proxy->domains, proxy_domain_destroy); |