Blame SOURCES/rsyslog-8.24.0-msg_c_nonoverwrite_merge.patch

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