summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2013-10-23 18:08:34 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2013-10-23 18:08:34 +0200
commit3a4ca82938dc8470fa1ceeef2ddb2058e896a803 (patch)
tree89b50d02537760ebd9e70b8d9f64b4f519a5cdae
parent5cddb0533b53f8acfa36a65a4337ff368aa980de (diff)
downloadrsyslog-3a4ca82938dc8470fa1ceeef2ddb2058e896a803.tar.gz
rsyslog-3a4ca82938dc8470fa1ceeef2ddb2058e896a803.tar.bz2
rsyslog-3a4ca82938dc8470fa1ceeef2ddb2058e896a803.zip
bugfix: unset statement always worked on message var, even if local var was given
-rw-r--r--ChangeLog2
-rw-r--r--runtime/msg.c30
2 files changed, 23 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 90b2f9a2..9f0a6167 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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)
{