aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2016-06-20 14:25:27 +0100
committerPatrik Flykt <patrik.flykt@linux.intel.com>2016-06-23 10:11:53 +0300
commit80d234fc23f3cb0011788a4af2ba4e8ebf13eb65 (patch)
treedf68f6379f5369a8caacefddaceca3fc906e27e5
parent3fd8f63041a5e26ec90c67317f0f30f7d74598d0 (diff)
downloadpacrunner-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.cc1
-rw-r--r--src/js.c16
-rw-r--r--src/js.h1
-rw-r--r--src/pacrunner.h1
-rw-r--r--src/proxy.c2
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,
};
diff --git a/src/js.c b/src/js.c
index ff08cee..3a9274e 100644
--- a/src/js.c
+++ b/src/js.c
@@ -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)
{
diff --git a/src/js.h b/src/js.h
index ea76849..e5d7abc 100644
--- a/src/js.h
+++ b/src/js.h
@@ -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);