summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-06-22 18:52:30 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-06-22 18:52:30 +0200
commitce5869f7c41c8db943d8cbe804b69af40d43e2e6 (patch)
tree5e36c1e35728021f6b067d668bf71245202e90a5 /tools
parent221dc8a3224dcb59a7dd3158716a8d24cee71618 (diff)
downloadrsyslog-ce5869f7c41c8db943d8cbe804b69af40d43e2e6.tar.gz
rsyslog-ce5869f7c41c8db943d8cbe804b69af40d43e2e6.tar.xz
rsyslog-ce5869f7c41c8db943d8cbe804b69af40d43e2e6.zip
optimized processing of TAG message field
Diffstat (limited to 'tools')
-rw-r--r--tools/syslogd.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/tools/syslogd.c b/tools/syslogd.c
index 16f08c21..ed826fc1 100644
--- a/tools/syslogd.c
+++ b/tools/syslogd.c
@@ -1173,9 +1173,9 @@ int parseLegacySyslogMsg(msg_t *pMsg, int flags)
uchar *p2parse;
char *pBuf;
char *pWork;
- cstr_t *pStrB;
- int iCnt;
int bTAGCharDetected;
+ int i; /* general index for parsing */
+ uchar bufParseTAG[CONF_TAG_MAXSIZE];
BEGINfunc
assert(pMsg != NULL);
@@ -1293,23 +1293,16 @@ int parseLegacySyslogMsg(msg_t *pMsg, int flags)
* is the max size ;) we need to shuffle the code again... Just for
* the records: the code is currently clean, but we could optimize it! */
if(!bTAGCharDetected) {
- uchar *pszTAG;
- if(cstrConstruct(&pStrB) != RS_RET_OK)
- return 1;
- rsCStrSetAllocIncrement(pStrB, 33);
- pWork = pBuf;
- iCnt = 0;
- while(*p2parse && *p2parse != ':' && *p2parse != ' ') {
- cstrAppendChar(pStrB, *p2parse++);
- ++iCnt;
+ i = 0;
+ while(*p2parse && *p2parse != ':' && *p2parse != ' ' && i < CONF_TAG_MAXSIZE) {
+ bufParseTAG[i++] = *p2parse++;
}
if(*p2parse == ':') {
++p2parse;
- cstrAppendChar(pStrB, ':');
+ bufParseTAG[i++] = ':';
}
- cstrFinalize(pStrB);
- cstrConvSzStrAndDestruct(pStrB, &pszTAG, 1);
- if(pszTAG == NULL)
+
+ if(i == 0)
{ /* rger, 2005-11-10: no TAG found - this implies that what
* we have considered to be the HOSTNAME is most probably the
* TAG. We consider it so probable, that we now adjust it
@@ -1322,7 +1315,8 @@ int parseLegacySyslogMsg(msg_t *pMsg, int flags)
moveHOSTNAMEtoTAG(pMsg);
MsgSetHOSTNAME(pMsg, getRcvFrom(pMsg));
} else { /* we have a TAG, so we can happily set it ;) */
- MsgAssignTAG(pMsg, pszTAG);
+ bufParseTAG[i] = '\0'; /* terminate string */
+ MsgSetTAG(pMsg, bufParseTAG, i);
}
} else {
/* we have no TAG, so we ... */