summaryrefslogtreecommitdiffstats
path: root/action.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-01-28 16:05:11 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-01-28 16:05:11 +0000
commitad2f1c7e6d806203a6cdca8cf6ea99380c3b2b88 (patch)
treecab86071e8c87243ce19fa768b7b3b874a36654c /action.c
parent6780beb633929cb174fc109531b47362ac487f21 (diff)
downloadrsyslog-ad2f1c7e6d806203a6cdca8cf6ea99380c3b2b88.tar.gz
rsyslog-ad2f1c7e6d806203a6cdca8cf6ea99380c3b2b88.tar.xz
rsyslog-ad2f1c7e6d806203a6cdca8cf6ea99380c3b2b88.zip
implemented the $ActionResumeRetryCount config directive
Diffstat (limited to 'action.c')
-rw-r--r--action.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/action.c b/action.c
index 2410c76e..2154fba2 100644
--- a/action.c
+++ b/action.c
@@ -36,10 +36,12 @@
#include "action.h"
#include "modules.h"
#include "sync.h"
+#include "srUtils.h"
/* object static data (once for all instances) */
static int glbliActionResumeInterval = 30;
+int glbliActionResumeRetryCount = 0; /* how often should suspended actions be retried? */
/* destructs an action descriptor object
* rgerhards, 2007-08-01
@@ -80,6 +82,7 @@ rsRetVal actionConstruct(action_t **ppThis)
}
pThis->iResumeInterval = glbliActionResumeInterval;
+ pThis->iResumeRetryCount = glbliActionResumeRetryCount;
SYNC_OBJ_TOOL_INIT(pThis);
finalize_it:
@@ -191,6 +194,69 @@ rsRetVal actionDbgPrint(action_t *pThis)
}
+/* call the DoAction output plugin entry point
+ * rgerhards, 2008-01-28
+ */
+rsRetVal
+actionCallDoAction(action_t *pAction)
+{
+ DEFiRet;
+ int iRetries;
+ int i;
+ int iSleepPeriod;
+
+ assert(pAction != NULL);
+
+ /* here we must loop to process all requested strings */
+ for(i = 0 ; i < pAction->iNumTpls ; ++i) {
+ CHKiRet(tplToString(pAction->ppTpl[i], pAction->f_pMsg, &pAction->ppMsgs[i]));
+ }
+
+ iRetries = 0;
+ do {
+RUNLOG_STR("going into do_action call loop");
+RUNLOG_VAR("%d", iRetries);
+ /* call configured action */
+ iRet = pAction->pMod->mod.om.doAction(pAction->ppMsgs, pAction->f_pMsg->msgFlags, pAction->pModData);
+RUNLOG_VAR("%d", iRet);
+ if(iRet == RS_RET_SUSPENDED) {
+ /* ok, this calls for our retry logic... */
+ ++iRetries;
+ iSleepPeriod = pAction->iResumeInterval;
+RUNLOG_VAR("%d", iSleepPeriod);
+ srSleep(iSleepPeriod, 0);
+ } else {
+ break; /* we are done in any case */
+ }
+ } while(pAction->iResumeRetryCount == -1 || iRetries < pAction->iResumeRetryCount); /* do...while! */
+RUNLOG_STR("out of retry loop");
+
+ if(iRet == RS_RET_DISABLE_ACTION) {
+ dbgprintf("Action requested to be disabled, done that.\n");
+ pAction->bEnabled = 0; /* that's it... */
+ }
+
+ if(iRet == RS_RET_SUSPENDED) {
+ dbgprintf("Action requested to be suspended, done that.\n");
+ actionSuspend(pAction);
+ }
+
+ if(iRet == RS_RET_OK)
+ pAction->f_prevcount = 0; /* message processed, so we start a new cycle */
+
+finalize_it:
+ /* cleanup */
+ for(i = 0 ; i < pAction->iNumTpls ; ++i) {
+ if(pAction->ppMsgs[i] != NULL) {
+ free(pAction->ppMsgs[i]);
+ pAction->ppMsgs[i] = NULL;
+ }
+ }
+
+ RETiRet;
+}
+
+
/*
* vi:set ai:
*/