summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2007-12-17 09:42:03 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2007-12-17 09:42:03 +0000
commit83c6a060be679722cefc531eaec40771ba5a3f21 (patch)
treecce8747ddb453151d478115f0da284114cc0a0cc
parentb5d69df3af01cf722f11c560c67cfa6b2b7cf765 (diff)
downloadrsyslog-83c6a060be679722cefc531eaec40771ba5a3f21.tar.gz
rsyslog-83c6a060be679722cefc531eaec40771ba5a3f21.tar.xz
rsyslog-83c6a060be679722cefc531eaec40771ba5a3f21.zip
implemented $MarkMessagePeriod config directive
-rw-r--r--module-template.h23
-rw-r--r--modules.c1
-rw-r--r--modules.h1
-rw-r--r--plugins/immark/immark.c14
-rw-r--r--rsyslog.h1
-rw-r--r--syslogd.c13
6 files changed, 44 insertions, 9 deletions
diff --git a/module-template.h b/module-template.h
index a0994d08..4dbb5a2c 100644
--- a/module-template.h
+++ b/module-template.h
@@ -378,6 +378,8 @@ static rsRetVal queryEtryPt(uchar *name, rsRetVal (**pEtryPoint)())\
*pEtryPoint = runInput;\
} else if(!strcmp((char*) name, "getTermSyncType")) {\
*pEtryPoint = modGetTermSyncType;\
+ } else if(!strcmp((char*) name, "willRun")) {\
+ *pEtryPoint = willRun;\
}
/* modInit()
@@ -469,6 +471,27 @@ static rsRetVal runInput(thrdInfo_t *pThrd)\
return iRet;\
}
+
+/* willRun()
+ * This is a function that will be replaced in the longer term. It is used so
+ * that a module can tell the caller if it will run or not. This is to be replaced
+ * when we introduce input module instances. However, these require config syntax
+ * changes and I may (or may not... ;)) hold that until another config file
+ * format is available. -- rgerhards, 2007-12-17
+ * returns RS_RET_NO_RUN if it will not run (RS_RET_OK or error otherwise)
+ */
+#define BEGINwillRun \
+static rsRetVal willRun(void)\
+{\
+ DEFiRet;
+
+#define CODESTARTwillRun
+
+#define ENDwillRun \
+ return iRet;\
+}
+
+
/* method to return which termination sync method is used by this module.
*/
#define TERM_SYNC_TYPE(x) \
diff --git a/modules.c b/modules.c
index 02ec366b..5381a036 100644
--- a/modules.c
+++ b/modules.c
@@ -259,6 +259,7 @@ rsRetVal doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)())
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"getTermSyncType", &modGetTermSyncType));
CHKiRet((iRet = (*modGetTermSyncType)(&pNew->mod.im.eTermSyncType)) != RS_RET_OK);
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"runInput", &pNew->mod.im.runInput));
+ CHKiRet((*pNew->modQueryEtryPt)((uchar*)"willRun", &pNew->mod.im.willRun));
break;
case eMOD_OUT:
CHKiRet((*pNew->modQueryEtryPt)((uchar*)"doAction", &pNew->mod.om.doAction));
diff --git a/modules.h b/modules.h
index 276d20c7..83fa641f 100644
--- a/modules.h
+++ b/modules.h
@@ -79,6 +79,7 @@ typedef struct moduleInfo {
struct {/* data for input modules */
eTermSyncType_t eTermSyncType;
rsRetVal (*runInput)(thrdInfo_t*); /* function to gather input and submit to queue */
+ rsRetVal (*willRun)(void); /* function to gather input and submit to queue */
} im;
struct {/* data for output modules */
/* below: perform the configured action
diff --git a/plugins/immark/immark.c b/plugins/immark/immark.c
index 72750e65..bb074d5c 100644
--- a/plugins/immark/immark.c
+++ b/plugins/immark/immark.c
@@ -46,9 +46,8 @@ MODULE_TYPE_INPUT
TERM_SYNC_TYPE(eTermSync_SIGNAL)
/* Module static data */
-/* TODO: this needs a lot of work ;) */
DEF_OMOD_STATIC_DATA
-static int bDoMarkMessages = 1;
+static int iMarkMessagePeriod = 5;
typedef struct _instanceData {
} instanceData;
@@ -77,7 +76,7 @@ CODESTARTrunInput
* if a cleanup is needed. But for now, we can just use CHKiRet().
* rgerhards, 2007-12-17
*/
- CHKiRet(thrdSleep(pThrd, 5, 0)); /* seconds, micro seconds */
+ CHKiRet(thrdSleep(pThrd, iMarkMessagePeriod, 0)); /* seconds, micro seconds */
logmsgInternal(LOG_INFO, "-- MARK --", ADDDATE);
//logmsgInternal(LOG_INFO, "-- MARK --", ADDDATE|MARK);
}
@@ -86,6 +85,13 @@ finalize_it:
ENDrunInput
+BEGINwillRun
+CODESTARTwillRun
+ if(iMarkMessagePeriod == 0)
+ iRet = RS_RET_NO_RUN;
+ENDwillRun
+
+
BEGINfreeInstance
CODESTARTfreeInstance
ENDfreeInstance
@@ -111,7 +117,7 @@ BEGINmodInit()
CODESTARTmodInit
*ipIFVersProvided = 1; /* so far, we only support the initial definition */
CODEmodInit_QueryRegCFSLineHdlr
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"markmessages", 0, eCmdHdlrBinary, NULL, &bDoMarkMessages, STD_LOADABLE_MODULE_ID));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"markmessageperiod", 0, eCmdHdlrInt, NULL, &iMarkMessagePeriod, STD_LOADABLE_MODULE_ID));
ENDmodInit
#endif /* #if 0 */
/*
diff --git a/rsyslog.h b/rsyslog.h
index 7499df28..1f18f10c 100644
--- a/rsyslog.h
+++ b/rsyslog.h
@@ -94,6 +94,7 @@ enum rsRetVal_ /** return value. All methods return this if not specified oth
RS_RET_MALICIOUS_ENTITY = -2021, /**< there is an malicious entity involved */
RS_RET_OK_DELETE_LISTENTRY = 1, /**< operation successful, but callee requested the deletion of an entry (special state) */
RS_RET_TERMINATE_NOW = 2, /**< operation successful, function is requested to terminate (mostly used with threads) */
+ RS_RET_NO_RUN = 3, /**< operation successful, but function does not like to be executed */
RS_RET_OK = 0 /**< operation successful */
};
typedef enum rsRetVal_ rsRetVal; /**< friendly type for global return value */
diff --git a/syslogd.c b/syslogd.c
index 953beb59..e24a4029 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -4214,13 +4214,16 @@ startInputModules(void)
/* loop through all modules and activate them (brr...) */
pMod = modGetNxtType(NULL, eMOD_IN);
while(pMod != NULL) {
- /* activate here */
-dbgprintf("thread creating...\n");
- thrdCreate(pMod->mod.im.runInput, pMod->mod.im.eTermSyncType);
- pMod = modGetNxtType(pMod, eMOD_IN);
+ if((iRet = pMod->mod.im.willRun()) == RS_RET_OK) {
+ /* activate here */
+ thrdCreate(pMod->mod.im.runInput, pMod->mod.im.eTermSyncType);
+ } else {
+ dbgprintf("module %lx will not run, iRet %d\n", (unsigned long) pMod, iRet);
+ }
+ pMod = modGetNxtType(pMod, eMOD_IN);
}
- return iRet;
+ return RS_RET_OK; /* intentional: we do not care about module errors */
}