Message ID | 20170518073928.22437-1-denis.osvald@sartura.hr |
---|---|
State | Accepted |
Headers | show |
On 2017-05-18 09:39, Denis Osvald wrote: > This wires in custom expression handler functionality, which was > present in json script since the original version, but never used. To add a bit of context: Experimenting with procd service triggers, it was noticed that when adding triggers for a network interface, trigger is activated too often. I saw discussions related to both netifd (as sender of network interface trigger events) and procd side of the problem a few times during past months on the list, e.g.: http://lists.infradead.org/pipermail/lede-dev/2017-April/007065.html http://lists.infradead.org/pipermail/lede-dev/2017-April/007162.html http://lists.infradead.org/pipermail/lede-dev/2017-March/006927.html Quote from the last link: > be nice if [...] there were ways to be better refine the interface > triggers to only a true interface reconfiguration As one way of solving the problem, I wanted to make a trigger-handling json_script which itself would check the trigger details, and decide whether the event was relevant enough to warrant a reload. I tried this via a patch to procd: http://public.inteno.se/?p=iopsys.git;a=commitdiff;h=3cdd8f80433e21eacfb593e69361e8f217aba30c However, json_script turned out not to support custom expression handlers, hence this patch. Regards, Denis
diff --git a/json_script.c b/json_script.c index 463aac8..8894901 100644 --- a/json_script.c +++ b/json_script.c @@ -415,8 +415,10 @@ static int json_process_expr(struct json_call *call, struct blob_attr *cur) } ret = __json_process_type(call, cur, expr, ARRAY_SIZE(expr), &found); - if (!found) - ctx->handle_error(ctx, "Unknown expression type", cur); + if (!found) { + const char *name = blobmsg_data(blobmsg_data(cur)); + ctx->handle_expr(ctx, name, cur, call->vars); + } return ret; }
This wires in custom expression handler functionality, which was present in json script since the original version, but never used. Signed-off-by: Denis Osvald <denis.osvald@sartura.hr> --- json_script.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)