diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-01-28 16:05:11 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-01-28 16:05:11 +0000 |
commit | ad2f1c7e6d806203a6cdca8cf6ea99380c3b2b88 (patch) | |
tree | cab86071e8c87243ce19fa768b7b3b874a36654c | |
parent | 6780beb633929cb174fc109531b47362ac487f21 (diff) | |
download | rsyslog-ad2f1c7e6d806203a6cdca8cf6ea99380c3b2b88.tar.gz rsyslog-ad2f1c7e6d806203a6cdca8cf6ea99380c3b2b88.tar.xz rsyslog-ad2f1c7e6d806203a6cdca8cf6ea99380c3b2b88.zip |
implemented the $ActionResumeRetryCount config directive
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | action.c | 66 | ||||
-rw-r--r-- | action.h | 9 | ||||
-rw-r--r-- | cfsysline.c | 2 | ||||
-rw-r--r-- | debug.h | 3 | ||||
-rw-r--r-- | doc/rsyslog_conf.html | 1 | ||||
-rwxr-xr-x | srUtils.c | 16 | ||||
-rwxr-xr-x | srUtils.h | 1 | ||||
-rw-r--r-- | syslogd.c | 39 |
9 files changed, 104 insertions, 34 deletions
@@ -1,5 +1,6 @@ --------------------------------------------------------------------------- Version 3.10.4 (rgerhards), 2008-01-?? +- implemented the $ActionResumeRetryCount config directive --------------------------------------------------------------------------- Version 3.10.3 (rgerhards), 2008-01-28 - fixed a bug with standard template definitions (not a big deal) - thanks @@ -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: */ @@ -28,6 +28,13 @@ #include "syslogd-types.h" #include "sync.h" +/* external data - this is to be removed when we change the action + * object interface (will happen some time..., at latest when the + * config file format is changed). -- rgerhards, 2008-01-28 + */ +extern int glbliActionResumeRetryCount; + + /* the following struct defines the action object data structure */ struct action_s { @@ -37,6 +44,7 @@ struct action_s { 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 iResumeRetryCount;/* how often shall we retry a suspended action? (-1 --> eternal) */ int iNbrResRtry; /* number of retries since last suspend */ struct moduleInfo *pMod;/* pointer to output module handling this selector */ void *pModData; /* pointer to module data - content is module-specific */ @@ -65,6 +73,7 @@ rsRetVal actionTryResume(action_t *pThis); rsRetVal actionSuspend(action_t *pThis); rsRetVal actionDbgPrint(action_t *pThis); rsRetVal actionSetGlobalResumeInterval(int iNewVal); +rsRetVal actionCallDoAction(action_t *pAction); #if 1 #define actionIsSuspended(pThis) ((pThis)->bSuspended == 1) diff --git a/cfsysline.c b/cfsysline.c index 7cbd5884..50d0066b 100644 --- a/cfsysline.c +++ b/cfsysline.c @@ -875,7 +875,7 @@ void dbgPrintCfSysLineHandlers(void) } } printf("\n"); - + ENDfunc } /* @@ -107,9 +107,12 @@ void dbgPrintAllDebugInfo(void); # define RUNLOG dbgSetExecLocation(dbgCALLStaCK_POP_POINT, __LINE__); dbgprintf("%s:%d: %s: log point\n", __FILE__, __LINE__, __func__) # define RUNLOG_VAR(fmt, x) dbgSetExecLocation(dbgCALLStaCK_POP_POINT, __LINE__);\ dbgprintf("%s:%d: %s: var '%s'[%s]: " fmt "\n", __FILE__, __LINE__, __func__, #x, fmt, x) +# define RUNLOG_STR(str) dbgSetExecLocation(dbgCALLStaCK_POP_POINT, __LINE__);\ + dbgprintf("%s:%d: %s: %s\n", __FILE__, __LINE__, __func__, str) #else # define RUNLOG # define RUNLOG_VAR(fmt, x) +# define RUNLOG_STR(str) #endif /* mutex operations */ diff --git a/doc/rsyslog_conf.html b/doc/rsyslog_conf.html index f69c80fd..929a8a0b 100644 --- a/doc/rsyslog_conf.html +++ b/doc/rsyslog_conf.html @@ -34,6 +34,7 @@ development and quite unstable...). So you have been warned ;)</p> <li><a href="rsconf1_actionresumeinterval.html">$ActionResumeInterval</a></li> <li>$AddUnixListenSocket <name-of-socket> adds additional unix socket, default none -- former -a option</li> + <li>$ActionResumeRetryCount <number> [default 0, -1 means eternal]</li> <li><a href="rsconf1_allowedsender.html">$AllowedSender</a></li> <li><a href="rsconf1_controlcharacterescapeprefix.html">$ControlCharacterEscapePrefix</a></li> <li><a href="rsconf1_debugprintcfsyslinehandlerlist.html">$DebugPrintCFSyslineHandlerList</a></li> @@ -373,6 +373,22 @@ mutexCancelCleanup(void *arg) } +/* rsSleep() - a fairly portable way to to sleep. It + * will wake up when + * a) the wake-time is over + * rgerhards, 2008-01-28 + */ +void +srSleep(int iSeconds, int iuSeconds) +{ + struct timeval tvSelectTimeout; + + BEGINfunc + tvSelectTimeout.tv_sec = iSeconds; + tvSelectTimeout.tv_usec = iuSeconds; /* micro seconds */ + select(0, NULL, NULL, NULL, &tvSelectTimeout); + ENDfunc +} /* * vi:set ai: */ @@ -69,6 +69,7 @@ int getNumberDigits(long lNum); rsRetVal timeoutComp(struct timespec *pt, long iTimeout); long timeoutVal(struct timespec *pt); void mutexCancelCleanup(void *arg); +void srSleep(int iSeconds, int iuSeconds); /* mutex operations */ /* some macros to cancel-safe lock a mutex (it will automatically be released @@ -535,6 +535,7 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __a iMainMsgQWrkMinMsgs = 100; bMainMsgQSaveOnShutdown = 1; MainMsgQueType = QUEUETYPE_FIXED_ARRAY; + glbliActionResumeRetryCount = 0; return RS_RET_OK; } @@ -2351,7 +2352,6 @@ fprintlog(action_t *pAction) msg_t *pMsgSave; /* to save current message pointer, necessary to restore it in case it needs to be updated (e.g. repeated msgs) */ DEFiRet; - int i; pMsgSave = NULL; /* indicate message poiner not saved */ /* first check if this is a regular message or the repeation of @@ -2371,10 +2371,7 @@ fprintlog(action_t *pAction) if((pMsg = MsgDup(pAction->f_pMsg)) == NULL) { /* it failed - nothing we can do against it... */ dbgprintf("Message duplication failed, dropping repeat message.\n"); - return RS_RET_ERR; - /* This return is OK. The finalizer frees strings, which are not - * yet allocated. So we can not use the finalizer. - */ + ABORT_FINALIZE(RS_RET_ERR); } /* We now need to update the other message properties. @@ -2397,36 +2394,9 @@ fprintlog(action_t *pAction) /* When we reach this point, we have a valid, non-disabled action. * So let's execute it. -- rgerhards, 2007-07-24 */ - /* 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])); - } - /* call configured action */ - iRet = pAction->pMod->mod.om.doAction(pAction->ppMsgs, pAction->f_pMsg->msgFlags, pAction->pModData); - - 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 */ + iRet = actionCallDoAction(pAction); finalize_it: - /* cleanup */ - for(i = 0 ; i < pAction->iNumTpls ; ++i) { - if(pAction->ppMsgs[i] != NULL) { - free(pAction->ppMsgs[i]); - pAction->ppMsgs[i] = NULL; - } - } - if(pMsgSave != NULL) { /* we had saved the original message pointer. That was * done because we needed to create a temporary one @@ -3158,6 +3128,8 @@ static void dbgPrintInitInfo(void) dbgprintf("Main queue watermarks: high: %d, low: %d, discard: %d, discard-severity: %d\n", iMainMsgQHighWtrMark, iMainMsgQLowWtrMark, iMainMsgQDiscardMark, iMainMsgQDiscardSeverity); /* TODO: add + iActionRetryCount = 0; + iActionRetryInterval = 30000; static int iMainMsgQtoWrkShutdown = 60000; static int iMainMsgQtoWrkMinMsgs = 100; static int iMainMsgQbSaveOnShutdown = 1; @@ -4570,6 +4542,7 @@ static rsRetVal loadBuildInModules(void) * This, I think, is the right thing to do. -- rgerhards, 2007-07-31 */ CHKiRet(regCfSysLineHdlr((uchar *)"workdirectory", 0, eCmdHdlrGetWord, NULL, &pszWorkDir, NULL)); + CHKiRet(regCfSysLineHdlr((uchar *)"actionresumeretrycount", 0, eCmdHdlrInt, NULL, &glbliActionResumeRetryCount, NULL)); CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuefilename", 0, eCmdHdlrGetWord, NULL, &pszMainMsgQFName, NULL)); CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuesize", 0, eCmdHdlrInt, NULL, &iMainMsgQueueSize, NULL)); CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuehighwatermark", 0, eCmdHdlrInt, NULL, &iMainMsgQHighWtrMark, NULL)); |