summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-09-21 18:17:39 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-10-09 14:08:32 +0200
commitae5d707f9348b50d44724ec2b091f4528ff0a72b (patch)
treea099dd9cb3829a387151615ecb288f2d5601651e
parent89190b853409c3d0465232da6dd11e4c0a0b73d7 (diff)
afb-export: record apiset at creation
Change-Id: I058eaee990e34990d0860a316ba8c348c23eff5f Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-api-so-v1.c2
-rw-r--r--src/afb-api-so-v2.c2
-rw-r--r--src/afb-export.c15
-rw-r--r--src/afb-export.h5
4 files changed, 12 insertions, 12 deletions
diff --git a/src/afb-api-so-v1.c b/src/afb-api-so-v1.c
index c69f2945..d7429efe 100644
--- a/src/afb-api-so-v1.c
+++ b/src/afb-api-so-v1.c
@@ -212,7 +212,7 @@ int afb_api_so_v1_add(const char *path, void *handle, struct afb_apiset *apiset)
/* allocates the description */
init = dlsym(handle, afb_api_so_v1_service_init);
onevent = dlsym(handle, afb_api_so_v1_service_event);
- export = afb_export_create_v1(path, init, onevent);
+ export = afb_export_create_v1(apiset, path, init, onevent);
desc = calloc(1, sizeof *desc);
if (desc == NULL || export == NULL) {
ERROR("out of memory");
diff --git a/src/afb-api-so-v2.c b/src/afb-api-so-v2.c
index fef6eb20..edc31d53 100644
--- a/src/afb-api-so-v2.c
+++ b/src/afb-api-so-v2.c
@@ -168,7 +168,7 @@ int afb_api_so_v2_add_binding(const struct afb_binding_v2 *binding, void *handle
assert(data);
/* allocates the description */
- export = afb_export_create_v2(binding->api, data, binding->init, binding->onevent);
+ export = afb_export_create_v2(apiset, binding->api, data, binding->init, binding->onevent);
desc = calloc(1, sizeof *desc);
if (!desc || !export) {
ERROR("out of memory");
diff --git a/src/afb-export.c b/src/afb-export.c
index 2f16b375..90507b64 100644
--- a/src/afb-export.c
+++ b/src/afb-export.c
@@ -39,7 +39,6 @@
#include "jobs.h"
#include "verbose.h"
-extern struct afb_apiset *main_apiset;
/*************************************************************************
* internal types and structures
@@ -206,7 +205,7 @@ static int require_api_cb(void *closure, const char *name, int initialized)
errno = EINVAL;
return -1;
}
- return -!(initialized ? afb_apiset_lookup_started : afb_apiset_lookup)(main_apiset, name, 1);
+ return -!(initialized ? afb_apiset_lookup_started : afb_apiset_lookup)(export->apiset, name, 1);
}
static int rename_api_cb(void *closure, const char *name)
@@ -687,7 +686,7 @@ static const struct afb_evt_itf evt_v12_itf = {
*************************************************************************************************************
*************************************************************************************************************/
-static struct afb_export *create(const char *apiname, enum afb_api_version version)
+static struct afb_export *create(struct afb_apiset *apiset, const char *apiname, enum afb_api_version version)
{
struct afb_export *export;
@@ -706,7 +705,7 @@ static struct afb_export *create(const char *apiname, enum afb_api_version versi
export->version = version;
export->state = Api_State_Pre_Init;
export->session = afb_session_addref(common_session);
- export->apiset = afb_apiset_addref(main_apiset);
+ export->apiset = afb_apiset_addref(apiset);
}
return export;
}
@@ -723,9 +722,9 @@ void afb_export_destroy(struct afb_export *export)
}
}
-struct afb_export *afb_export_create_v1(const char *apiname, int (*init)(struct afb_service), void (*onevent)(const char*, struct json_object*))
+struct afb_export *afb_export_create_v1(struct afb_apiset *apiset, const char *apiname, int (*init)(struct afb_service), void (*onevent)(const char*, struct json_object*))
{
- struct afb_export *export = create(apiname, Api_Version_1);
+ struct afb_export *export = create(apiset, apiname, Api_Version_1);
if (export) {
export->init.v1 = init;
export->on_event.v12 = onevent;
@@ -737,9 +736,9 @@ struct afb_export *afb_export_create_v1(const char *apiname, int (*init)(struct
return export;
}
-struct afb_export *afb_export_create_v2(const char *apiname, struct afb_binding_data_v2 *data, int (*init)(), void (*onevent)(const char*, struct json_object*))
+struct afb_export *afb_export_create_v2(struct afb_apiset *apiset, const char *apiname, struct afb_binding_data_v2 *data, int (*init)(), void (*onevent)(const char*, struct json_object*))
{
- struct afb_export *export = create(apiname, Api_Version_2);
+ struct afb_export *export = create(apiset, apiname, Api_Version_2);
if (export) {
export->init.v2 = init;
export->on_event.v12 = onevent;
diff --git a/src/afb-export.h b/src/afb-export.h
index 853fc5d4..9bd08204 100644
--- a/src/afb-export.h
+++ b/src/afb-export.h
@@ -24,8 +24,9 @@ struct afb_service;
struct afb_binding_data_v2;
struct afb_binding_interface_v1;
-extern struct afb_export *afb_export_create_v1(const char *apiname, int (*init)(struct afb_service), void (*onevent)(const char*, struct json_object*));
-extern struct afb_export *afb_export_create_v2(const char *apiname, struct afb_binding_data_v2 *data, int (*init)(), void (*onevent)(const char*, struct json_object*));
+extern struct afb_export *afb_export_create_v1(struct afb_apiset *apiset, const char *apiname, int (*init)(struct afb_service), void (*onevent)(const char*, struct json_object*));
+extern struct afb_export *afb_export_create_v2(struct afb_apiset *apiset, const char *apiname, struct afb_binding_data_v2 *data, int (*init)(), void (*onevent)(const char*, struct json_object*));
+
extern void afb_export_destroy(struct afb_export *export);
extern const char *afb_export_apiname(const struct afb_export *export);