diff --git a/system/nxinit/action.c b/system/nxinit/action.c index a8ce57da8..f1d1d2bfd 100644 --- a/system/nxinit/action.c +++ b/system/nxinit/action.c @@ -216,6 +216,7 @@ static int event_callback(FAR struct action_manager_s *am, init_debug("Trigger %s%s%s", event->key, event->invert ? "!=" : "==", event->value); + return EVENT_STATE_TRIGGERED; } } @@ -237,20 +238,18 @@ int init_action_foreach_event(FAR struct action_manager_s *am, list_for_every_entry(&am->actions, a, struct action_s, node) { - for (i = 0, m = 0; i < nitems(a->events) && a->events[i].key; i++) + for (i = 0, m = 1; i < nitems(a->events) && a->events[i].key; i++) { ret = cb(am, a, &a->events[i], arg); if (ret < 0) { break; } - else if (ret > 0) - { - m++; - } + + m = MIN(m * ret, EVENT_STATE_TRIGGERED); } - if (i > 0 && i == m) + if (m == EVENT_STATE_TRIGGERED) { add_ready(am, a); } diff --git a/system/nxinit/action.h b/system/nxinit/action.h index 19252f3d0..a13637ed2 100644 --- a/system/nxinit/action.h +++ b/system/nxinit/action.h @@ -78,6 +78,18 @@ struct action_manager_s FAR struct init_poller_s *prop; }; +/* Event evaluation result reported by init_action_event_cb. + * TRIGGERED means the event is satisfied and its key is the one that just + * changed, SATISFIED means it stays satisfied from an earlier change. + */ + +enum action_event_state_e +{ + EVENT_STATE_UNSATISFIED = 0, + EVENT_STATE_SATISFIED, + EVENT_STATE_TRIGGERED, +}; + typedef CODE int (*init_action_event_cb)(FAR struct action_manager_s *, FAR struct action_s *, FAR struct action_event_s *,