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 v3] Port pacrunner to mozjs24 (Jeremy Linton)
   2. [PATCH v3] Pull pacrunner forward to mozjs24 (Jeremy Linton)
   3. Re: [PATCH v3] Pull pacrunner forward to mozjs24
      (Tomasz Bursztyka)
   4. Re: Connman spinning (Frederic Dalleau)
   5. [PATCH] Bluetooth: change state before disconnecting
      (Fr?d?ric Dalleau)
   6. [PATCH] wifi: Clean up connected flag after disconnecting
      (Jose Blanquicet)


----------------------------------------------------------------------

Message: 1
Date: Mon, 12 Sep 2016 16:58:41 -0500
From: Jeremy Linton <[email protected]>
To: [email protected]
Subject: [PATCH v3] Port pacrunner to mozjs24
Message-ID: <[email protected]>

This patch moves pacrunner to mozjs24. This is still
a little behind the times, but gnome/etc are using mozjs24
so the distro's are on the hook for supporting it.

v2->v3 Change mozjs plugin to .cc rather than .cpp, also suppress mozjs
   offsetof warning, and remove redundant comment I added in the makefile in
   v2.

v1->v2 Change automake script so that --disable-mozjs doesn't require
 pacrunner to depend on the C++ support libraries.

Jeremy Linton (1):
  Pull pacrunner forward to mozjs24

 Makefile.am                   | 15 ++++++++-------
 configure.ac                  |  4 ++--
 plugins/{mozjs.c => mozjs.cc} | 38 +++++++++++++++++++++-----------------
 3 files changed, 31 insertions(+), 26 deletions(-)
 rename plugins/{mozjs.c => mozjs.cc} (81%)

-- 
2.9.2



------------------------------

Message: 2
Date: Mon, 12 Sep 2016 16:58:42 -0500
From: Jeremy Linton <[email protected]>
To: [email protected]
Subject: [PATCH v3] 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                   | 15 ++++++++-------
 configure.ac                  |  4 ++--
 plugins/{mozjs.c => mozjs.cc} | 38 +++++++++++++++++++++-----------------
 3 files changed, 31 insertions(+), 26 deletions(-)
 rename plugins/{mozjs.c => mozjs.cc} (81%)

diff --git a/Makefile.am b/Makefile.am
index ee84b75..65cc8c9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -31,9 +31,10 @@ endif
 if MOZJS
 js_sources = src/js_funcs.c
 builtin_modules += mozjs
-builtin_sources += plugins/mozjs.c
-builtin_cflags += @MOZJS_CFLAGS@
-builtin_libadd += @MOZJS_LIBS@
+builtin_libadd += plugins/libmozjsplugin.a @MOZJS_LIBS@ -lstdc++
+noinst_LIBRARIES += plugins/libmozjsplugin.a
+plugins_libmozjsplugin_a_SOURCES = plugins/mozjs.cc
+plugins_libmozjsplugin_a_CXXFLAGS = $(AM_CFLAGS) @MOZJS_CFLAGS@ @DBUS_CFLAGS@ 
@GLIB_CFLAGS@
 endif
 
 if V8
@@ -137,16 +138,16 @@ unit_test_pacrunner_LDADD += @CURL_LIBS@
 endif
 
 if MOZJS
-unit_test_pacrunner_SOURCES += plugins/mozjs.c
-
+unit_test_pacrunner_SOURCES += plugins/mozjs.cc
+unit_test_pacrunner_CXXFLAGS = $(AM_CFLAGS)  @MOZJS_CFLAGS@
 unit_test_pacrunner_LDADD += @MOZJS_LIBS@ @PTHREAD_LIBS@
 
 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.cc $(js_sources)
+unit_test_mozjs_CXXFLAGS = $(AM_CFLAGS)  @MOZJS_CFLAGS@
 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.cc
similarity index 81%
rename from plugins/mozjs.c
rename to plugins/mozjs.cc
index a923203..8c7a7ce 100644
--- a/plugins/mozjs.c
+++ b/plugins/mozjs.cc
@@ -31,11 +31,15 @@
 #include <netdb.h>
 
 #pragma GCC diagnostic ignored "-Wredundant-decls"
+#pragma GCC diagnostic ignored "-Winvalid-offsetof"
 #include <jsapi.h>
 #pragma GCC diagnostic error "-Wredundant-decls"
+#pragma GCC diagnostic error "-Winvalid-offsetof"
 
+extern "C" {
 #include "pacrunner.h"
 #include "js.h"
+}
 
 static pthread_mutex_t mozjs_mutex = PTHREAD_MUTEX_INITIALIZER;
 
@@ -43,11 +47,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 +73,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 +102,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 +120,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 +131,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 +155,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 +184,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 +233,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: 3
Date: Tue, 13 Sep 2016 08:55:29 +0200
From: Tomasz Bursztyka <[email protected]>
To: [email protected]
Subject: Re: [PATCH v3] Pull pacrunner forward to mozjs24
Message-ID: <[email protected]>
Content-Type: text/plain; charset=windows-1252; format=flowed

Hi Jeremy,

>   
>   static pthread_mutex_t mozjs_mutex = PTHREAD_MUTEX_INITIALIZER;
>   
> @@ -43,11 +47,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);

Ok looks like cpp needs you to cast but then:

>       char address[NI_MAXHOST];
>   
>       DBG("");
> @@ -68,9 +73,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);

Make sure you don't override 80 chars limit. (break a line a after '=')

>   
>       ctx->proxy = proxy;
>       ctx->jsctx = JS_NewContext(jsrun, 8 * 1024);
> @@ -126,12 +131,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 +155,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);

same

>   
>       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 +184,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);

same

Tomasz



------------------------------

Message: 4
Date: Tue, 13 Sep 2016 11:50:28 +0200
From: Frederic Dalleau <[email protected]>
To: [email protected]
Subject: Re: Connman spinning
Message-ID: <[email protected]>
Content-Type: text/plain; charset=windows-1252; format=flowed

Hi Patrik,

I have narrowed the problem now:
It happens every time the pan connection fails.
To reproduce it it as simple as "start connman, make a failing bluetooth 
connection".

The connection can fail if the target device is too far away. It also 
occurs if a bluetooth connection is triggered within half a second after 
a disconnect. That one being more like a bluetooth issue.

In both cases connman spins. I'll send a patch that "works for me", let 
me know what you think.

Regards,
Fred

On 08/09/2016 15:15, Frederic Dalleau wrote:
> Hi Patrik
> connmand says 1.32
> Regards
> Fred
>
>
> On 08/09/2016 14:07, Patrik Flykt wrote:
>> On Thu, 2016-09-08 at 13:43 +0200, Frederic Dalleau wrote:
>>> Hello,
>>>
>>> I am using connman to setup some bluetooth pan connections.
>>> Sometimes things don't do well, it can be disconnected, or the
>>> connection may not be setup, or setup and immediately disconnected.
>>> I ran several times into the problem that connmand starts to spin as
>>> follow :
>>>
>>> plugins/bluetooth.c:bluetooth_pan_disconnect() network 0xfb8510
>>> plugins/bluetooth.c:pan_disconnect_cb() network 0xfb8510
>>> org.bluez.Error.NotConnected
>>> plugins/bluetooth.c:pan_disconnect_cb() network 0xfb8510
>>> src/network.c:connman_network_set_connected() network 0xfb8510
>>> connected
>>> 0/0 connecting 0 associating 1
>>> src/network.c:connman_network_set_error() network 0xfb8510 error 4
>>> src/service.c:__connman_service_indicate_error() service 0xfb88e0
>>> error 4
>>> src/network.c:__connman_network_disconnect() network 0xfb8510
>>> plugins/bluetooth.c:bluetooth_pan_disconnect() network 0xfb8510
>>> plugins/bluetooth.c:pan_disconnect_cb() network 0xfb8510
>>> org.bluez.Error.NotConnected
>>> plugins/bluetooth.c:pan_disconnect_cb() network 0xfb8510
>>> src/network.c:connman_network_set_connected() network 0xfb8510
>>> connected
>>> 0/0 connecting 0 associating 1
>>> src/network.c:connman_network_set_error() network 0xfb8510 error 4
>>> src/service.c:__connman_service_indicate_error() service 0xfb88e0
>>> error 4
>>> src/network.c:__connman_network_disconnect() network 0xfb8510
>>> plugins/bluetooth.c:bluetooth_pan_disconnect() network 0xfb8510
>>> plugins/bluetooth.c:pan_disconnect_cb() network 0xfb8510
>>> org.bluez.Error.NotConnected
>>>
>>> And so on, and so forth...  Has anyone seen that? or better, does
>>> somebody already have the patch :) in which case i'd be happy to
>>> test, or just a hint about what fix should be needed.
>>
>> Haven't see this one before. I assume you are using a recent version of
>> ConnMan?
>>
>> Cheers,
>>
>>     Patrik
>>
> _______________________________________________
> connman mailing list
> [email protected]
> https://lists.01.org/mailman/listinfo/connman


------------------------------

Message: 5
Date: Tue, 13 Sep 2016 11:51:59 +0200
From: Fr?d?ric Dalleau  <[email protected]>
To: [email protected]
Subject: [PATCH] Bluetooth: change state before disconnecting
Message-ID:
        <1473760319-26752-1-git-send-email-frederic.dall...@collabora.co.uk>
Content-Type: text/plain; charset=UTF-8

When bluetooth pan connection fails, connman starts spinning.
This can happen when trying to connect to a device out of
reached, or when trying to reconnect, just after disconnect.

Signed-off-by: Fr?d?ric Dalleau <[email protected]>
---
 plugins/bluetooth.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 181df27..401bb30 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -218,6 +218,7 @@ static void pan_connect_cb(DBusMessage *message, void 
*user_data)
 
                if (strcmp(dbus_error,
                                "org.bluez.Error.AlreadyConnected") != 0) {
+                       connman_network_set_associating(pan->network, false);
                        connman_network_set_error(pan->network,
                                CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL);
                        return;
-- 
2.7.4



------------------------------

Message: 6
Date: Tue, 13 Sep 2016 16:30:52 +0200
From: Jose Blanquicet <[email protected]>
To: [email protected]
Subject: [PATCH] wifi: Clean up connected flag after disconnecting
Message-ID: <[email protected]>

After disconnecting, wifi->connected value is not coherent with the
actual interface state and it does not allow to start auto-scan. In 
addition, this patch will also help future patches to make decisions
based on this flag.


NOTE: After checking the use of this flag I did not see any place where
this modification could create regressions or problems with roaming in
interface_state(), there is something I am missing?  

---
 plugins/wifi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index 9d56671..206bf48 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -2145,6 +2145,7 @@ static void disconnect_callback(int result, 
GSupplicantInterface *interface,
        }
 
        wifi->disconnecting = false;
+       wifi->connected = false;
 
        if (wifi->pending_network) {
                network_connect(wifi->pending_network);
-- 
1.9.1



------------------------------

Subject: Digest Footer

_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman


------------------------------

End of connman Digest, Vol 11, Issue 15
***************************************

Reply via email to