From ef91faafac9eba14c8faeb7680ea6a45672d23ea Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 20 Oct 2018 17:12:39 +0200 Subject: [PATCH] shmem: add new mode setting which superseeds the polling setting --- lib/nodes/shmem.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/nodes/shmem.c b/lib/nodes/shmem.c index 90c3090d2..f4e0aaf7b 100644 --- a/lib/nodes/shmem.c +++ b/lib/nodes/shmem.c @@ -39,7 +39,7 @@ int shmem_parse(struct node *n, json_t *cfg) { struct shmem *shm = (struct shmem *) n->_vd; - const char *val; + const char *val, *mode_str = NULL; int ret; json_t *json_exec = NULL; @@ -51,18 +51,27 @@ int shmem_parse(struct node *n, json_t *cfg) shm->conf.polling = false; shm->exec = NULL; - ret = json_unpack_ex(cfg, &err, 0, "{ s: { s: s }, s: { s: s }, s?: i, s?: b, s?: o }", + ret = json_unpack_ex(cfg, &err, 0, "{ s: { s: s }, s: { s: s }, s?: i, s?: o, s?: s }", "out", "name", &shm->out_name, "in", "name", &shm->in_name, "queuelen", &shm->conf.queuelen, - "polling", &shm->conf.polling, - "exec", &json_exec + "exec", &json_exec, + "mode", &mode_str ); if (ret) jerror(&err, "Failed to parse configuration of node %s", node_name(n)); + if (mode_str) { + if (!strcmp(mode_str, "polling")) + shm->conf.polling = true; + else if (!strcmp(mode_str, "pthread")) + shm->conf.polling = false; + else + error("Unknown mode '%s' in node %s", mode_str, node_name(n)); + } + if (json_exec) { if (!json_is_array(json_exec)) error("Setting 'exec' of node %s must be an array of strings", node_name(n));