Blame SOURCES/rsyslog-8.24.0-msg_c_nonoverwrite_merge.patch

a856a8
From fa7d98b0cb0512d84355e3aafdc5a3e366842f2a Mon Sep 17 00:00:00 2001
a856a8
From: Radovan Sroka <rsroka@redhat.com>
a856a8
Date: Mon, 21 Nov 2016 13:38:18 +0100
a856a8
Subject: [PATCH 2/4] Rebased from: Patch2:
a856a8
 rsyslog-7.2.1-msg_c_nonoverwrite_merge.patch
a856a8
a856a8
Resolves:
a856a8
	no adressed bugzila
a856a8
---
a856a8
 runtime/msg.c | 25 +++++++++++++++++++++++--
a856a8
 1 file changed, 23 insertions(+), 2 deletions(-)
a856a8
a856a8
diff --git a/runtime/msg.c b/runtime/msg.c
a856a8
index f6e017b..5430331 100644
a856a8
--- a/runtime/msg.c
a856a8
+++ b/runtime/msg.c
a856a8
@@ -4632,6 +4632,27 @@ finalize_it:
a856a8
 	RETiRet;
a856a8
 }
a856a8
 
a856a8
+static rsRetVal jsonMerge(struct json_object *existing, struct json_object *json);
a856a8
+
a856a8
+static rsRetVal
a856a8
+jsonMergeNonOverwrite(struct json_object *existing, struct json_object *json)
a856a8
+{
a856a8
+	DEFiRet;
a856a8
+
a856a8
+	struct json_object_iterator it = json_object_iter_begin(existing);
a856a8
+	struct json_object_iterator itEnd = json_object_iter_end(existing);
a856a8
+	while (!json_object_iter_equal(&it, &itEnd)) {
a856a8
+		json_object_object_add(json, json_object_iter_peek_name(&it),
a856a8
+			json_object_get(json_object_iter_peek_value(&it)));
a856a8
+		json_object_iter_next(&it);
a856a8
+	}
a856a8
+
a856a8
+	CHKiRet(jsonMerge(existing, json));
a856a8
+finalize_it:
a856a8
+	RETiRet;
a856a8
+}
a856a8
+
a856a8
+
a856a8
 static rsRetVal
a856a8
 jsonMerge(struct json_object *existing, struct json_object *json)
a856a8
 {
a856a8
@@ -4714,7 +4735,7 @@ msgAddJSON(msg_t * const pM, uchar *name, struct json_object *json, int force_re
a856a8
 		if(*pjroot == NULL)
a856a8
 			*pjroot = json;
a856a8
 		else
a856a8
-			CHKiRet(jsonMerge(*pjroot, json));
a856a8
+			CHKiRet(jsonMergeNonOverwrite(*pjroot, json));
a856a8
 	} else {
a856a8
 		if(*pjroot == NULL) {
a856a8
 			/* now we need a root obj */
a856a8
@@ -4742,7 +4763,7 @@ msgAddJSON(msg_t * const pM, uchar *name, struct json_object *json, int force_re
a856a8
 			json_object_object_add(parent, (char*)leaf, json);
a856a8
 		} else {
a856a8
 			if(json_object_get_type(json) == json_type_object) {
a856a8
-				CHKiRet(jsonMerge(*pjroot, json));
a856a8
+				CHKiRet(jsonMergeNonOverwrite(*pjroot, json));
a856a8
 			} else {
a856a8
 				/* TODO: improve the code below, however, the current
a856a8
 				 *       state is not really bad */
a856a8
-- 
a856a8
2.7.4
a856a8