diff options
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | runtime/msg.c | 30 |
2 files changed, 23 insertions, 9 deletions
@@ -1,3 +1,5 @@ +- bugfix: unset statement always worked on message var, even if local + var was given --------------------------------------------------------------------------- Version 7.5.6 [devel] 2013-10-?? - imudp: support for binding to ruleset added diff --git a/runtime/msg.c b/runtime/msg.c index c9ac507e..eef69f85 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -3952,16 +3952,32 @@ msgAddJSON(msg_t *pM, uchar *name, struct json_object *json) { } rsRetVal -msgDelJSONVar(msg_t *pM, struct json_object **jroot, uchar *name) +msgDelJSON(msg_t *pM, uchar *name) { + struct json_object **jroot; struct json_object *parent, *leafnode; uchar *leaf; DEFiRet; dbgprintf("AAAA: unset variable '%s'\n", name); MsgLock(pM); - if((name[0] == '!' || name[0] == '.' || name[0] == '/') && name[1] == '\0') { - /* strange, but I think we should permit this. After all, + + if(name[0] == '!') { + jroot = &pM->json; + } else if(name[0] == '.') { + jroot = &pM->localvars; + } else { /* globl var */ + pthread_rwlock_wrlock(&glblVars_rwlock); + jroot = &global_var_root; + } + if(jroot == NULL) { + DBGPRINTF("msgDelJSONVar; jroot empty in unset for property %s\n", + name); + FINALIZE; + } + + if(name[1] == '\0') { + /* full tree! Strange, but I think we should permit this. After all, * we trust rsyslog.conf to be written by the admin. */ DBGPRINTF("unsetting JSON root object\n"); @@ -3988,16 +4004,12 @@ DBGPRINTF("AAAA: unset found JSON value path '%s', " "leaf '%s', leafnode %p\n", } finalize_it: + if(name[0] == '/') + pthread_rwlock_unlock(&glblVars_rwlock); MsgUnlock(pM); RETiRet; } -rsRetVal -msgDelJSON(msg_t *pM, uchar *name) -{ - return msgDelJSONVar(pM, &pM->json, name); -} - static struct json_object * jsonDeepCopy(struct json_object *src) { |