X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-supervision.c;h=e6bc0a516e7535a0e2863520cb3698c5c17abbe2;hb=refs%2Fheads%2Fsandbox%2FDDTLK%2Fpakage;hp=79a9d3fd4ca8ffff4c77854b434e48d7abe86944;hpb=4521c1e7ae5371ab9d639adc617d17fb4e8ded0c;p=src%2Fapp-framework-binder.git diff --git a/src/afb-supervision.c b/src/afb-supervision.c index 79a9d3fd..e6bc0a51 100644 --- a/src/afb-supervision.c +++ b/src/afb-supervision.c @@ -14,8 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#if defined(WITH_SUPERVISION) + #define _GNU_SOURCE -#define AFB_BINDING_PRAGMA_NO_VERBOSE_MACRO #include #include @@ -49,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; @@ -62,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 json_object *config; +} global; /* the supervision apiset (not exported) */ static struct afb_apiset *supervision_apiset; @@ -209,7 +212,7 @@ static void try_connect_supervisor() ERROR("Creation of supervisor failed: %m"); goto end; } - afb_stub_ws_on_hangup(supervisor, on_supervisor_hangup); + afb_stub_ws_set_on_hangup(supervisor, on_supervisor_hangup); /* successful termination */ goto end; @@ -235,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 json_object *config) { int rc; struct sigaction sa; @@ -261,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; @@ -344,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, json_object_get(global.config), NULL, NULL); break; case Trace: if (!trace) @@ -370,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 { @@ -395,3 +402,4 @@ static void on_supervision_call(void *closure, struct afb_xreq *xreq) } } +#endif