diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2009-06-18 16:20:06 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2009-06-18 16:20:06 +0200 |
commit | df9012f755a305ef48037f10fcc9413406894e66 (patch) | |
tree | 1aed124ca0396ace409a5550bf39c8432ec5f15c /runtime | |
parent | f18c0ffb9a6de737d2b86b3df164ead22ac5ef58 (diff) | |
download | rsyslog-df9012f755a305ef48037f10fcc9413406894e66.tar.gz rsyslog-df9012f755a305ef48037f10fcc9413406894e66.tar.xz rsyslog-df9012f755a305ef48037f10fcc9413406894e66.zip |
slight optimization of template generation
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/msg.c | 10 | ||||
-rw-r--r-- | runtime/msg.h | 2 | ||||
-rw-r--r-- | runtime/rule.c | 4 |
3 files changed, 12 insertions, 4 deletions
diff --git a/runtime/msg.c b/runtime/msg.c index 39f2370c..67aaf250 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -1848,7 +1848,8 @@ static uchar *getNOW(eNOWType eNow) * rgerhards 2005-09-15 */ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, - cstr_t *pCSPropName, unsigned short *pbMustBeFreed) + cstr_t *pCSPropName, size_t *pPropLen, + unsigned short *pbMustBeFreed) { uchar *pName; char *pRes; /* result pointer */ @@ -2546,6 +2547,10 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, *pbMustBeFreed = 1; } + if(bufLen == -1) + bufLen = strlen(pRes); + *pPropLen = bufLen; + /*dbgprintf("MsgGetProp(\"%s\"): \"%s\"\n", pName, pRes); only for verbose debug logging */ return(pRes); } @@ -2561,6 +2566,7 @@ msgGetMsgVar(msg_t *pThis, cstr_t *pstrPropName, var_t **ppVar) { DEFiRet; var_t *pVar; + size_t propLen; uchar *pszProp = NULL; cstr_t *pstrProp; unsigned short bMustBeFreed = 0; @@ -2574,7 +2580,7 @@ msgGetMsgVar(msg_t *pThis, cstr_t *pstrPropName, var_t **ppVar) CHKiRet(var.ConstructFinalize(pVar)); /* always call MsgGetProp() without a template specifier */ - pszProp = (uchar*) MsgGetProp(pThis, NULL, pstrPropName, &bMustBeFreed); + pszProp = (uchar*) MsgGetProp(pThis, NULL, pstrPropName, &propLen, &bMustBeFreed); /* now create a string object out of it and hand that over to the var */ CHKiRet(rsCStrConstructFromszStr(&pstrProp, pszProp)); diff --git a/runtime/msg.h b/runtime/msg.h index 13c2c4ea..48c1090e 100644 --- a/runtime/msg.h +++ b/runtime/msg.h @@ -161,7 +161,7 @@ void MsgSetRawMsgWOSize(msg_t *pMsg, char* pszRawMsg); void MsgSetRawMsg(msg_t *pMsg, char* pszRawMsg, size_t lenMsg); void moveHOSTNAMEtoTAG(msg_t *pM); char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, - cstr_t *pCSPropName, unsigned short *pbMustBeFreed); + cstr_t *pCSPropName, size_t *pPropLen, unsigned short *pbMustBeFreed); char *textpri(char *pRes, size_t pResLen, int pri); rsRetVal msgGetMsgVar(msg_t *pThis, cstr_t *pstrPropName, var_t **ppVar); rsRetVal MsgEnableThreadSafety(void); diff --git a/runtime/rule.c b/runtime/rule.c index f17c524e..12494543 100644 --- a/runtime/rule.c +++ b/runtime/rule.c @@ -106,6 +106,7 @@ shouldProcessThisMessage(rule_t *pRule, msg_t *pMsg, int *bProcessMsg) unsigned short pbMustBeFreed; char *pszPropVal; int bRet = 0; + size_t propLen; vm_t *pVM = NULL; var_t *pResult = NULL; @@ -177,7 +178,8 @@ shouldProcessThisMessage(rule_t *pRule, msg_t *pMsg, int *bProcessMsg) bRet = (pResult->val.num) ? 1 : 0; } else { assert(pRule->f_filter_type == FILTER_PROP); /* assert() just in case... */ - pszPropVal = MsgGetProp(pMsg, NULL, pRule->f_filterData.prop.pCSPropName, &pbMustBeFreed); + pszPropVal = MsgGetProp(pMsg, NULL, pRule->f_filterData.prop.pCSPropName, &propLen, &pbMustBeFreed); + // TODO: optimize, we now have the length of the property! /* Now do the compares (short list currently ;)) */ switch(pRule->f_filterData.prop.operation ) { |