diff options
author | José Bollo <jose.bollo@iot.bzh> | 2018-07-12 11:22:14 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2018-07-13 12:19:11 +0200 |
commit | 93d8d6f69399dacbb43c0780ebccc378b4f44880 (patch) | |
tree | d34a7947b0e6882de75591a1e66c66f678c061fe /src/afb-supervision.c | |
parent | 6c003255918fc85b693a4b0becf45016d1282dfe (diff) |
afb-supervision: Remove dependency to external
Also some cleaning in use of extern to allow
accurate grep.
Removing extern is better for linking and for
structuration.
Change-Id: I8121c4b9b34fa2737bffd2ecbe170d04d1d60ad1
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-supervision.c')
-rw-r--r-- | src/afb-supervision.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/afb-supervision.c b/src/afb-supervision.c index 84c302f6..2482a082 100644 --- a/src/afb-supervision.c +++ b/src/afb-supervision.c @@ -51,8 +51,6 @@ #include "wrap-json.h" #include "jobs.h" -extern struct afb_config *main_config; - /* api and apiset name */ static const char supervision_apiname[] = AFS_SUPERVISION_APINAME; static const char supervisor_apiname[] = AFS_SUPERVISOR_APINAME; @@ -64,7 +62,10 @@ static const char supervisor_socket_path[] = AFS_SUPERVISION_SOCKET; static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; /* the standard apiset */ -extern struct afb_apiset *main_apiset; +static struct { + struct afb_apiset *apiset; + struct afb_config *config; +} global; /* the supervision apiset (not exported) */ static struct afb_apiset *supervision_apiset; @@ -237,7 +238,7 @@ static void on_sighup(int signum) /** * initialize the supervision */ -int afb_supervision_init() +int afb_supervision_init(struct afb_apiset *apiset, struct afb_config *config) { int rc; struct sigaction sa; @@ -263,6 +264,10 @@ int afb_supervision_init() return rc; } + /* init the globals */ + global.apiset = apiset; + global.config = config; + /* get SIGHUP */ memset(&sa, 0, sizeof sa); sa.sa_handler = on_sighup; @@ -346,7 +351,7 @@ static void on_supervision_call(void *closure, struct afb_xreq *xreq) afb_xreq_reply(xreq, list, NULL, NULL); break; case Config: - afb_xreq_reply(xreq, afb_config_json(main_config), NULL, NULL); + afb_xreq_reply(xreq, afb_config_json(global.config), NULL, NULL); break; case Trace: if (!trace) @@ -372,7 +377,7 @@ static void on_supervision_call(void *closure, struct afb_xreq *xreq) if (wrap_json_unpack(args, "{ss ss s?o*}", "api", &api, "verb", &verb, "args", &sub)) afb_xreq_reply(xreq, NULL, "error", "bad request"); else { - xapi = afb_apiset_lookup_started(main_apiset, api, 1); + xapi = afb_apiset_lookup_started(global.apiset, api, 1); if (!xapi) afb_xreq_reply_unknown_api(xreq); else { |