From: José Bollo Date: Wed, 31 Jan 2018 16:16:18 +0000 (+0100) Subject: afb-trace: Replace daemon by api name X-Git-Tag: flounder_5.99.1~90 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=f8ca7444353ca2ea3384d53482219e26f624b7d8;p=src%2Fapp-framework-binder.git afb-trace: Replace daemon by api name This replacement greatly improves the code. Change-Id: If3fd6e6080eda2268ccf551998f99af01799be29 Signed-off-by: José Bollo --- diff --git a/src/afb-monitor.c b/src/afb-monitor.c index 4b1c0384..e34b5989 100644 --- a/src/afb-monitor.c +++ b/src/afb-monitor.c @@ -21,7 +21,8 @@ #include -#include +#define AFB_BINDING_VERSION 0 +#include #include "afb-api.h" #include "afb-apiset.h" @@ -324,7 +325,7 @@ static void f_set(struct afb_req req) static void *context_create() { - return afb_trace_create(&datav2.daemon, NULL); + return afb_trace_create(_afb_binding_v2_monitor.api, NULL); } static void context_destroy(void *pointer) diff --git a/src/afb-trace.c b/src/afb-trace.c index 021ab5af..2b803029 100644 --- a/src/afb-trace.c +++ b/src/afb-trace.c @@ -27,6 +27,7 @@ #include #include + #define AFB_BINDING_VERSION 0 #include @@ -106,7 +107,7 @@ struct afb_trace { int refcount; /* reference count */ pthread_mutex_t mutex; /* concurrency management */ - struct afb_daemon *daemon; /* daemon */ + const char *apiname; /* api name for events */ struct afb_session *bound; /* bound to session */ struct event *events; /* list of events */ struct tag *tags; /* list of tags */ @@ -1065,7 +1066,6 @@ static struct tag *trace_get_tag(struct afb_trace *trace, const char *name, int */ static struct event *trace_get_event(struct afb_trace *trace, const char *name, int alloc) { - struct afb_event e; struct event *event; /* search the event */ @@ -1076,8 +1076,7 @@ static struct event *trace_get_event(struct afb_trace *trace, const char *name, if (!event && alloc) { event = malloc(sizeof * event); if (event) { - e = afb_daemon_make_event_v1(*trace->daemon, name); - event->evtid = afb_evt_eventid_to_evtid(afb_event_to_eventid(e)); + event->evtid = afb_evt_evtid_create2(trace->apiname, name); if (event->evtid) { event->next = trace->events; trace->events = event; @@ -1437,17 +1436,17 @@ static void drop_session(void *closure, struct json_object *object) /*******************************************************************************/ /* allocates an afb_trace instance */ -struct afb_trace *afb_trace_create(struct afb_daemon *daemon, struct afb_session *bound) +struct afb_trace *afb_trace_create(const char *apiname, struct afb_session *bound) { struct afb_trace *trace; - assert(daemon); + assert(apiname); trace = calloc(1, sizeof *trace); if (trace) { trace->refcount = 1; trace->bound = bound; - trace->daemon = daemon; + trace->apiname = apiname; pthread_mutex_init(&trace->mutex, NULL); } return trace; diff --git a/src/afb-trace.h b/src/afb-trace.h index c3d8ed2b..2d3b0beb 100644 --- a/src/afb-trace.h +++ b/src/afb-trace.h @@ -20,11 +20,11 @@ struct afb_trace; -extern struct afb_trace *afb_trace_create(struct afb_daemon *daemon, struct afb_session *bound); +extern struct afb_trace *afb_trace_create(const char *api, struct afb_session *bound); + extern void afb_trace_addref(struct afb_trace *trace); extern void afb_trace_unref(struct afb_trace *trace); - extern int afb_trace_add(struct afb_req req, struct json_object *args, struct afb_trace *trace); extern int afb_trace_drop(struct afb_req req, struct json_object *args, struct afb_trace *trace);