From f547af1f86b489faaf16b4a040df5ebd3c974af5 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Wed, 30 Jan 2008 08:28:33 +0000 Subject: finally implemented infinite action retries via -1 retry count --- action.c | 26 +++++++++++++------------- cfsysline.c | 13 ++++++++++++- syslogd.c | 1 + 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/action.c b/action.c index d60e2d77..9dfe16bb 100644 --- a/action.c +++ b/action.c @@ -345,10 +345,19 @@ actionCallDoAction(action_t *pAction, msg_t *pMsg) iRetries = 0; do { -RUNLOG_STR("going into do_action call loop"); +RUNLOG_VAR("%d", iRet); + /* on first invocation, this if should never be true. We just put it at the top + * of the loop so that processing (and code) is simplified. This code is actually + * triggered on the 2nd+ invocation. -- rgerhards, 2008-01-30 + */ + if(iRet == RS_RET_SUSPENDED) { + /* ok, this calls for our retry logic... */ + ++iRetries; + iSleepPeriod = pAction->iResumeInterval; + srSleep(iSleepPeriod, 0); + } RUNLOG_VAR("%d", iRetries); /* first check if we are suspended and, if so, retry */ - ASSERT(pAction != NULL); if(actionIsSuspended(pAction)) { dbgprintf("action %p is suspended\n", pAction); iRet = actionTryResume(pAction); @@ -360,17 +369,8 @@ RUNLOG_STR("calling configured action\n"); iRet = pAction->pMod->mod.om.doAction(pAction->ppMsgs, 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_VAR("%d", pAction->iResumeRetryCount); + } while(iRet == RS_RET_SUSPENDED && (pAction->iResumeRetryCount == -1 || iRetries < pAction->iResumeRetryCount)); /* do...while! */ RUNLOG_STR("out of retry loop"); if(iRet == RS_RET_DISABLE_ACTION) { diff --git a/cfsysline.c b/cfsysline.c index 50d0066b..c87c2a54 100644 --- a/cfsysline.c +++ b/cfsysline.c @@ -103,9 +103,10 @@ finalize_it: */ static rsRetVal parseIntVal(uchar **pp, size_t *pVal) { - uchar *p; DEFiRet; + uchar *p; size_t i; + int bWasNegative; assert(pp != NULL); assert(*pp != NULL); @@ -114,6 +115,13 @@ static rsRetVal parseIntVal(uchar **pp, size_t *pVal) skipWhiteSpace(pp); /* skip over any whitespace */ p = *pp; + if(*p == '-') { + bWasNegative = 1; + ++p; /* eat it */ + } else { + bWasNegative = 0; + } + if(!isdigit((int) *p)) { errno = 0; logerror("invalid number"); @@ -124,6 +132,9 @@ static rsRetVal parseIntVal(uchar **pp, size_t *pVal) for(i = 0 ; *p && isdigit((int) *p) ; ++p) i = i * 10 + *p - '0'; + if(bWasNegative) + i *= -1; + *pVal = i; *pp = p; diff --git a/syslogd.c b/syslogd.c index b4983513..ed59f0d5 100644 --- a/syslogd.c +++ b/syslogd.c @@ -3435,6 +3435,7 @@ static rsRetVal cflineProcessTradPRIFilter(uchar **pline, register selector_t *f } if (pri < 0) { +dbgPrintAllDebugInfo(); snprintf((char*) xbuf, sizeof(xbuf), "unknown priority name \"%s\"", buf); logerror((char*) xbuf); return RS_RET_ERR; -- cgit