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] Pull pacrunner forward to mozjs24 (Jeremy Linton)
2. Re: [PATCH] Pull pacrunner forward to mozjs24 (Marcel Holtmann)
3. Re: [PATCH] Pull pacrunner forward to mozjs24 (Jeremy Linton)
4. Not sure how to fix this bug (Thomas Green)
----------------------------------------------------------------------
Message: 1
Date: Thu, 25 Aug 2016 15:05:12 -0500
From: Jeremy Linton <[email protected]>
To: [email protected]
Subject: [PATCH] Pull pacrunner forward to mozjs24
Message-ID: <[email protected]>
Mozjs185 is getting really old and unsupported. Newer versions
of the mozjs JSAPI are C++ based. Start the conversion to more recent
JSAPI's by updating pacrunner to use mozjs24 which is a common version
being used by a number of distributions. It also happens to be the first
C++ only version of JSAPI.
Signed-off-by: Jeremy Linton <[email protected]>
---
Makefile.am | 6 +++---
configure.ac | 4 ++--
plugins/{mozjs.c => mozjs.cpp} | 36 +++++++++++++++++++-----------------
3 files changed, 24 insertions(+), 22 deletions(-)
rename plugins/{mozjs.c => mozjs.cpp} (82%)
diff --git a/Makefile.am b/Makefile.am
index ee84b75..21a602d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -31,7 +31,7 @@ endif
if MOZJS
js_sources = src/js_funcs.c
builtin_modules += mozjs
-builtin_sources += plugins/mozjs.c
+builtin_sources += plugins/mozjs.cpp
builtin_cflags += @MOZJS_CFLAGS@
builtin_libadd += @MOZJS_LIBS@
endif
@@ -137,7 +137,7 @@ unit_test_pacrunner_LDADD += @CURL_LIBS@
endif
if MOZJS
-unit_test_pacrunner_SOURCES += plugins/mozjs.c
+unit_test_pacrunner_SOURCES += plugins/mozjs.cpp
unit_test_pacrunner_LDADD += @MOZJS_LIBS@ @PTHREAD_LIBS@
@@ -145,7 +145,7 @@ noinst_PROGRAMS += unit/test-mozjs
unit_test_mozjs_SOURCES = unit/test-mozjs.c src/pacrunner.h \
src/proxy.c src/manual.c src/download.c \
- src/js.c plugins/mozjs.c $(js_sources)
+ src/js.c plugins/mozjs.cpp $(js_sources)
unit_test_mozjs_LDADD = @MOZJS_LIBS@ @GLIB_LIBS@ @PTHREAD_LIBS@
endif
diff --git a/configure.ac b/configure.ac
index 42a64a9..d2fc8f8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,8 +76,8 @@ AM_CONDITIONAL(DUKTAPE, test "${enable_duktape}" = "yes")
AC_ARG_ENABLE(mozjs, AC_HELP_STRING([--enable-mozjs],
[enable Mozilla Javascript plugin support]))
if (test "${enable_mozjs}" = "yes"); then
- PKG_CHECK_MODULES(MOZJS, mozjs185, dummy=yes,
- AC_MSG_ERROR(Mozilla Javascript >= 1.8 is required))
+ PKG_CHECK_MODULES(MOZJS, mozjs-24, dummy=yes,
+ AC_MSG_ERROR(Mozilla Javascript >= 24 is required))
AC_SUBST(MOZJS_CFLAGS)
AC_SUBST(MOZJS_LIBS)
fi
diff --git a/plugins/mozjs.c b/plugins/mozjs.cpp
similarity index 82%
rename from plugins/mozjs.c
rename to plugins/mozjs.cpp
index a923203..843b2fa 100644
--- a/plugins/mozjs.c
+++ b/plugins/mozjs.cpp
@@ -34,8 +34,10 @@
#include <jsapi.h>
#pragma GCC diagnostic error "-Wredundant-decls"
+extern "C" {
#include "pacrunner.h"
#include "js.h"
+}
static pthread_mutex_t mozjs_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -43,11 +45,12 @@ struct pacrunner_mozjs {
struct pacrunner_proxy *proxy;
JSContext *jsctx;
JSObject *jsobj;
+ JSAutoCompartment *jsac;
};
-static JSBool myipaddress(JSContext *jsctx, uintN argc, jsval *vp)
+static JSBool myipaddress(JSContext *jsctx, unsigned argc, jsval *vp)
{
- struct pacrunner_mozjs *ctx = JS_GetContextPrivate(jsctx);
+ struct pacrunner_mozjs *ctx = (pacrunner_mozjs
*)JS_GetContextPrivate(jsctx);
char address[NI_MAXHOST];
DBG("");
@@ -68,9 +71,9 @@ static JSBool myipaddress(JSContext *jsctx, uintN argc, jsval
*vp)
return JS_TRUE;
}
-static JSBool dnsresolve(JSContext *jsctx, uintN argc, jsval *vp)
+static JSBool dnsresolve(JSContext *jsctx, unsigned argc, jsval *vp)
{
- struct pacrunner_mozjs *ctx = JS_GetContextPrivate(jsctx);
+ struct pacrunner_mozjs *ctx = (pacrunner_mozjs
*)JS_GetContextPrivate(jsctx);
char address[NI_MAXHOST];
jsval *argv = JS_ARGV(jsctx, vp);
char *host = JS_EncodeString(jsctx, JS_ValueToString(jsctx, argv[0]));
@@ -97,10 +100,10 @@ static JSBool dnsresolve(JSContext *jsctx, uintN argc,
jsval *vp)
static JSClass jscls = {
"global", JSCLASS_GLOBAL_FLAGS,
- JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+ JS_PropertyStub, JS_DeletePropertyStub, JS_PropertyStub,
JS_StrictPropertyStub,
- JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
+ JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, NULL,
+ JSCLASS_NO_OPTIONAL_MEMBERS
};
static JSRuntime *jsrun;
@@ -115,7 +118,7 @@ static int create_object(struct pacrunner_proxy *proxy)
if (!script)
return 0;
- ctx = g_malloc0(sizeof(struct pacrunner_mozjs));
+ ctx = (pacrunner_mozjs *)g_malloc0(sizeof(struct pacrunner_mozjs));
ctx->proxy = proxy;
ctx->jsctx = JS_NewContext(jsrun, 8 * 1024);
@@ -126,12 +129,10 @@ static int create_object(struct pacrunner_proxy *proxy)
JS_SetContextPrivate(ctx->jsctx, ctx);
__pacrunner_proxy_set_jsctx(proxy, ctx);
-#if JS_VERSION >= 185
- ctx->jsobj = JS_NewCompartmentAndGlobalObject(ctx->jsctx, &jscls,
- NULL);
-#else
- ctx->jsobj = JS_NewObject(ctx->jsctx, &jscls, NULL, NULL);
-#endif
+ JS::CompartmentOptions compart_opts;
+ compart_opts.setVersion(JSVERSION_LATEST);
+ ctx->jsobj = JS_NewGlobalObject(ctx->jsctx, &jscls, NULL, compart_opts);
+ ctx->jsac = new JSAutoCompartment(ctx->jsctx, ctx->jsobj);
if (!JS_InitStandardClasses(ctx->jsctx, ctx->jsobj))
pacrunner_error("Failed to init JS standard classes");
@@ -152,13 +153,14 @@ static int create_object(struct pacrunner_proxy *proxy)
static int mozjs_clear_proxy(struct pacrunner_proxy *proxy)
{
- struct pacrunner_mozjs *ctx = __pacrunner_proxy_get_jsctx(proxy);
+ struct pacrunner_mozjs *ctx = (pacrunner_mozjs
*)__pacrunner_proxy_get_jsctx(proxy);
DBG("proxy %p ctx %p", proxy, ctx);
if (!ctx)
return -EINVAL;
+ delete ctx->jsac;
JS_DestroyContext(ctx->jsctx);
__pacrunner_proxy_set_jsctx(proxy, NULL);
@@ -180,7 +182,7 @@ static int mozjs_set_proxy(struct pacrunner_proxy *proxy)
static char * mozjs_execute(struct pacrunner_proxy *proxy, const char *url,
const char *host)
{
- struct pacrunner_mozjs *ctx = __pacrunner_proxy_get_jsctx(proxy);
+ struct pacrunner_mozjs *ctx = (pacrunner_mozjs
*)__pacrunner_proxy_get_jsctx(proxy);
JSBool result;
jsval rval, args[2];
char *answer, *g_answer;
@@ -229,7 +231,7 @@ static int mozjs_init(void)
{
DBG("");
- jsrun = JS_NewRuntime(8 * 1024 * 1024);
+ jsrun = JS_NewRuntime(8 * 1024 * 1024, JS_USE_HELPER_THREADS);
return pacrunner_js_driver_register(&mozjs_driver);
}
--
2.9.2
------------------------------
Message: 2
Date: Thu, 25 Aug 2016 16:12:43 -0400
From: Marcel Holtmann <[email protected]>
To: Jeremy Linton <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] Pull pacrunner forward to mozjs24
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
Hi Jeremy,
> Mozjs185 is getting really old and unsupported. Newer versions
> of the mozjs JSAPI are C++ based. Start the conversion to more recent
> JSAPI's by updating pacrunner to use mozjs24 which is a common version
> being used by a number of distributions. It also happens to be the first
> C++ only version of JSAPI.
>
> Signed-off-by: Jeremy Linton <[email protected]>
> ---
> Makefile.am | 6 +++---
> configure.ac | 4 ++--
> plugins/{mozjs.c => mozjs.cpp} | 36 +++++++++++++++++++-----------------
> 3 files changed, 24 insertions(+), 22 deletions(-)
> rename plugins/{mozjs.c => mozjs.cpp} (82%)
>
> diff --git a/Makefile.am b/Makefile.am
> index ee84b75..21a602d 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -31,7 +31,7 @@ endif
> if MOZJS
> js_sources = src/js_funcs.c
> builtin_modules += mozjs
> -builtin_sources += plugins/mozjs.c
> +builtin_sources += plugins/mozjs.cpp
please do the same as what we did for v8. We want to build .a first so that
linking doesn't happen with CXX.
Regards
Marcel
------------------------------
Message: 3
Date: Thu, 25 Aug 2016 15:20:43 -0500
From: Jeremy Linton <[email protected]>
To: Marcel Holtmann <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] Pull pacrunner forward to mozjs24
Message-ID: <[email protected]>
Content-Type: text/plain; charset=windows-1252; format=flowed
Hi,
On 08/25/2016 03:12 PM, Marcel Holtmann wrote:
> Hi Jeremy,
>
>> Mozjs185 is getting really old and unsupported. Newer versions
>> of the mozjs JSAPI are C++ based. Start the conversion to more recent
>> JSAPI's by updating pacrunner to use mozjs24 which is a common version
>> being used by a number of distributions. It also happens to be the first
>> C++ only version of JSAPI.
>>
>> Signed-off-by: Jeremy Linton <[email protected]>
>> ---
>> Makefile.am | 6 +++---
>> configure.ac | 4 ++--
>> plugins/{mozjs.c => mozjs.cpp} | 36 +++++++++++++++++++-----------------
>> 3 files changed, 24 insertions(+), 22 deletions(-)
>> rename plugins/{mozjs.c => mozjs.cpp} (82%)
>>
>> diff --git a/Makefile.am b/Makefile.am
>> index ee84b75..21a602d 100644
>> --- a/Makefile.am
>> +++ b/Makefile.am
>> @@ -31,7 +31,7 @@ endif
>> if MOZJS
>> js_sources = src/js_funcs.c
>> builtin_modules += mozjs
>> -builtin_sources += plugins/mozjs.c
>> +builtin_sources += plugins/mozjs.cpp
>
> please do the same as what we did for v8. We want to build .a first so that
> linking doesn't happen with CXX.
Ok, let me take a look at that..
Thanks,
------------------------------
Message: 4
Date: Thu, 25 Aug 2016 22:28:59 +0000
From: Thomas Green <[email protected]>
To: "[email protected]" <[email protected]>
Subject: Not sure how to fix this bug
Message-ID:
<c2bc44d770753c45aaac42695fb5be0201255aa...@slc-exmb01.corp.srelay.com>
Content-Type: text/plain; charset="us-ascii"
In connman 1.33 I have come up with an interesting scenario, and am not sure
how to fix it. The easiest way to duplicate it is to plug my wired connection
into a switch that is turned on, but does -not- have the uplink cable plugged
in. After the DHCP request fails, there is some (random?) address assigned
(169.254.x.x). At that point the uplink cable on the switch is plugged in.
When a DHCP solicitation is sent again, and an answer is received, connman gets
the information, but does not send the new nameserver information. Attached is
a copy of the debug log I have, and at about line 149 you see where the
nameservers are saved. But after that, they are all used internally, but my
application does not get a PropertyChanged signal indicating the change.
It seems to me it would be a quick fix but I'm not sure where is the best place
to do it.
Thank you for your help
Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.01.org/pipermail/connman/attachments/20160825/f1fc394a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: connmand_debug.log
Type: application/octet-stream
Size: 19259 bytes
Desc: connmand_debug.log
URL:
<http://lists.01.org/pipermail/connman/attachments/20160825/f1fc394a/attachment.obj>
------------------------------
Subject: Digest Footer
_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman
------------------------------
End of connman Digest, Vol 10, Issue 32
***************************************