src/app-framework-binder.git
4 years agoFix globset compilation warning 48/23648/3 8.99.5 icefish/8.99.5 icefish_8.99.5
José Bollo [Thu, 23 Jan 2020 17:09:51 +0000 (18:09 +0100)]
Fix globset compilation warning

The case of returning NULL is not tested in `globset_add`.
It is safe because `grow` is called first and then `search`
never returns a NULL pointer.

Bug-AGL: SPEC-3134

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: I21e8ba3a6c8202a920c6784f4d61376450b9a063

4 years agoUpdate copyright dates 59/23559/2
José Bollo [Wed, 8 Jan 2020 11:14:52 +0000 (12:14 +0100)]
Update copyright dates

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: I01a566a693b8ec6239209c9323ae4ff15a07f737

4 years agoafb-ws-client: Improve direct URI 53/23553/1
Jose Bollo [Tue, 7 Jan 2020 09:28:27 +0000 (10:28 +0100)]
afb-ws-client: Improve direct URI

The direct connection URI was expecting a slash after the port
for "tcp:" URI.  This slash is not needed because it does not
carry any meaning. This change implements the ability to set
or not the path of URI.

Bug-AGL: SPEC-3094

Change-Id: I3d4c350f4e917759cbf82ccc0d261aa420f6f88a
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoafb-evt: Ensure unsubscribe works 38/23538/1
Jose Bollo [Wed, 18 Dec 2019 17:26:00 +0000 (18:26 +0100)]
afb-evt: Ensure unsubscribe works

Fix the logic of unsubscribing to events. It
was not possible before to implment it without
tracking every session and context. It was not
done because of the required complexity.

This implementation ensures that unexpected
events lead to a removal of the listener from the
list of watchers of the events.

The management of the list of watchers is reworked
to free unused memory.

Bug-AGL: SPEC-3069

Change-Id: Ie67372adbde9dcb9dc6c5c2738111d22609e7256
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoafb-evt: Improve name of listening functions 37/23537/1
José Bollo [Wed, 18 Dec 2019 09:42:15 +0000 (10:42 +0100)]
afb-evt: Improve name of listening functions

Some more improvement on the road of the following bug:

Bug-AGL: SPEC-3069

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: I5ad6439fa6051566ab2caf271345eda1efcef398

4 years agoafb-proto-ws: Add message for unexpected event 36/23536/1
Jose Bollo [Tue, 17 Dec 2019 07:22:00 +0000 (08:22 +0100)]
afb-proto-ws: Add message for unexpected event

This new message allows to revoke an event no more
expected or listened.

Bug-AGL: SPEC-3069

Change-Id: I71945e322276f29b01b628bdf43d75599b521fc3
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoafb-proto-ws: Improve comment and names 35/23535/1
Jose Bollo [Tue, 17 Dec 2019 07:21:19 +0000 (08:21 +0100)]
afb-proto-ws: Improve comment and names

Some more comment and naming improvement on the road
of the following bug:

Bug-AGL: SPEC-3069

Change-Id: I001ccfba2ea59604d217feb6afe3e5a313f3fbaf
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoAFB.js: pass event name 34/23534/1
José Bollo [Thu, 19 Dec 2019 13:30:58 +0000 (14:30 +0100)]
AFB.js: pass event name

The event name is given at second position,
preserving existing code and making its
use optionnal.

Bug-AGL: SPEC-3069

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: Ieeed1762977b990c139d56c4d78e2b539d6927c6

4 years agoafb-apiset: Fix start of apis 33/23533/1
Jose Bollo [Fri, 3 Jan 2020 15:50:29 +0000 (16:50 +0100)]
afb-apiset: Fix start of apis

When using dynamically created/destroyed API, the binder
might miss to start some apis. This fixes that issue by
enforcing to restart from beginning until all is initialised.

Bug-AGL: SPEC-3087

Change-Id: I4dd8c60c8465419a46132bf9f6deffa11e172e2a
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agomain-afb-client-demo: Fix typo 69/23469/1
Jose Bollo [Mon, 23 Dec 2019 16:05:19 +0000 (17:05 +0100)]
main-afb-client-demo: Fix typo

New line markers were missing.

Bug-AGL: SPEC-3066

Change-Id: I4f1cf990edfb7772480ba658b6eda94bdd7e0289
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoafb-token: Fix a critical bug 41/23441/1 8.99.4 icefish/8.99.4 icefish_8.99.4
Jose Bollo [Fri, 20 Dec 2019 13:55:28 +0000 (14:55 +0100)]
afb-token: Fix a critical bug

Management of tokens had a big bug, due to insufficent testing.
This fixes the issue that leaded to memory crashes.

BUG-AGL: SPEC-3066

Change-Id: If967ec58ed04dc715d255a5e7c2196133ce3ec4a
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoafb-daemon: Fix optionnal port 38/23338/1
José Bollo [Thu, 12 Dec 2019 13:37:52 +0000 (14:37 +0100)]
afb-daemon: Fix optionnal port

Since:
 - introduction of interface to set the
   listening port(s) and address(es)
 - use of nss-localuser for discriminating
   binders

there is no more strict need for exporting
the port and substituting it. So the
substitution is make only if needed.

Since removal of token generation, there is no
more need to propoagate any token.

The two possibilities are kept for being used
whene needed and to ensure sweet transition.

Bug-AGL: SPEC-2968

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: I1d2b4d765f244e46de3071baddd8b3d0817b9436

4 years agomain-afb-daemon: manage listening interfaces 69/23169/1 8.99.2 8.99.3 icefish/8.99.2 icefish/8.99.3 icefish_8.99.2 icefish_8.99.3
Jose Bollo [Mon, 2 Dec 2019 23:12:31 +0000 (00:12 +0100)]
main-afb-daemon: manage listening interfaces

This change allows to specify interfaces to serve
explicitely.

By default the option --port=PORT lead to serving
interface of specification "tcp:*:PORT". Meaning
that all interfaces are listened.

This is intended to be used with localuser family
of hostnames.

Bug-AGL: SPEC-2968

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: I3fb2a77a5c03dd4c2118ebe3267794f79bfc0262

4 years agoafb-socket: Add ability to set a default scheme 68/23168/1
Jose Bollo [Tue, 3 Dec 2019 14:19:31 +0000 (15:19 +0100)]
afb-socket: Add ability to set a default scheme

This is a basic improvement for allowing simple
option setting when uri are to be written.
It allows to set contextually the default scheme.

Bug-AGL: SPEC-2968

Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Change-Id: I9d7be96743c47b3dd788a35b0b3642387613bacb

4 years agoRelax constraint on aliases 67/23167/1
Jose Bollo [Mon, 2 Dec 2019 19:40:50 +0000 (20:40 +0100)]
Relax constraint on aliases

Without relaxing constraint, it is impossible to alias
2 directory contents for the same prefix. Relaxing it
is needed for implementing ".well-known" interface.

Bug-AGL: SPEC-2968

Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Change-Id: I339699bbe66ed3df74ed4ac92344646339e5f2ad

4 years agoAFB.js: Enforce single code 66/23166/1
José Bollo [Tue, 3 Dec 2019 14:22:19 +0000 (15:22 +0100)]
AFB.js: Enforce single code

AFB.js was present with 2 different versions.
This make it unique.

Bug-AGL: SPEC-2968

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: Iee7a5a08fa1457d572000e42da4147c9fa5944b8

4 years agoafb-perm: separate access to permission db 65/23165/1
José Bollo [Fri, 29 Nov 2019 17:41:59 +0000 (18:41 +0100)]
afb-perm: separate access to permission db

Access to permission database is better handled
in a separate file. It will afterward evolve to
integrate cynagora.

Bug-AGL: SPEC-2968

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: Iebcd4e227e3e6c318029926499afb9d41d3f72c7

4 years agoafb-supervision: Improve messages 64/23164/1
José Bollo [Mon, 2 Dec 2019 09:15:24 +0000 (10:15 +0100)]
afb-supervision: Improve messages

The messages prompted when the supervisor is
absent were of to high priority.

Bug-AGL: SPEC-2968

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: Ic53a3039c2d3ed5be0138ec3215d58e27758a79c

4 years agoafb-context & afb-token: rework token validation 63/23163/1
José Bollo [Fri, 29 Nov 2019 11:44:46 +0000 (12:44 +0100)]
afb-context & afb-token: rework token validation

Validation of token is now linked to backend permission
database.

Bug-AGL: SPEC-2968

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: I30b049f92b8324740abecbb9539f7413ad55f7ec

4 years agoafb-context: Move credentials to context 62/23162/1
José Bollo [Fri, 29 Nov 2019 10:12:31 +0000 (11:12 +0100)]
afb-context: Move credentials to context

The split between context and credentials
in requests was somehow artificial and awkward.

This change move the credentials to the context
and removes as many references to credentials
as possible in favor of working on contexts.

Change the value returned by afb_auth_check to be 1
if validated, 0 or less than zero if not validated.

Bug-AGL: SPEC-2968

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: I979dc841e03247e126e3fa8433a1cc0d4108adf0

4 years agoafb-hswitch: Update websocket policy 61/23161/1
Jose Bollo [Sat, 16 Nov 2019 08:30:51 +0000 (09:30 +0100)]
afb-hswitch: Update websocket policy

The previous policy for websocket was to enforce them
to present a valid token when establishing. This policy
is removed because the Websocket API of javascript doesn't
provide a way to set the Bearer token in the HTTP header
of the negociation (a big miss in my opinion).

But because the new policy of token logic is to check
the token at each request, it is not more needed to check
it at establishment.

Bug-AGL: SPEC-2968

Change-Id: I2941757492a27a2eed14e26fbb411330ab4aa8bc
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoafb-auth: Increase and improve use of afb-auth 60/23160/1
Jose Bollo [Wed, 27 Nov 2019 15:58:55 +0000 (16:58 +0100)]
afb-auth: Increase and improve use of afb-auth

This change factorize code for version V1 of bindings
and centralizes management of authorisations in a
single place.

Bug-AGL: SPEC-2968

Change-Id: I6ad95d5bfa0d85dbb6d2060fc9ebca08b68eb4e9
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoafb-error-text: Introduce standard error text 59/23159/1
Jose Bollo [Wed, 27 Nov 2019 11:20:38 +0000 (12:20 +0100)]
afb-error-text: Introduce standard error text

The standard error text are used to return standard
HTTP error codes.

Bug-AGL: SPEC-2968

Change-Id: Ic70e7982b1e05a1830cfa4e54813227621192ae2
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoafb-proto-ws: Change the protocol WSAPI 58/23158/1
Jose Bollo [Fri, 15 Nov 2019 13:41:40 +0000 (14:41 +0100)]
afb-proto-ws: Change the protocol WSAPI

Change internals of the protocol WSAPI for the following
rationale:

 1. Enforce specific declaration and transmission of session
    identifiers and of access tokens.
 2. Lower the size of identifiers to be 16 bits.
 3. Introduce protocol versionning through a mechanism of offer/set.

The main purpose of that change is to optimize the count of data
transmitted. It manages as best as possible the transmission of
access tokens the less possible times. Same for sessions that
the chage was transmitted at each call.

Bug-AGL: SPEC-2968

Change-Id: If0a22b86627ead35a410e51c1028025c5b02c38f
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoafb-stub-ws: Enforce asynchronous describe 57/23157/1
Jose Bollo [Mon, 4 Nov 2019 16:57:23 +0000 (17:57 +0100)]
afb-stub-ws: Enforce asynchronous describe

Because remote apis describe themselves asynchronousely,
it is better to have asynchronous describe api.

Bug-AGL: SPEC-2968

Change-Id: I52b4dab697f229ad01ea2b73d6b8dee22d507912
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoafb-evt: Use 16 bits for ids 56/23156/1
Jose Bollo [Wed, 20 Nov 2019 11:03:08 +0000 (12:03 +0100)]
afb-evt: Use 16 bits for ids

16 bits are enough

Bug-AGL: SPEC-2968

Change-Id: I0e8708c1d6a3934a342721a6ce5edb4676df6d1b
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agou16id: Add maps for identifiers id of 16 bits 55/23155/1
Jose Bollo [Tue, 19 Nov 2019 12:43:06 +0000 (13:43 +0100)]
u16id: Add maps for identifiers id of 16 bits

These maps will shortly be used by protocol to handle
tokens/sessions/events.

Bug-AGL: SPEC-2968

Change-Id: Iadef7d6e01c8ef021516749524b10ccc1abec340
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoafb-session: remove initial token 54/23154/1
Jose Bollo [Mon, 18 Nov 2019 16:10:53 +0000 (17:10 +0100)]
afb-session: remove initial token

Tokens are no more managed by the binder.

Bug-AGL: SPEC-2968

Change-Id: Idf1c38105f8ede82cd0ed43aeae3e8e69b9845a3
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoafb-session: Expose a local id for sessions 53/23153/1
Jose Bollo [Fri, 15 Nov 2019 13:39:04 +0000 (14:39 +0100)]
afb-session: Expose a local id for sessions

Also, improve readability and memory footprint

Bug-AGL: SPEC-2968

Change-Id: I90104fb19a44e2810b92bef51d774acf734fd90f
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoUse afb_token in contexts 52/23152/1
Jose Bollo [Fri, 15 Nov 2019 15:40:34 +0000 (16:40 +0100)]
Use afb_token in contexts

Tokens are now object used in the context.

Bug-AGL: SPEC-2968

Change-Id: I107d31732202b7b1172afaf09f3a52470f050d7c
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoMove tokens from sessions to requests 51/23151/1
Jose Bollo [Fri, 15 Nov 2019 15:21:03 +0000 (16:21 +0100)]
Move tokens from sessions to requests

Tokens are no more related to sessions.

Each request provides a token. In the case of websockets or
connected link, the context can record the token.

Bug-AGL: SPEC-2968

Change-Id: I1442b0422584c5a5b860ddb826518b0e673612f9
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoDon't return the uuid 50/23150/1
Jose Bollo [Fri, 15 Nov 2019 15:01:27 +0000 (16:01 +0100)]
Don't return the uuid

uuid is available in cookies and through
a call to monitor/session

Bug-AGL: SPEC-2968

Change-Id: I72912f3dc7985cca09e77c952e416b608711abbe
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoRemove returning token 49/23149/1
Jose Bollo [Sat, 16 Nov 2019 08:25:02 +0000 (09:25 +0100)]
Remove returning token

The token is no more generated by the binder

Bug-AGL: SPEC-2968

Change-Id: I43f66c7613b42d33058e167b831a93b2112d3b9e
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoRemove refreshing token 48/23148/1
Jose Bollo [Fri, 15 Nov 2019 14:33:26 +0000 (15:33 +0100)]
Remove refreshing token

The token is no more generated by the binder
but by some external component.

Bug-AGL: SPEC-2968

Change-Id: I2c6221034272ab097e21e7727e4840b6b47bd0dc
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoafb-hreq: Handle access_token query parameter 47/23147/1
José Bollo [Thu, 21 Nov 2019 14:31:32 +0000 (15:31 +0100)]
afb-hreq: Handle access_token query parameter

As specified by OAuth2 protocols, the access token can be
passed as a POST/GET parameter of name 'access_token'.

Bug-AGL: SPEC-2968

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: I0e02e6fd0d53dad6de994d4482350fe42ecfce48

4 years agomonitoring: Fix display on connection error 88/22988/1
Jose Bollo [Tue, 12 Nov 2019 08:52:35 +0000 (09:52 +0100)]
monitoring: Fix display on connection error

When the connection can't occur, the output is not correct.

Bug-AGL: SPEC-2975

Change-Id: I9cc185329ddccb00f2544dd7b17841b108cc2c81
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agocoverage: Fix regression 87/22987/1
Jose Bollo [Thu, 7 Nov 2019 09:41:20 +0000 (10:41 +0100)]
coverage: Fix regression

The coverage test was broken. This restores it.

Also add a simple build script that covers most
of the code by default.

Bug-AGL: SPEC-2974

Change-Id: I4fc5a0ba54195738405460a04f985bb67b81b5df
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoIntroduce object for tokens 67/22967/2 8.99.1 icefish/8.99.1 icefish_8.99.1
Jose Bollo [Mon, 28 Oct 2019 17:02:36 +0000 (18:02 +0100)]
Introduce object for tokens

For further optimizations, the token is represented
by a specific structure.

Bug-AGL: SPEC-2968

Change-Id: I3d46a12c8c16809c6cc1d543fa2e6309927ed84d
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoafb-hreq: Handle HTTP header Authorization 66/22966/2
Jose Bollo [Wed, 23 Oct 2019 12:08:12 +0000 (14:08 +0200)]
afb-hreq: Handle HTTP header Authorization

Allows the client to pass its authorization
token using the standard RFC 6750 method.

Bug-AGL: SPEC-2968

Change-Id: Ie9428f4b63554af121b091282ae2c126b4d0c020
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoafb-proto-ws: Fix crash on event to disconnected 65/22965/2
Jose Bollo [Thu, 7 Nov 2019 09:38:49 +0000 (10:38 +0100)]
afb-proto-ws: Fix crash on event to disconnected

There was a race condition that made the binder
crashing when reporting event to a client that was
disconnecting.

Bug-AGL: SPEC-2967

Change-Id: I37a654960b42fbce5548ace9d3fb50cf2b375090
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoafb-api-dbus: Fix broken broadcast in dbus apis 64/22964/2
Jose Bollo [Wed, 13 Nov 2019 16:05:06 +0000 (17:05 +0100)]
afb-api-dbus: Fix broken broadcast in dbus apis

Probably because of conditional compiling,
afb-api-dbus was broken since introduction
of uuid and hops in broadcats. This change
fixes this issue.

Bug-AGL: SPEC-2969

Change-Id: I9a0fd8552f5f61d6eafa1ed83f6e09e6474378ff
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agodocs(func-service.md): typo 73/22973/1
Li Xiaoming [Tue, 19 Nov 2019 02:25:04 +0000 (10:25 +0800)]
docs(func-service.md): typo

Bug-AGL: SPEC-2714

Change-Id: I913a836d8b762771d4a966870569b48e4c06804c
Signed-off-by: Li Xiaoming <lixm.fnst@cn.fujitsu.com>
4 years agojobs: Fix callsync hanging 67/22867/2
Jose Bollo [Wed, 6 Nov 2019 10:12:16 +0000 (11:12 +0100)]
jobs: Fix callsync hanging

The function implementing jobs_enter, used by
implementations of synchronous calls, was not
taking care of waking up a thread. This had the
effect of blocking calls made by an external thread.

Bug-AGL: SPEC-2937

Change-Id: I4bf0265b4c029fb619ef7128824ee9d46a45996e
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agosig-monitor: Fix exit in signal handler 99/22699/1
José Bollo [Thu, 17 Oct 2019 09:12:59 +0000 (11:12 +0200)]
sig-monitor: Fix exit in signal handler

Calling exit in signal interrupts wasn't correctly handling
the case where the signal interrupts a thread waiting in the
main loop. This can lead to the binder error report:

    CRITICAL: Can't enter dispatch while in dispatch!

This patch defers the call to exit in a job.

Bug-AGL: SPEC-2907

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: I49c7cca1d229ae957d9ea9bfb8838161ce73a53e

4 years agoImprove detection of the bindings 46/22546/1
José Bollo [Tue, 1 Oct 2019 09:10:28 +0000 (11:10 +0200)]
Improve detection of the bindings

The symbol 'afbBindingV3root' may be defined
in shared libraries that are not bindings.
Using it to detect bindings v3 can lead to
false detection and errors.

Bug-AGL: SPEC-2841

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: Ib2bc77d95e3306e7b4a883136ce27c92f8524a8d

4 years agoRevert "Make source files relative" 19/22419/1
José Bollo [Fri, 13 Sep 2019 11:32:43 +0000 (13:32 +0200)]
Revert "Make source files relative"

This reverts commit 45a4e69d4ef15c70d2b74ea4d0d2e4cd22e3adea.

Revert looks good because the issue has to be adressed by
the build environment.

Bug-AGL: SPEC-2801

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: Id2f1f3890b5965e0a28f189834c758be5bd08d55

4 years agojobs: Wake up an event loop if needed 17/22417/1
José Bollo [Fri, 13 Sep 2019 09:01:42 +0000 (11:01 +0200)]
jobs: Wake up an event loop if needed

A queued job must be treated. It was not the case
when the job was queued from a foreign thread.
This change detect that a potential hang exists
and wake up an event loop to avoid it.

Bug-AGL: SPEC-2809

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: Id12d32771ea37df5f5f2e208ec9645a6c4b0d0ab

4 years agoMake source files relative 76/22376/1
José Bollo [Tue, 10 Sep 2019 15:20:15 +0000 (17:20 +0200)]
Make source files relative

It is intended to enhance reproducibility
of produced binaries as unmeaning prefixes
are removed.

Bug-AGL: SPEC-2801

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: I6a7ee9fa2ce4a744f7a5ef8a3c9886cd6a9f15e9

4 years agoFix binding example path & update afb-daemon options 98/22198/5
Li Xiaoming [Fri, 23 Aug 2019 08:57:42 +0000 (16:57 +0800)]
Fix binding example path & update afb-daemon options

Bug-AGL: SPEC-2714

Change-Id: I78aee6b3d96728a7eb394ddd94000c516fbc63ba
Signed-off-by: Li Xiaoming <lixm.fnst@cn.fujitsu.com>
4 years agoFix client disconnection close 81/22181/1
José Bollo [Tue, 20 Aug 2019 10:32:02 +0000 (12:32 +0200)]
Fix client disconnection close

Before that change, the client disconection made a loop
on read but wasn't closing the link.

Bug-AGL: SPEC-2759

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: Iecfbb95cb1b7079e695ff5c08155b2310bf4b8d8

4 years agojobs: Add starting mode for jobs 69/22169/2
Jose Bollo [Wed, 20 Feb 2019 09:07:21 +0000 (10:07 +0100)]
jobs: Add starting mode for jobs

Also improve naming of variables.

Bug-AGL: SPEC-2720

Change-Id: I8efa74e27256425df18f57b3de257c234ff60e69
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoReplace obsolete argument "sessiondir" with "workdir" 76/22176/2
Li Xiaoming [Mon, 19 Aug 2019 09:59:20 +0000 (17:59 +0800)]
Replace obsolete argument "sessiondir" with "workdir"

afb-daemon can not recognize arg "sessiondir" now, it will report
"Error: Bad option detected".Use "workdir" instead.

Bug-AGL: SPEC-2714

Change-Id: I0a194efa7a37ce3e6624c44e48d3e98dcfdda4c2
Signed-off-by: Li Xiaoming <lixm.fnst@cn.fujitsu.com>
4 years agoAvoid lock when child dies 78/22078/2
Jose Bollo [Fri, 2 Aug 2019 14:23:50 +0000 (16:23 +0200)]
Avoid lock when child dies

Interaction between pthread_cond_wait, pthread_broadcast
and signal may lead to lock when the child of afb-daemon dies.

To avoid that sad behavior, this commit defers the call to
"job_exit" using lazy job queueing.

Bug-AGL: SPEC-2720

Change-Id: Ifd1a56f4a439e1704f79a1291fa01f39b1640f29
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoFix outdated documents 76/22076/1
Li Xiaoming [Fri, 2 Aug 2019 04:21:32 +0000 (12:21 +0800)]
Fix outdated documents

Bug-AGL: SPEC-2714

Change-Id: I198f93184a0389f017c9da5b64e800b6faec8cac
Signed-off-by: Li Xiaoming <lixm.fnst@cn.fujitsu.com>
4 years agoFix detection of error in call synchronous 03/22003/1
Jose Bollo [Mon, 29 Jul 2019 09:48:00 +0000 (11:48 +0200)]
Fix detection of error in call synchronous

There fixes a bug with an inversion between info
and error in implementation of synchronous calls,
leading to bad detection of errors.

Bug-AGL: SPEC-2697

Change-Id: I30a8cd9c45a91b442f6c501dd3b0c32cd3ea632d
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agosupervisor: Setup services for local API use 38/21938/1
José Bollo [Tue, 9 Jul 2019 15:56:55 +0000 (17:56 +0200)]
supervisor: Setup services for local API use

The supervisor only allowed external accesses.
This was wrong, it must also allow local access
through standard API. This commit fix it.

Bug-AGL: SPEC-2660

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: Ifa1119a6b2f22c87b1dbe087206d9f51c4005a57

4 years agoAFB.js: Improve default token discovery 37/21937/1
José Bollo [Tue, 9 Jul 2019 15:27:03 +0000 (17:27 +0200)]
AFB.js: Improve default token discovery

The example script AFB.js should look int the URLs
of the page if the token is set or not and then use it.

Bug-AGL: SPEC-2661

Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Change-Id: I4adba8eac214130b425b6cd3c56fc1dc63543011

4 years agoafb-binding.h: Ensure json-c/json.h is sourced 36/21936/1
Jose Bollo [Mon, 22 Jul 2019 15:02:09 +0000 (17:02 +0200)]
afb-binding.h: Ensure json-c/json.h is sourced

This is needed if we want to replace json-c with jsonfast.

Bug-AGL: SPEC-2659

Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Change-Id: I32da71bd05bfe3538596cbf751d55ff45b4fe7f9

4 years agoafb-xreq: Remove field 'listener' 35/21935/1
Jose Bollo [Wed, 27 Mar 2019 16:16:06 +0000 (17:16 +0100)]
afb-xreq: Remove field 'listener'

This simplifies the flow that now has only one
case: the callbacks subscribe/unsubscribe of
struct afb_xreq_query_itf.

Bug-AGL: SPEC-2658

Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Change-Id: Ia49f3ce7aaa4d8603014fe163f311eadfcbf68e4

4 years agoFix bad memory access at client disconnection 02/21902/1
José Bollo [Tue, 9 Jul 2019 22:06:36 +0000 (00:06 +0200)]
Fix bad memory access at client disconnection

The management of structures handling a client
connection to a exported --ws-server was accessing
freed memory. Tha commit fixes that issue.

Bug-AGL: SPEC-2651

Change-Id: I511218afc907308347bc422a8aead32ca00bdae6
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoTag broadcasted events with UUID and hop 00/21900/2
José Bollo [Tue, 16 Jul 2019 21:39:27 +0000 (23:39 +0200)]
Tag broadcasted events with UUID and hop

When API have mutual dependencies, leading to
loops in dependecies, broadcasting an event
never ends because of the loop (see SPEC-2625).

To avoid that weird flood of events, a unic
identifier (UUID) is attached to broadcasted
event and a tiny memory records previously
broadcasted events to avoid re-sending an
already sent event.

The size of the memory can be set using the
macro variable EVENT_BROADCAST_MEMORY_COUNT
whose default value is 8. It can be reduced
to 0.

An other mecanism is added to limit the count
of hops that a broadcasted event can do. That
count can be set using the macro variable
EVENT_BROADCAST_HOP_MAX whose default value
is 10.

Bug-AGL: SPEC-2625

Change-Id: I29550a8a5c8f5e2ffb20edc3330357a1e870c0e2
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
4 years agoafb-evt: Refactor processing of broadcasted events 99/21899/2
José Bollo [Tue, 16 Jul 2019 12:12:35 +0000 (14:12 +0200)]
afb-evt: Refactor processing of broadcasted events

Solving the bug SPEC-2625 needs to rework the broadcasting
of events. It appeared that the numerical event identifier
passed for broadcast wasn't used by called function except
for hooking. Suppressing it introduces a clear distinction
between the push and the broadcast paths.

The file afb-ws-json1 is changed to avoid casting of
functions.

Bug-AGL: SPEC-2625

Change-Id: I9fe75adc8086812b21b70ce28baffcf77bd5e1cf
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
4 years agouuid: Add module for UUID generation 98/21898/2
José Bollo [Tue, 16 Jul 2019 13:27:29 +0000 (15:27 +0200)]
uuid: Add module for UUID generation

This commit allow modules of afb-daemon to request UUID.

This introduce an abstraction above libuuid for 3 reasons:

 1. Using uuid had bad side effect inthe past because it
    required enought entropy at start time, leading to hanging
    initialisations in wait for enough entropy.

 2. Solving bug SPEC-2625 will require use of UUID.

 3. Porting to systems that haven't libuuid is made more
    easy after that.

Bug-AGL: SPEC-2625

Change-Id: I27d8b611946686dea6fab250697afe9b89aac869
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
4 years agoafb-client-demo: Allow pipe of messages 66/21866/2 7.99.3 halibut/7.99.3 halibut_7.99.3
Jose Bollo [Wed, 10 Jul 2019 15:23:31 +0000 (17:23 +0200)]
afb-client-demo: Allow pipe of messages

The tool afb-client-demo implements a synchronous
mode (option -s) that allows to wait for a reply
before to send the next request.

It is interesting for the purpose of testing to allow
afb-client-demo it to send a controlled count of
requests, ensuring that there is a controlled count
of pending requests.

Bug-AGL: SPEC-2638

Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Change-Id: Ic854d68aaeb82c17b4640c5c9de46181ad3a7e5e

4 years agoafb-xreq: Forbids (un)subscribes after reply 65/21865/2
Jose Bollo [Wed, 10 Jul 2019 13:18:02 +0000 (15:18 +0200)]
afb-xreq: Forbids (un)subscribes after reply

Allowing to subscribe to a request that was replied
was possible and lead to problem revealed by issues
SPEC-2542 and SPEC-2599 (these issues are more related
to processing unordered incoming messages).

The choice was
 - fix the bug and authorize (un)subscribe after reply
 - forbids to (un)subscribe after reply

Second solution was chosen for its simplicity and
its networking efficiency.

Bug-AGL: SPEC-2542
Bug-AGL: SPEC-2599

Change-Id: I09f48b760b1fd6f70d42b80df3c8053696c45966
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoRevert "afb-stub-ws: Allow unordered process of messages" 64/21864/1
José Bollo [Fri, 12 Jul 2019 13:41:32 +0000 (15:41 +0200)]
Revert "afb-stub-ws: Allow unordered process of messages"

This reverts commit 5425e054fbf87fe6d024103f46e53f2a28e074f2.

The change introduced in the reverted commit
is no more necessary since events are sent asynchronousely.

Bug-AGL: SPEC-2215
Bug-AGL: SPEC-2219
Bug-AGL: SPEC-2542
Bug-AGL: SPEC-2599

Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Change-Id: I4fd8d1516c97e2f95caaa244e28491f71b15bba7

4 years agoafb-evt: send events in separate job 63/21863/1
Jose Bollo [Thu, 11 Jul 2019 16:20:23 +0000 (18:20 +0200)]
afb-evt: send events in separate job

Sending events in the context of the calling process
had the consequence that the ordering of the messages
had to be removed (see SPEC-2215 & SPEC-2219). This
was not good by nature and lead to issues SPEC-2542
and SPEC-2599.

Sending events in the context of the calling process
also implies to delay the calling process.

For this reasons, sending events is now done in an
other jobs. For that reason, the count of allowed
pending jobs is increased to 100 (was 50).

Bug-AGL: SPEC-2215
Bug-AGL: SPEC-2219
Bug-AGL: SPEC-2542
Bug-AGL: SPEC-2599

Change-Id: I5b56d952cc187b65ad6eb9344ad74e5e8d3b7540
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agoafb-evt: Improve compatibility to guppy 62/21862/1
José Bollo [Fri, 12 Jul 2019 09:30:49 +0000 (11:30 +0200)]
afb-evt: Improve compatibility to guppy

The commit "a2cf84e: hooks: Allow to remove hooking"
re-order fragment of code. But this is an issue when
backporting changes to guppy.

That commit improve the situation for the file
afb-evt.c in the process of fixing the issue
SPEC-2599

Bug-AGL: SPEC-2599

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: I4e56cbeee7d3a89770e37a3045f652f39fc07410

4 years agoafb-args: Fix output of --version 40/21840/1
José Bollo [Tue, 9 Jul 2019 16:05:31 +0000 (18:05 +0200)]
afb-args: Fix output of --version

The legacy V1 and V2 versions of bindings are no
more printed if absent.

The support of dynamic bindings is fixed.

Bug-AGL: SPEC-2617

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: I429c0e2cdfcbfba6e0f1e639dbcbc2ca90a345ed

4 years agoFix syntax error in a constexpr function 32/21832/2
Loïc Collignon [Mon, 8 Jul 2019 12:47:30 +0000 (14:47 +0200)]
Fix syntax error in a constexpr function

The function declaration contains a syntax error that was somehow
ignored but raise an error about an illegal cast in a constexpr
function.
Fixed this error and clean up a bit surrounding code to be more concise.

Bug-AGL: SPEC-2615

Change-Id: I931b086c96b093b3de4465c51dfc3e865f7ece3b
Signed-off-by: Loïc Collignon <loic.collignon@iot.bzh>
4 years agoFix invalid TRACE setting in print version 37/21837/2
Sebastien Douheret [Tue, 9 Jul 2019 06:16:20 +0000 (08:16 +0200)]
Fix invalid TRACE setting in print version

Bug-AGL: SPEC-2617

Change-Id: Ia935aab3b0b508e7a916e334237c639efb1feb15
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
4 years agoFix warning when compiling with clang 86/21786/4
Loïc Collignon [Fri, 28 Jun 2019 07:50:46 +0000 (09:50 +0200)]
Fix warning when compiling with clang

The 'maybe-uninitialized' warning option is a GCC's only flag. The
equivalent one for Clang is 'possible-uninitialized'.
Added the right flag based on the compiler.

Bug-AGL: SPEC-2584

Change-Id: I09ce434dfda21996cefbf0b527b43d666a042e0e
Signed-off-by: Loïc Collignon <loic.collignon@iot.bzh>
4 years agoBuild af-binder-devtools-native using GCC-9.1.1 87/21487/3 7.99.2 halibut/7.99.2 halibut_7.99.2
Bechir Mghirbi [Tue, 4 Jun 2019 08:16:03 +0000 (10:16 +0200)]
Build af-binder-devtools-native using GCC-9.1.1

GCC-9.1.1 complains about variable ‘buf[0]’ that it may be used uninitialized
in the function 'make_info()'. This patchset initialize the variable.

Bug-AGL: SPEC-2482
Signed-off-by: Bechir Mghirbi <bechir.mghirbi@grammer.com>
Change-Id: I38d0c6f47fed462f4ea48990c4cb63f21fb2ee16

4 years agoafb-daemon: Add /tmp has fallback for uploads 76/21376/2 7.99.1 halibut/7.99.1 halibut_7.99.1
José Bollo [Thu, 23 May 2019 08:21:43 +0000 (10:21 +0200)]
afb-daemon: Add /tmp has fallback for uploads

During its start, when implementing HTTP server,
afb-daemon checked that the upload directory was
accessible and writable and afb-daemon refused to
start when it was not the case.

When trying to use systemd's DynamicUser for platform
services, it had the effect to forbid service to run.

That commit add the directory /tmp as a fallback
upload directory.

Bug-AGL: SPEC-2446

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: Ib4ee456d71cb1aefa19e8eed6774ef5f77919366

4 years agojobs: Fix infinite wait lock 38/21438/2
José Bollo [Tue, 28 May 2019 07:37:11 +0000 (09:37 +0200)]
jobs: Fix infinite wait lock

The binder was sometime locked until an external
event comes. This was discovered during stressing
startup test that don't expect external inputs and
that then waits for always without terminating.

The issue came from a little hole in the management
of the state of evmgr object. By design the evmgr
has to be synchronised against concurrent accesses
not by itself but by the integration. However, the
state of "running" wasn't set in the code protected
against concurent accesses. The new function allows
the integrator to correctly set the state before
releasing protection.

Bug-AGL: SPEC-2459

Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: Id75fd97c06d69666ced912a0a61380573dab31af

4 years agoFix afb document typo. 77/21277/3
Li Xiaoming [Thu, 9 May 2019 07:23:28 +0000 (15:23 +0800)]
Fix afb document typo.

Bug-AGL: SPEC-2391

Change-Id: I73efab27d09fce7ca16edabe14fe19d1092162db
Signed-off-by: Li Xiaoming <lixm.fnst@cn.fujitsu.com>
4 years agoafb-export: Fix requirement on multiple apis 45/21245/1
José Bollo [Fri, 3 May 2019 13:08:10 +0000 (15:08 +0200)]
afb-export: Fix requirement on multiple apis

The test 'test-apiv3' was failing because the required
api list "albert armel" wasn't splitted but set as-is.

At the same time, test suite is improved.

Bug-AGL: SPEC-1130
Bug-AGL: SPEC-2377

Change-Id: Ia4ab23bf666b5b4b1db3e1da2654d9387c2c01e5
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
4 years agocoverage: Add test of AFB_DEBUG_WAIT 16/21216/1
José Bollo [Tue, 30 Apr 2019 20:39:33 +0000 (22:39 +0200)]
coverage: Add test of AFB_DEBUG_WAIT

Bug-AGL: SPEC-1130

Change-Id: I349c141015e3851ddecd4a6df7497d8ef4cceaa6
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
4 years agocoverage: Allow to run coverage everywhere 15/21215/1
José Bollo [Tue, 30 Apr 2019 20:38:28 +0000 (22:38 +0200)]
coverage: Allow to run coverage everywhere

Coverage presumed that an available afb-daemon without
coverage instrumentation was available in the PATH.

This fix that problem by compiling that requirement.

Bug-AGL: SPEC-1130

Change-Id: Ic3435d73e830d630bef63dfb8e9b2ff9f1bf043c
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
4 years agoAllow to tune installation directories 14/21214/1
José Bollo [Tue, 30 Apr 2019 20:18:08 +0000 (22:18 +0200)]
Allow to tune installation directories

The location of intrinsic bindings and samples could not be tuned
but was fixed to be ${CMAKE_INSTALL_FULL_LIBDIR}/afb and
${CMAKE_INSTALL_FULL_DATADIR}/af-binder

These default locations are not bad but it is important to be able
to tune that location.

Bug-AGL: SPEC-2367

Change-Id: I4d4f9e9490d61e3278ef35ac42f2143a752a7c37
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
4 years agodoc: Improve comment on asynchronous calls 25/21125/2
Jose Bollo [Mon, 25 Feb 2019 10:27:48 +0000 (11:27 +0100)]
doc: Improve comment on asynchronous calls

Following the remarks of fellow developers, the status
of the object received by the callback function
needs to be explained better.

Change-Id: I0e6bcd51849bbc5af92af08675949a901bfd683e
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agobinding-wrap: Rework of context handling 09/21009/4
Jose Bollo [Fri, 12 Apr 2019 09:18:46 +0000 (11:18 +0200)]
binding-wrap: Rework of context handling

The C++ wrapper for handling contexts has
to be improved. This is a proposition of
improvement.

Change-Id: I7df36383f427d109356bdf4df573cba4b6e6ec05
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
4 years agosamples: wrong parameter for get_new_board() 71/21071/2
Phong Tran [Wed, 17 Apr 2019 15:58:40 +0000 (22:58 +0700)]
samples: wrong parameter for get_new_board()

for fixing
warning: too many arguments in call to 'get_new_board'

Change-Id: I7b3d175310156ea3d2efed29e344f01c9904d534
Signed-off-by: Phong Tran <tranmanphong@gmail.com>
4 years agoMerge changes Id24d9bb0,I6807ed25
José Bollo [Tue, 23 Apr 2019 09:06:24 +0000 (09:06 +0000)]
Merge changes Id24d9bb0,I6807ed25

* changes:
  change style initialization of struct afb_auth
  missing full initialization for struct afb_verb_v3

5 years agochange style initialization of struct afb_auth 69/21069/1
Phong Tran [Wed, 17 Apr 2019 15:57:17 +0000 (22:57 +0700)]
change style initialization of struct afb_auth

This is for fixing
warning: suggest braces around initialization of subobject
[-Wmissing-braces]

Change-Id: Id24d9bb09e46d59df7d043ed931e00bb5ec9469a
Signed-off-by: Phong Tran <tranmanphong@gmail.com>
5 years agomissing full initialization for struct afb_verb_v3 68/21068/1
Phong Tran [Wed, 17 Apr 2019 15:56:37 +0000 (22:56 +0700)]
missing full initialization for struct afb_verb_v3

This is for fixing
warning: missing field 'callback' initializer
[-Wmissing-field-initializers]

Change-Id: I6807ed25bff96c96f347ec1e87f1b12cf0759498
Signed-off-by: Phong Tran <tranmanphong@gmail.com>
5 years agoMerge "afb-migration-to-binding-v3: fix broken links"
Jan-Simon Moeller [Tue, 16 Apr 2019 17:04:22 +0000 (17:04 +0000)]
Merge "afb-migration-to-binding-v3: fix broken links"

5 years agoafb-migration-to-binding-v3: fix broken links 56/21056/1
Clément Bénier [Tue, 16 Apr 2019 14:47:40 +0000 (16:47 +0200)]
afb-migration-to-binding-v3: fix broken links

- fix broken link to the same section

Change-Id: I5e104c5527fae29ff51b6208f43ed0eb3c5f8c04
Signed-off-by: Clément Bénier <clement.benier@iot.bzh>
5 years agoFix small issues 06/21006/2
Jose Bollo [Fri, 12 Apr 2019 07:39:34 +0000 (09:39 +0200)]
Fix small issues

These issues was discovered by static analysis tool.

Change-Id: Iea75151c9b1f5e4cb139d2dc4e8a5c8bae5bb303
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
5 years agocoverage: Update Makefile 95/20995/5
José Bollo [Thu, 11 Apr 2019 11:06:04 +0000 (13:06 +0200)]
coverage: Update Makefile

Add new definitions according to new compile flags.

Change-Id: I49f19c8bb4dc2a5a142c03e2e415eaa725d4c0af
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
5 years agoReordering of sample and tutorial bindings 94/20994/5
José Bollo [Thu, 11 Apr 2019 11:09:56 +0000 (13:09 +0200)]
Reordering of sample and tutorial bindings

The main idea here is to install the sample and
tutorial bindings in specific directory.

This will at the end help to package parts
of the binder.

It also includes a simplification of CMakeLists
files.

Also fix an error in packaging rpm.

Bug-AGL: SPEC-2165

Change-Id: I494cc753796848cde849de1c3596893c78fa228f
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
5 years agoFix rpm packaging following review 20926 54/20954/1
Frederic Marec [Tue, 9 Apr 2019 07:35:08 +0000 (09:35 +0200)]
Fix rpm packaging following review 20926

Change-Id: Iec9de4201e966ef53e3f1edf9d0a6a81ae2899fc
Signed-off-by: Frederic Marec <frederic.marec@iot.bzh>
5 years agoChange agl-app-framework-binder.sh 26/20926/1
Frederic Marec [Fri, 5 Apr 2019 07:35:29 +0000 (09:35 +0200)]
Change agl-app-framework-binder.sh

Aligned the two different names from the two ways of packaging
From AGL-agl-app-framework-binder.sh to agl-app-framework-binder.sh for .rpm
From AGL-app-framework-binder.sh to agl-app-framework-binder.sh for .deb

Change-Id: Ie324ce159a55ccae7c051c97be5116d975e0da85
Signed-off-by: Frederic Marec <frederic.marec@iot.bzh>
5 years agoafb-export: Fix heap corruption 05/20905/1
José Bollo [Thu, 4 Apr 2019 13:28:03 +0000 (15:28 +0200)]
afb-export: Fix heap corruption

The allocated size wasn't correct when 'path'
was used. The effect be unseen depending on
size and alignment of heap chunks.

Change-Id: Id9f85a0078028319491b51bc3e11cd51e4bc3755
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
5 years agoFix false ***buffer overflow*** detection 82/20882/1
José Bollo [Tue, 2 Apr 2019 14:49:09 +0000 (16:49 +0200)]
Fix false ***buffer overflow*** detection

The compiling option __FORTIFY_SOURCE=2 introduced
a false ***buffer overflow*** detection when the
flexible array 'pattern' was initilized in globset.

The compiler is only complaining when the array is
in a struct that is in a struct like

 struct { ...; struct { ...; char name[1]; }}

To avoid these false detections, it is enougth
to ellipsese the dimension of the array. Seems
to be the now standard way of declaring flexible
arrays when it was before an extension. So now:

 struct { ...; struct { ...; char name[]; }}

works even when __FORTIFY_SOURCE=2.

Bug-AGL: SPEC-2292

Change-Id: I4b4a5df505a5357f92b9ab1657175911198ca582
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
5 years agoAdd conditionnal support of dynamic bindings 73/20873/1
Jose Bollo [Mon, 18 Feb 2019 14:04:38 +0000 (15:04 +0100)]
Add conditionnal support of dynamic bindings

The load of dynamic bindings becomes removable.
This is a step in direction of a tiny binder library.

Also refactor AGL_DEVEL

Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Change-Id: If283f431fd8a831429e717b2770464cb54476dc7

5 years agoAdd conditionnal support of bindings version 2 72/20872/1
Jose Bollo [Mon, 18 Feb 2019 13:31:25 +0000 (14:31 +0100)]
Add conditionnal support of bindings version 2

Bindings version 2 will become legacy soon.
This patch allows their removal

Change-Id: Iecad3abd0ddd714e5d55c0b935be756a29d1ca37
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
5 years agoImprove setting of options 71/20871/1
Jose Bollo [Mon, 18 Feb 2019 12:13:56 +0000 (13:13 +0100)]
Improve setting of options

Change-Id: Idbadb9b7b801cb61d527addb5d3137aeb4cf6311
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
5 years agojobs: Refactor exiting jobs 70/20870/1
José Bollo [Fri, 15 Feb 2019 19:49:54 +0000 (20:49 +0100)]
jobs: Refactor exiting jobs

The new termination function can allow the restart
because it doesn't abort the waiting jobs.

So after calling 'jobs_exit', all threads stop.
The function 'job_start' returns.

The threads that are in blocking state, i.e. in
a call to 'jobs_enter' or 'jobs_call' are stopped.
An error status -1 with errno=EINTR is returned in
that case.

But before returning, that function calls the exit
handler if any.

Change-Id: I85a4b1976b09b18804eb681af940531ae5ace6c3
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
5 years agoWorkaround an exit issue 69/20869/1
José Bollo [Fri, 15 Feb 2019 16:40:04 +0000 (17:40 +0100)]
Workaround an exit issue

When running gcov the running script is
sometime blocking.

GDB tells:

 Thread 1 (Thread 0x7ff14e783b40 (LWP 1318)):
 #0  0x00007ff14ccf334c in __lll_lock_wait_private () from /lib64/libc.so.6
 #1  0x00007ff14cc70598 in malloc () from /lib64/libc.so.6
 #2  0x000000000046523a in gcov_do_dump ()
 #3  0x00000000004653f4 in __gcov_exit ()
 #4  0x00000000004632df in _GLOBAL__sub_D_00100_1_wrap_json_get_error_position () at ../../src/wrap-json.c:1250
 #5  0x00007ff14e5b5916 in _dl_fini () from /lib64/ld-linux-x86-64.so.2
 #6  0x00007ff14cc255ec in __run_exit_handlers () from /lib64/libc.so.6
 #7  0x00007ff14cc2571c in exit () from /lib64/libc.so.6
 #8  0x00000000004069fc in on_sigchld (signum=17, info=0x7ffc3f43fa70, uctx=0x7ffc3f43f940) at ../../src/main-afb-daemon.c:411
 #9  <signal handler called>
 #10 0x00007ff14cc6e527 in _int_malloc () from /lib64/libc.so.6
 #11 0x00007ff14cc710a2 in calloc () from /lib64/libc.so.6
 #12 0x00007ff14d454ff7 in json_object_new_int () from /lib64/libjson-c.so.4
 ...

It means that allocating memory in exit handlers
can block!

The work around here is to force the daemon to exit
properly, i.e., not in a signal handler, by calling hello/exit
from test script -at the very end-.

Change-Id: Iee289fb1af8479628df895aac7eb021cedda4f2c
Signed-off-by: José Bollo <jose.bollo@iot.bzh>