Send connman mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.01.org/mailman/listinfo/connman
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."
Today's Topics:
1. [PATCH v2 2/2] js: Add proxy argument to JS execute()
methods. (David Woodhouse)
2. Re: [PATCH 1/2] proxy: Fix handling of proxy->domains
(Tomasz Bursztyka)
3. Re: [PATCH 1/2] proxy: Fix handling of proxy->domains
(David Woodhouse)
4. Re: [PATCH 1/2] proxy: Fix handling of proxy->domains
(Tomasz Bursztyka)
----------------------------------------------------------------------
Message: 1
Date: Fri, 17 Jun 2016 12:34:06 +0100
From: David Woodhouse <[email protected]>
To: [email protected]
Subject: [PATCH v2 2/2] js: Add proxy argument to JS execute()
methods.
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
For now, just make the back ends automatically switch over, if
they're being invoked on a different context to the last invocation.
We'll fix them shortly to support multiple contexts.
---
plugins/mozjs.c | 8 ++++++--
plugins/v8.cc | 10 +++++++---
src/js.c | 5 +++--
src/js.h | 3 ++-
src/pacrunner.h | 3 ++-
src/proxy.c | 2 +-
unit/test-mozjs.c | 16 ++++++++++------
7 files changed, 31 insertions(+), 16 deletions(-)
diff --git a/plugins/mozjs.c b/plugins/mozjs.c
index af91fea..77a0c13 100644
--- a/plugins/mozjs.c
+++ b/plugins/mozjs.c
@@ -222,17 +222,21 @@ static int mozjs_set_proxy(struct pacrunner_proxy *proxy)
return 0;
}
-static char * mozjs_execute(const char *url, const char *host)
+static char * mozjs_execute(struct pacrunner_proxy *proxy, const char *url,
+ const char *host)
{
JSBool result;
jsval rval, args[2];
char *answer, *g_answer;
- DBG("url %s host %s", url, host);
+ DBG("proxy %p url %s host %s", proxy, url, host);
if (!jsctx)
return NULL;
+ if (proxy != current_proxy && mozjs_set_proxy(proxy))
+ return NULL;
+
pthread_mutex_lock(&mozjs_mutex);
JS_BeginRequest(jsctx);
diff --git a/plugins/v8.cc b/plugins/v8.cc
index 6cb28ca..e947bed 100644
--- a/plugins/v8.cc
+++ b/plugins/v8.cc
@@ -251,11 +251,15 @@ static int v8_set_proxy(struct pacrunner_proxy *proxy)
}
-static char *v8_execute(const char *url, const char *host)
+static char *v8_execute(struct pacrunner_proxy *proxy, const char *url,
+ const char *host)
{
- v8::Locker lck;
+ DBG("proxy %p url %s host %s", proxy, url, host);
+
+ if (current_proxy != proxy && v8_set_proxy(proxy))
+ return NULL;
- DBG("url %s host %s", url, host);
+ v8::Locker lck;
if (jsctx.IsEmpty() || jsfn.IsEmpty())
return NULL;
diff --git a/src/js.c b/src/js.c
index 84b8ada..ff08cee 100644
--- a/src/js.c
+++ b/src/js.c
@@ -69,7 +69,8 @@ int __pacrunner_js_set_proxy(struct pacrunner_proxy *proxy)
return -ENXIO;
}
-char *__pacrunner_js_execute(const char *url, const char *host)
+char *__pacrunner_js_execute(struct pacrunner_proxy *proxy, const char *url,
+ const char *host)
{
GSList *list;
@@ -77,7 +78,7 @@ char *__pacrunner_js_execute(const char *url, const char
*host)
struct pacrunner_js_driver *driver = list->data;
if (driver->execute)
- return driver->execute(url, host);
+ return driver->execute(proxy, url, host);
}
return NULL;
diff --git a/src/js.h b/src/js.h
index 91143d1..ea76849 100644
--- a/src/js.h
+++ b/src/js.h
@@ -27,7 +27,8 @@ struct pacrunner_js_driver {
const char *name;
int priority;
int (*set_proxy) (struct pacrunner_proxy *proxy);
- char *(*execute)(const char *url, const char *host);
+ char *(*execute)(struct pacrunner_proxy *proxy, const char *url,
+ const char *host);
};
int pacrunner_js_driver_register(struct pacrunner_js_driver *driver);
diff --git a/src/pacrunner.h b/src/pacrunner.h
index db534cf..71913bb 100644
--- a/src/pacrunner.h
+++ b/src/pacrunner.h
@@ -110,4 +110,5 @@ 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);
-char *__pacrunner_js_execute(const char *url, const char *host);
+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 95ee75c..5010397 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -567,7 +567,7 @@ found:
selected_proxy->servers,
selected_proxy->excludes);
case PACRUNNER_PROXY_METHOD_AUTO:
- return __pacrunner_js_execute(url, host);
+ return __pacrunner_js_execute(selected_proxy, url, host);
}
return NULL;
diff --git a/unit/test-mozjs.c b/unit/test-mozjs.c
index 8ac9741..7ccdee9 100644
--- a/unit/test-mozjs.c
+++ b/unit/test-mozjs.c
@@ -97,7 +97,7 @@ static void test_single_execute_without_pac(void)
g_assert(mozjs_init() == 0);
- result = __pacrunner_js_execute(EXAMPLE_URL, EXAMPLE_HOST);
+ result = __pacrunner_js_execute(proxy, EXAMPLE_URL, EXAMPLE_HOST);
g_test_message("result: %s", result);
mozjs_exit();
@@ -111,7 +111,8 @@ static void test_multiple_execute_without_pac(void)
g_assert(mozjs_init() == 0);
for (i = 0; i < MULTIPLE_COUNT; i++) {
- result = __pacrunner_js_execute(EXAMPLE_URL, EXAMPLE_HOST);
+ result = __pacrunner_js_execute(proxy, EXAMPLE_URL,
+ EXAMPLE_HOST);
g_test_message("result %d: %s", i, result);
}
@@ -126,7 +127,7 @@ static void test_single_execute_with_direct_pac(void)
g_assert(pacrunner_proxy_set_auto(proxy, NULL, DIRECT_PAC) == 0);
- result = __pacrunner_js_execute(EXAMPLE_URL, EXAMPLE_HOST);
+ result = __pacrunner_js_execute(proxy, EXAMPLE_URL, EXAMPLE_HOST);
g_test_message("result: %s", result);
pacrunner_proxy_disable(proxy);
@@ -144,7 +145,8 @@ static void test_multiple_execute_with_direct_pac(void)
g_assert(pacrunner_proxy_set_auto(proxy, NULL, DIRECT_PAC) == 0);
for (i = 0; i < MULTIPLE_COUNT; i++) {
- result = __pacrunner_js_execute(EXAMPLE_URL, EXAMPLE_HOST);
+ result = __pacrunner_js_execute(proxy, EXAMPLE_URL,
+ EXAMPLE_HOST);
g_test_message("result %d: %s", i, result);
}
@@ -163,7 +165,8 @@ static void test_massive_execute_with_direct_pac(void)
g_assert(pacrunner_proxy_set_auto(proxy, NULL, DIRECT_PAC) == 0);
for (i = 0; i < MASSIVE_COUNT; i++) {
- result = __pacrunner_js_execute(EXAMPLE_URL, EXAMPLE_HOST);
+ result = __pacrunner_js_execute(proxy, EXAMPLE_URL,
+ EXAMPLE_HOST);
g_test_message("result %d: %s", i, result);
}
@@ -182,7 +185,8 @@ static void test_multiple_execute_with_example_pac(void)
g_assert(pacrunner_proxy_set_auto(proxy, NULL, EXAMPLE_PAC) == 0);
for (i = 0; i < MULTIPLE_COUNT; i++) {
- result = __pacrunner_js_execute(EXAMPLE_URL, EXAMPLE_HOST);
+ result = __pacrunner_js_execute(proxy, EXAMPLE_URL,
+ EXAMPLE_HOST);
g_test_message("result %d: %s", i, result);
}
--
2.7.4
--
David Woodhouse Open Source Technology Centre
[email protected] Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5760 bytes
Desc: not available
URL:
<http://lists.01.org/pipermail/connman/attachments/20160617/4543cb88/attachment-0001.bin>
------------------------------
Message: 2
Date: Fri, 17 Jun 2016 13:50:13 +0200
From: Tomasz Bursztyka <[email protected]>
To: David Woodhouse <[email protected]>, [email protected]
Subject: Re: [PATCH 1/2] proxy: Fix handling of proxy->domains
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8; format=flowed
Hi David,
> Because logically, it's one operation, to free-and-clear a pointer.
> If we could write it as
> proxy->domains = g_list_free_full(?);
> we would.
>
> Look at all the rest of reset_proxy(), where we do it precisely the
> same. Free and clear in pairs, then a blank line before the next free-
> and-clear pair:
>
>
> g_free(proxy->url);
> proxy->url = NULL;
>
> g_free(proxy->script);
> proxy->script = NULL;
>
> __pacrunner_manual_destroy_servers(proxy->servers);
> proxy->servers = NULL;
>
> __pacrunner_manual_destroy_excludes(proxy->excludes);
> proxy->excludes = NULL;
But these don't have an if () statement before.
Usually, we always break a line after an if () [{] ... [}]
That was just my point.
> It was right the first time. It was right when Atul added it to
> pacrunner_proxy_unref(), and I only got it *wrong* when I extended his
> patch and also added the same to pacrunner_proxy_set_domains()
>
> I'll submit a new patch.
>
------------------------------
Message: 3
Date: Fri, 17 Jun 2016 12:46:01 +0100
From: David Woodhouse <[email protected]>
To: Tomasz Bursztyka <[email protected]>,
[email protected]
Subject: Re: [PATCH 1/2] proxy: Fix handling of proxy->domains
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
On Fri, 2016-06-17 at 13:50 +0200, Tomasz Bursztyka wrote:
>
> But these don't have an if () statement before.
> Usually, we always break a line after an if () [{] ... [}]
> That was just my point.
I'd actually completely blanked that that was an if() and not a
while(). (Doubly stupid, of course, since if it was a while() style
loop when by definition we couldn't need to *set* it to NULL at the
end).
So if the if() even necessary... can't we just call
?g_list_free_full(NULL, ?) anyway?
--
dwmw2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5760 bytes
Desc: not available
URL:
<http://lists.01.org/pipermail/connman/attachments/20160617/17693810/attachment-0001.bin>
------------------------------
Message: 4
Date: Fri, 17 Jun 2016 13:57:12 +0200
From: Tomasz Bursztyka <[email protected]>
To: David Woodhouse <[email protected]>, [email protected]
Subject: Re: [PATCH 1/2] proxy: Fix handling of proxy->domains
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8; format=flowed
>> But these don't have an if () statement before.
>> Usually, we always break a line after an if () [{] ... [}]
>> That was just my point.
> I'd actually completely blanked that that was an if() and not a
> while(). (Doubly stupid, of course, since if it was a while() style
> loop when by definition we couldn't need to *set* it to NULL at the
> end).
>
> So if the if() even necessary... can't we just call
> g_list_free_full(NULL, ?) anyway?
>
I was wondering about that. At least manual does not say you can/cannot
provide a NULL... Just a GList pointer.
So maybe we can't. I haven't tested though ;-?
Tomasz
------------------------------
Subject: Digest Footer
_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman
------------------------------
End of connman Digest, Vol 8, Issue 24
**************************************