diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2010-06-04 12:45:31 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2010-06-04 12:45:31 +0200 |
commit | d9e64c16e52357bae1eb00fc8403c4e63d6365ca (patch) | |
tree | 9a37b8395ff1e8996950328696054b24ddffd564 /runtime | |
parent | 527bfcea5c9ca5c8414620a022f097d4e53af784 (diff) | |
download | rsyslog-d9e64c16e52357bae1eb00fc8403c4e63d6365ca.tar.gz rsyslog-d9e64c16e52357bae1eb00fc8403c4e63d6365ca.tar.xz rsyslog-d9e64c16e52357bae1eb00fc8403c4e63d6365ca.zip |
finshed implementation of strgen modules
and also provided four build-in modules for the most common use
cases, hopefully resulting in a speedup of around 5% for typical
rsyslog processing.
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/modules.h | 6 | ||||
-rw-r--r-- | runtime/msg.c | 9 | ||||
-rw-r--r-- | runtime/msg.h | 7 | ||||
-rw-r--r-- | runtime/rsyslog.h | 6 | ||||
-rw-r--r-- | runtime/strgen.c | 14 |
5 files changed, 17 insertions, 25 deletions
diff --git a/runtime/modules.h b/runtime/modules.h index 4ba6411e..49586e8d 100644 --- a/runtime/modules.h +++ b/runtime/modules.h @@ -124,7 +124,7 @@ struct modInfo_s { rsRetVal (*parse)(msg_t*); } pm; struct { /* data for strgen modules */ - rsRetVal (*strgen)(msg_t*, uchar* pBuf); + rsRetVal (*strgen)(msg_t*, uchar**, size_t *); } sm; } mod; void *pModHdlr; /* handler to the dynamic library holding the module */ @@ -136,6 +136,7 @@ struct modInfo_s { # endif }; + /* interfaces */ BEGINinterface(module) /* name must also be changed in ENDinterface macro! */ modInfo_t *(*GetNxt)(modInfo_t *pThis); @@ -158,7 +159,4 @@ PROTOTYPEObj(module); /* TODO: remove them below (means move the config init code) -- rgerhards, 2008-02-19 */ extern uchar *pModDir; /* read-only after startup */ - #endif /* #ifndef MODULES_H_INCLUDED */ -/* vi:set ai: - */ diff --git a/runtime/msg.c b/runtime/msg.c index 97d65e00..dc354947 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -1257,7 +1257,8 @@ static int getPRIi(msg_t *pM) /* Get PRI value in text form */ -static inline char *getPRI(msg_t *pM) +char * +getPRI(msg_t *pM) { /* PRI is a number in the range 0..191. Thus, we use a simple lookup table to obtain the * string value. It looks a bit clumpsy here in code ;) @@ -1272,8 +1273,8 @@ static inline char *getPRI(msg_t *pM) } -//static inline char *getTimeReported(msg_t *pM, enum tplFormatTypes eFmt) -char *getTimeReported(msg_t *pM, enum tplFormatTypes eFmt) +char * +getTimeReported(msg_t *pM, enum tplFormatTypes eFmt) { BEGINfunc if(pM == NULL) @@ -1289,7 +1290,6 @@ char *getTimeReported(msg_t *pM, enum tplFormatTypes eFmt) datetime.formatTimestamp3164(&pM->tTIMESTAMP, pM->pszTIMESTAMP3164, (eFmt == tplFmtRFC3164BuggyDate)); } -dbgprintf("getTimeReported will return buffer %p\n", pM->pszTIMESTAMP3164); MsgUnlock(pM); return(pM->pszTIMESTAMP3164); case tplFmtMySQLDate: @@ -1693,7 +1693,6 @@ static inline void tryEmulateTAG(msg_t *pM, sbool bLockMutex) } -//static inline void void getTAG(msg_t *pM, uchar **ppBuf, int *piLen) { diff --git a/runtime/msg.h b/runtime/msg.h index 97cac62f..d42f1de2 100644 --- a/runtime/msg.h +++ b/runtime/msg.h @@ -112,8 +112,8 @@ struct msg { uchar *pszTAG; /* pointer to tag value */ uchar szBuf[CONF_TAG_BUFSIZE]; } TAG; - char pszTimestamp3164[16]; - char pszTimestamp3339[33]; + char pszTimestamp3164[CONST_LEN_TIMESTAMP_3164 + 1]; + char pszTimestamp3339[CONST_LEN_TIMESTAMP_3339 + 1]; char pszTIMESTAMP_SecFrac[7]; /* Note: a pointer is 64 bits/8 char, so this is actually fewer than a pointer! */ char pszRcvdAt_SecFrac[7]; /* same as above. Both are fractional seconds for their respective timestamp */ }; @@ -167,6 +167,9 @@ char *textpri(char *pRes, size_t pResLen, int pri); rsRetVal msgGetMsgVar(msg_t *pThis, cstr_t *pstrPropName, var_t **ppVar); rsRetVal MsgEnableThreadSafety(void); uchar *getRcvFrom(msg_t *pM); +void getTAG(msg_t *pM, uchar **ppBuf, int *piLen); +char *getTimeReported(msg_t *pM, enum tplFormatTypes eFmt); +char *getPRI(msg_t *pMsg); /* TODO: remove these five (so far used in action.c) */ diff --git a/runtime/rsyslog.h b/runtime/rsyslog.h index 0e5b1ad4..6a717403 100644 --- a/runtime/rsyslog.h +++ b/runtime/rsyslog.h @@ -27,6 +27,12 @@ #define INCLUDED_RSYSLOG_H /* ############################################################# * + * # Some constant values # * + * ############################################################# */ +#define CONST_LEN_TIMESTAMP_3164 15 /* number of chars (excluding \0!) in a RFC3164 timestamp */ +#define CONST_LEN_TIMESTAMP_3339 32 /* number of chars (excluding \0!) in a RFC3339 timestamp */ + +/* ############################################################# * * # Config Settings # * * ############################################################# */ #define RS_STRINGBUF_ALLOC_INCREMENT 128 diff --git a/runtime/strgen.c b/runtime/strgen.c index b8270be9..46be1236 100644 --- a/runtime/strgen.c +++ b/runtime/strgen.c @@ -235,16 +235,6 @@ finalize_it: ENDobjQueryInterface(strgen) - -/* Reset config variables to default values. - * rgerhards, 2007-07-17 - */ -static rsRetVal -resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unused)) *pVal) -{ - return RS_RET_OK; -} - /* This destroys the master strgenlist and all of its strgen entries. MUST only be * done when the module is shut down. Strgen modules are NOT unloaded, rsyslog * does that at a later stage for all dynamically loaded modules. @@ -284,10 +274,6 @@ BEGINObjClassInit(strgen, 1, OBJ_IS_CORE_MODULE) /* class, version */ CHKiRet(objUse(glbl, CORE_COMPONENT)); CHKiRet(objUse(errmsg, CORE_COMPONENT)); CHKiRet(objUse(ruleset, CORE_COMPONENT)); - - //CHKiRet(regCfSysLineHdlr((uchar *)"escapecontrolcharactertab", 0, eCmdHdlrBinary, NULL, &bEscapeTab, NULL)); - //CHKiRet(regCfSysLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL, NULL)); - InitStrgenList(&pStrgenLstRoot); ENDObjClassInit(strgen) |