diff options
author | José Bollo <jose.bollo@iot.bzh> | 2019-07-16 23:39:27 +0200 |
---|---|---|
committer | Jose Bollo <jose.bollo@iot.bzh> | 2019-07-18 15:38:02 +0200 |
commit | 6dfeafe7e4fa582b3db3f950136bc97f8611fc6d (patch) | |
tree | 62386661fe495dd8992260c89e09757326450edc /src/afb-evt.h | |
parent | 5b5968815dc672467f40ed6b49f05a590bdb8b4d (diff) |
Tag broadcasted events with UUID and hop
When API have mutual dependencies, leading to
loops in dependecies, broadcasting an event
never ends because of the loop (see SPEC-2625).
To avoid that weird flood of events, a unic
identifier (UUID) is attached to broadcasted
event and a tiny memory records previously
broadcasted events to avoid re-sending an
already sent event.
The size of the memory can be set using the
macro variable EVENT_BROADCAST_MEMORY_COUNT
whose default value is 8. It can be reduced
to 0.
An other mecanism is added to limit the count
of hops that a broadcasted event can do. That
count can be set using the macro variable
EVENT_BROADCAST_HOP_MAX whose default value
is 10.
Bug-AGL: SPEC-2625
Change-Id: I29550a8a5c8f5e2ffb20edc3330357a1e870c0e2
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-evt.h')
-rw-r--r-- | src/afb-evt.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/afb-evt.h b/src/afb-evt.h index 47c55815..3e37df53 100644 --- a/src/afb-evt.h +++ b/src/afb-evt.h @@ -17,6 +17,8 @@ #pragma once +#include "uuid.h" + struct afb_event_x1; struct afb_event_x2; struct afb_evtid; @@ -27,7 +29,7 @@ struct afb_evt_listener; struct afb_evt_itf { void (*push)(void *closure, const char *event, int evtid, struct json_object *object); - void (*broadcast)(void *closure, const char *event, struct json_object *object); + void (*broadcast)(void *closure, const char *event, struct json_object *object, const uuid_binary_t uuid, uint8_t hop); void (*add)(void *closure, const char *event, int evtid); void (*remove)(void *closure, const char *event, int evtid); }; @@ -35,6 +37,7 @@ struct afb_evt_itf extern struct afb_evt_listener *afb_evt_listener_create(const struct afb_evt_itf *itf, void *closure); extern int afb_evt_broadcast(const char *event, struct json_object *object); +extern int afb_evt_rebroadcast(const char *event, struct json_object *object, const uuid_binary_t uuid, uint8_t hop); extern struct afb_evt_listener *afb_evt_listener_addref(struct afb_evt_listener *listener); extern void afb_evt_listener_unref(struct afb_evt_listener *listener); |