summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-05-30 09:57:49 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-05-30 09:57:49 +0200
commitaa44ff4b4e94409b5ca7ddc7b6f280865bc36c54 (patch)
tree111c5f1cca877c1451b174aca18ef5da088c81d8
parente1e9ea2305132b62636b5e6e71a594c86216956a (diff)
Bindings V1: allows to receive event
Don't enforce anymore to have the function 'afbBindingV1ServiceInit' defined when expecting events through 'afbBindingV1ServiceEvent'. This will allow to handle broadcasted events. Change-Id: Ib75904487ad99fdc50813deaf6013f4ba4c47421 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-api-so-v1.c4
-rw-r--r--src/afb-svc.c8
2 files changed, 7 insertions, 5 deletions
diff --git a/src/afb-api-so-v1.c b/src/afb-api-so-v1.c
index f4562ec5..f367820d 100644
--- a/src/afb-api-so-v1.c
+++ b/src/afb-api-so-v1.c
@@ -96,7 +96,8 @@ static int service_start_cb(void *closure, int share_session, int onneed, struct
/* get the initialisation */
init = dlsym(desc->handle, afb_api_so_v1_service_init);
- if (init == NULL) {
+ onevent = dlsym(desc->handle, afb_api_so_v1_service_event);
+ if (init == NULL && onevent == NULL) {
/* not an error when onneed */
if (onneed != 0)
return 0;
@@ -107,7 +108,6 @@ static int service_start_cb(void *closure, int share_session, int onneed, struct
}
/* get the event handler if any */
- onevent = dlsym(desc->handle, afb_api_so_v1_service_event);
desc->service = afb_svc_create_v1(apiset, share_session, init, onevent);
if (desc->service == NULL) {
/* starting error */
diff --git a/src/afb-svc.c b/src/afb-svc.c
index b4032e32..b492520c 100644
--- a/src/afb-svc.c
+++ b/src/afb-svc.c
@@ -194,9 +194,11 @@ struct afb_svc *afb_svc_create_v1(
}
/* initialises the svc now */
- rc = start(to_afb_service(svc));
- if (rc < 0)
- goto error;
+ if (start) {
+ rc = start(to_afb_service(svc));
+ if (rc < 0)
+ goto error;
+ }
return svc;