summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--action.c21
-rw-r--r--action.h2
-rw-r--r--syslogd.c9
3 files changed, 29 insertions, 3 deletions
diff --git a/action.c b/action.c
index 639e5822..7d0a47d0 100644
--- a/action.c
+++ b/action.c
@@ -30,11 +30,15 @@
#include <time.h>
#include "rsyslog.h"
+#include "syslogd.h"
#include "template.h"
#include "action.h"
#include "modules.h"
+/* object static data (once for all instances) */
+static int glbliActionResumeInterval = 30;
+
/* destructs an action descriptor object
* rgerhards, 2007-08-01
*/
@@ -72,6 +76,8 @@ rsRetVal actionConstruct(action_t **ppThis)
ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
}
+ pThis->iResumeInterval = glbliActionResumeInterval;
+
finalize_it:
*ppThis = pThis;
return iRet;
@@ -91,7 +97,15 @@ static rsRetVal actionResume(action_t *pThis)
}
-#define ACTION_RESUME_INTERVAL 30 /* TODO: make this dynamic from conf file */
+/* set the global resume interval
+ */
+rsRetVal actionSetGlobalResumeInterval(int iNewVal)
+{
+ glbliActionResumeInterval = iNewVal;
+ return RS_RET_OK;
+}
+
+
/* suspend an action -- rgerhards, 2007-08-02
*/
rsRetVal actionSuspend(action_t *pThis)
@@ -100,7 +114,7 @@ rsRetVal actionSuspend(action_t *pThis)
assert(pThis != NULL);
pThis->bSuspended = 1;
- pThis->ttResumeRtry = time(NULL) + ACTION_RESUME_INTERVAL;
+ pThis->ttResumeRtry = time(NULL) + pThis->iResumeInterval;
pThis->iNbrResRtry = 0; /* tell that we did not yet retry to resume */
return iRet;
@@ -131,7 +145,7 @@ rsRetVal actionTryResume(action_t *pThis)
* CPU time. TODO: maybe a config option for that?
* rgerhards, 2007-08-02
*/
- pThis->ttResumeRtry = ttNow + ACTION_RESUME_INTERVAL * (pThis->iNbrResRtry / 10 + 1);
+ pThis->ttResumeRtry = ttNow + pThis->iResumeInterval * (pThis->iNbrResRtry / 10 + 1);
}
} else {
/* it's too early, we are still suspended --> indicate this */
@@ -159,6 +173,7 @@ rsRetVal actionDbgPrint(action_t *pThis)
pThis->pMod->dbgPrintInstInfo(pThis->pModData);
printf("\n\tInstance data: 0x%x\n", (unsigned) pThis->pModData);
printf("\tRepeatedMsgReduction: %d\n", pThis->f_ReduceRepeated);
+ printf("\tResume Interval: %d\n", pThis->iResumeInterval);
printf("\tSuspended: %d", pThis->bSuspended);
if(pThis->bSuspended) {
printf(" next retry: %u, number retries: %d", (unsigned) pThis->ttResumeRtry, pThis->iNbrResRtry);
diff --git a/action.h b/action.h
index 467404fc..e7757d73 100644
--- a/action.h
+++ b/action.h
@@ -34,6 +34,7 @@ struct action_s {
short bEnabled; /* is the related action enabled (1) or disabled (0)? */
short bSuspended; /* is the related action temporarily suspended? */
time_t ttResumeRtry; /* when is it time to retry the resume? */
+ int iResumeInterval;/* resume interval for this action */
int iNbrResRtry; /* number of retries since last suspend */
struct moduleInfo *pMod;/* pointer to output module handling this selector */
void *pModData; /* pointer to module data - contents is module-specific */
@@ -60,6 +61,7 @@ rsRetVal actionDestruct(action_t *pThis);
rsRetVal actionTryResume(action_t *pThis);
rsRetVal actionSuspend(action_t *pThis);
rsRetVal actionDbgPrint(action_t *pThis);
+rsRetVal actionSetGlobalResumeInterval(int iNewVal);
#if 1
#define actionIsSuspended(pThis) ((pThis)->bSuspended == 1)
diff --git a/syslogd.c b/syslogd.c
index d5714024..3266fe9d 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -3826,6 +3826,14 @@ finalize_it:
}
+/* set the action resume interval
+ */
+static rsRetVal setActionResumeInterval(void __attribute__((unused)) *pVal, int iNewVal)
+{
+ return actionSetGlobalResumeInterval(iNewVal);
+}
+
+
/* set the processes umask (upon configuration request)
*/
static rsRetVal setUmask(void __attribute__((unused)) *pVal, int iUmask)
@@ -5819,6 +5827,7 @@ static rsRetVal loadBuildInModules(void)
#endif
CHKiRet(regCfSysLineHdlr((uchar *)"repeatedmsgreduction", 0, eCmdHdlrBinary, NULL, &bReduceRepeatMsgs));
CHKiRet(regCfSysLineHdlr((uchar *)"actionexeconlywhenpreviousissuspended", 0, eCmdHdlrBinary, NULL, &bActExecWhenPrevSusp));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionresumeinterval", 0, eCmdHdlrInt, setActionResumeInterval, NULL));
CHKiRet(regCfSysLineHdlr((uchar *)"controlcharacterescapeprefix", 0, eCmdHdlrGetChar, NULL, &cCCEscapeChar));
CHKiRet(regCfSysLineHdlr((uchar *)"escapecontrolcharactersonreceive", 0, eCmdHdlrBinary, NULL, &bEscapeCCOnRcv));
CHKiRet(regCfSysLineHdlr((uchar *)"dropmsgswithmaliciousdnsptrrecords", 0, eCmdHdlrBinary, NULL, &bDropMalPTRMsgs));