summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-11-04 15:34:31 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2009-11-04 15:34:31 +0100
commitaa2e8ea15b2001f131ebd196c180cc82aceb57b4 (patch)
tree5d285066e3ce83fc0ada6059174e6dfcd2d78632 /runtime
parentb6a92e2f23895cadf9f0ea2de64021912bd2eeb0 (diff)
downloadrsyslog-aa2e8ea15b2001f131ebd196c180cc82aceb57b4.tar.gz
rsyslog-aa2e8ea15b2001f131ebd196c180cc82aceb57b4.tar.xz
rsyslog-aa2e8ea15b2001f131ebd196c180cc82aceb57b4.zip
first complete implementation of loadable parser system
I have now done the necessary cleanup. Looks like everything is in place. Unfortunately, I do not yet have any actual parser that is not built-in, but I think we can postpone working on that when the first one appears. I don't expect troubles in that case, but you never know ;)
Diffstat (limited to 'runtime')
-rw-r--r--runtime/parser.c56
-rw-r--r--runtime/parser.h1
-rw-r--r--runtime/ruleset.c3
3 files changed, 58 insertions, 2 deletions
diff --git a/runtime/parser.c b/runtime/parser.c
index 0689657f..38f72986 100644
--- a/runtime/parser.c
+++ b/runtime/parser.c
@@ -85,6 +85,27 @@ InitParserList(parserList_t **pListRoot)
}
+/* destruct a parser list. The list elements are destroyed, but the parser objects
+ * themselves are not modified. (That is done at a late stage during rsyslogd
+ * shutdown and need not be considered here.)
+ */
+static rsRetVal
+DestructParserList(parserList_t **ppListRoot)
+{
+ parserList_t *pParsLst;
+ parserList_t *pParsLstDel;
+
+ pParsLst = *ppListRoot;
+ while(pParsLst != NULL) {
+ pParsLstDel = pParsLst;
+ pParsLst = pParsLst->pNext;
+ free(pParsLstDel);
+ }
+ *ppListRoot = NULL;
+ return RS_RET_OK;
+}
+
+
/* Add a parser to the list. We use a VERY simple and ineffcient algorithm,
* but it is employed only for a few milliseconds during config processing. So
* I prefer to keep it very simple and with simple data structures. Unfortunately,
@@ -143,7 +164,6 @@ finalize_it:
/* --- END helper functions for parser list handling --- */
-
/* Add a an already existing parser to the default list. As usual, order
* of calls is important (most importantly, that means the legacy parser,
* which can process everything, MUST be added last!).
@@ -186,8 +206,8 @@ finalize_it:
BEGINobjDestruct(parser) /* be sure to specify the object type also in END and CODESTART macros! */
CODESTARTobjDestruct(parser)
+ dbgprintf("destructing parser '%s'\n", pThis->pName);
free(pThis->pName);
- //TODO: free module!
ENDobjDestruct(parser)
@@ -581,6 +601,7 @@ CODESTARTobjQueryInterface(parser)
pIf->ParseMsg = ParseMsg;
pIf->SanitizeMsg = SanitizeMsg;
pIf->InitParserList = InitParserList;
+ pIf->DestructParserList = DestructParserList;
pIf->AddParserToList = AddParserToList;
pIf->AddDfltParser = AddDfltParser;
pIf->FindParser = FindParser;
@@ -602,6 +623,37 @@ resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unus
return RS_RET_OK;
}
+/* This destroys the master parserlist and all of its parser entries. MUST only be
+ * done when the module is shut down. Parser modules are NOT unloaded, rsyslog
+ * does that at a later stage for all dynamically loaded modules.
+ */
+static void
+destroyMasterParserList(void)
+{
+ parserList_t *pParsLst;
+ parserList_t *pParsLstDel;
+
+ pParsLst = pParsLstRoot;
+ while(pParsLst != NULL) {
+ parserDestruct(&pParsLst->pParser);
+ pParsLstDel = pParsLst;
+ pParsLst = pParsLst->pNext;
+ free(pParsLstDel);
+ }
+}
+
+/* Exit our class.
+ * rgerhards, 2009-11-04
+ */
+BEGINObjClassExit(parser, OBJ_IS_CORE_MODULE) /* class, version */
+ DestructParserList(&pDfltParsLst);
+ destroyMasterParserList();
+ objRelease(glbl, CORE_COMPONENT);
+ objRelease(errmsg, CORE_COMPONENT);
+ objRelease(datetime, CORE_COMPONENT);
+ objRelease(ruleset, CORE_COMPONENT);
+ENDObjClassExit(parser)
+
/* Initialize the parser class. Must be called as the very first method
* before anything else is called inside this class.
diff --git a/runtime/parser.h b/runtime/parser.h
index a92b9920..c4f63021 100644
--- a/runtime/parser.h
+++ b/runtime/parser.h
@@ -54,6 +54,7 @@ BEGINinterface(parser) /* name must also be changed in ENDinterface macro! */
rsRetVal (*SetDoPRIParsing)(parser_t *pThis, int);
rsRetVal (*FindParser)(parser_t **ppThis, uchar*name);
rsRetVal (*InitParserList)(parserList_t **pListRoot);
+ rsRetVal (*DestructParserList)(parserList_t **pListRoot);
rsRetVal (*AddParserToList)(parserList_t **pListRoot, parser_t *pParser);
/* static functions */
rsRetVal (*ParseMsg)(msg_t *pMsg);
diff --git a/runtime/ruleset.c b/runtime/ruleset.c
index bfcb520f..1a77be2b 100644
--- a/runtime/ruleset.c
+++ b/runtime/ruleset.c
@@ -350,6 +350,9 @@ CODESTARTobjDestruct(ruleset)
if(pThis->pQueue != NULL) {
qqueueDestruct(&pThis->pQueue);
}
+ if(pThis->pParserLst != NULL) {
+ parser.DestructParserList(&pThis->pParserLst);
+ }
llDestroy(&pThis->llRules);
free(pThis->pszName);
ENDobjDestruct(ruleset)