diff --git a/runtime/msg.c b/runtime/msg.c index f10a77a64..8a1502929 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -1350,6 +1350,11 @@ MsgDeserialize(smsg_t * const pMsg, strm_t *pStrm) reinitVar(pVar); CHKiRet(objDeserializeProperty(pVar, pStrm)); } + if(isProp("pszStrucData")) { + MsgSetStructuredData(pMsg, (char*) rsCStrGetSzStrNoNULL(pVar->val.pStr)); + reinitVar(pVar); + CHKiRet(objDeserializeProperty(pVar, pStrm)); + } if(isProp("json")) { tokener = json_tokener_new(); pMsg->json = json_tokener_parse_ex(tokener, (char*)rsCStrGetSzStrNoNULL(pVar->val.pStr), @@ -1366,11 +1371,6 @@ MsgDeserialize(smsg_t * const pMsg, strm_t *pStrm) reinitVar(pVar); CHKiRet(objDeserializeProperty(pVar, pStrm)); } - if(isProp("pszStrucData")) { - MsgSetStructuredData(pMsg, (char*) rsCStrGetSzStrNoNULL(pVar->val.pStr)); - reinitVar(pVar); - CHKiRet(objDeserializeProperty(pVar, pStrm)); - } if(isProp("pCSAPPNAME")) { MsgSetAPPNAME(pMsg, (char*) rsCStrGetSzStrNoNULL(pVar->val.pStr)); reinitVar(pVar); @@ -1401,8 +1401,10 @@ MsgDeserialize(smsg_t * const pMsg, strm_t *pStrm) * but on the other hand it works decently AND we will probably replace * the whole persisted format soon in any case. -- rgerhards, 2012-11-06 */ - if(!isProp("offMSG")) + if(!isProp("offMSG")) { + DBGPRINTF("error property: %s\n", rsCStrGetSzStrNoNULL(pVar->pcsName)); ABORT_FINALIZE(RS_RET_DS_PROP_SEQ_ERR); + } MsgSetMSGoffs(pMsg, pVar->val.num); finalize_it: if(pVar != NULL) diff --git a/tests/Makefile.am b/tests/Makefile.am index 1dffd5519..aee4ddfd9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -97,6 +97,7 @@ TESTS += \ daqueue-persist.sh \ daqueue-invld-qi.sh \ daqueue-dirty-shutdown.sh \ + diskq-rfc5424.sh \ diskqueue.sh \ diskqueue-fsync.sh \ rulesetmultiqueue.sh \ @@ -703,6 +704,7 @@ EXTRA_DIST= \ fieldtest.sh \ rsf_getenv.sh \ testsuites/rsf_getenv.conf \ + diskq-rfc5424.sh \ diskqueue.sh \ testsuites/diskqueue.conf \ arrayqueue.sh \ diff --git a/tests/diskq-rfc5424.sh b/tests/diskq-rfc5424.sh new file mode 100755 index 000000000..a7d61d393 --- /dev/null +++ b/tests/diskq-rfc5424.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# detect queue corruption based on invalid property bag ordering. +# Note: this mimics an issue actually seen in practice. +# Triggering condition: "json" property (message variables) are present +# and "structured-data" property is also present. Caused rsyslog to +# thrash the queue file, getting messages stuck in it and loosing all +# after the initial problem occurence. +# add 2017-02-08 by Rainer Gerhards, released under ASL 2.0 +. $srcdir/diag.sh init +. $srcdir/diag.sh generate-conf +. $srcdir/diag.sh add-conf ' +module(load="../plugins/imtcp/.libs/imtcp") +input(type="imtcp" port="13514" ruleset="rs") + + +template(name="outfmt" type="string" string="%msg:F,58:2%\n") + +ruleset(name="rs2" queue.type="disk" queue.filename="rs2_q" + queue.spoolDirectory="test-spool") { + set $!tmp=$msg; + action(type="omfile" file="rsyslog.out.log" template="outfmt") +} +ruleset(name="rs") { + set $!tmp=$msg; + call rs2 +} +' +. $srcdir/diag.sh startup +. $srcdir/diag.sh tcpflood -m1000 -y +. $srcdir/diag.sh shutdown-when-empty +. $srcdir/diag.sh wait-shutdown +. $srcdir/diag.sh seq-check 0 999 + +. $srcdir/diag.sh exit