X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-supervision.c;h=0884bc961827425c4169f0c97d051523be595d6e;hb=bd10bc4405f3777fe495cb9f62818d67ab584854;hp=f41ca18b53b3dd74eb78ddfe5586346a6257bc2d;hpb=abbb4599f0b921c6f434b6bd02bcfb277eecf745;p=src%2Fapp-framework-binder.git diff --git a/src/afb-supervision.c b/src/afb-supervision.c index f41ca18b..0884bc96 100644 --- a/src/afb-supervision.c +++ b/src/afb-supervision.c @@ -43,6 +43,7 @@ #include "afs-supervision.h" #include "afb-stub-ws.h" #include "afb-debug.h" +#include "afb-fdev.h" #include "verbose.h" #include "wrap-json.h" #include "jobs.h" @@ -50,7 +51,8 @@ extern struct afb_config *main_config; /* api and apiset name */ -static const char supervision_apiname[] = AFS_SURPERVISION_APINAME_INTERNAL; +static const char supervision_apiname[] = AFS_SURPERVISION_APINAME; +static const char supervisor_apiname[] = AFS_SURPERVISOR_APINAME; /* path of the supervision socket */ static const char supervisor_socket_path[] = AFS_SURPERVISION_SOCKET; @@ -138,6 +140,7 @@ static void try_connect_supervisor() int fd; ssize_t srd; struct afs_supervision_initiator initiator; + struct fdev *fdev; /* get the mutex */ pthread_mutex_lock(&mutex); @@ -195,10 +198,15 @@ static void try_connect_supervisor() } /* make the supervisor link */ - supervisor = afb_stub_ws_create_server(fd, supervision_apiname, supervision_apiset); + fdev = afb_fdev_create(fd); + if (!fdev) { + ERROR("Creation of fdev failed: %m"); + goto end2; + } + supervisor = afb_stub_ws_create_server(fdev, supervision_apiname, supervision_apiset); if (!supervisor) { ERROR("Creation of supervisor failed: %m"); - goto end2; + goto end; } afb_stub_ws_on_hangup(supervisor, on_supervisor_hangup); @@ -284,7 +292,6 @@ static const char *verbs[] = { "break", "config", "do", "exit", "sclose", "slist", "trace", "wait" }; enum { Break , Config , Do , Exit , Sclose , Slist , Trace , Wait }; - static void on_supervision_call(void *closure, struct afb_xreq *xreq) { int i, rc; @@ -309,7 +316,7 @@ static void on_supervision_call(void *closure, struct afb_xreq *xreq) i = 0; if (wrap_json_unpack(args, "i", &i)) wrap_json_unpack(args, "{si}", "code", &i); - ERROR("existing from supervision with code %d -> %d", i, i & 127); + ERROR("exiting from supervision with code %d -> %d", i, i & 127); exit(i & 127); break; case Sclose: @@ -340,9 +347,10 @@ static void on_supervision_call(void *closure, struct afb_xreq *xreq) break; case Trace: if (!trace) - trace = afb_trace_create(supervision_apiname, NULL /* not bound to any session */); + trace = afb_trace_create(supervisor_apiname, NULL /* not bound to any session */); - req = afb_xreq_unstore((struct afb_stored_req*)xreq); + req = xreq_to_req(xreq); + add = drop = NULL; wrap_json_unpack(args, "{s?o s?o}", "add", &add, "drop", &drop); if (add) { rc = afb_trace_add(req, add, trace);