diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2013-11-01 17:34:38 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2013-11-01 17:34:38 +0100 |
commit | 8c46d7129373eb462ab9e8cc837cc899440f785d (patch) | |
tree | 83374699aeb0be57412e962aa8a6fffbfa605e15 | |
parent | bf11ace45ac4eadb904fa2503e404e21a3738896 (diff) | |
download | rsyslog-8c46d7129373eb462ab9e8cc837cc899440f785d.tar.gz rsyslog-8c46d7129373eb462ab9e8cc837cc899440f785d.tar.bz2 rsyslog-8c46d7129373eb462ab9e8cc837cc899440f785d.zip |
refactor: move handling too-frequent tryResume == OK to wti_t
-rw-r--r-- | action.c | 12 | ||||
-rw-r--r-- | action.h | 1 | ||||
-rw-r--r-- | runtime/wti.h | 18 |
3 files changed, 24 insertions, 7 deletions
@@ -581,7 +581,7 @@ static void actionCommitted(action_t *pThis, wti_t *pWti) static void actionRetry(action_t *pThis, wti_t *pWti) { actionSetState(pThis, pWti, ACT_STATE_RTRY); - pThis->iResumeOKinRow++; + incActionResumeInRow(pWti, pThis); } @@ -648,9 +648,9 @@ actionDoRetry(action_t *pThis, wti_t *pWti, int *pbShutdownImmediate) DBGPRINTF("actionDoRetry: enter loop, iRetries=%d\n", iRetries); iRet = pThis->pMod->tryResume(pThis->pModData); DBGPRINTF("actionDoRetry: action->tryResume returned %d\n", iRet); - if((pThis->iResumeOKinRow > 9) && (pThis->iResumeOKinRow % 10 == 0)) { + if((getActionResumeInRow(pWti, pThis) > 9) && (getActionResumeInRow(pWti, pThis) % 10 == 0)) { bTreatOKasSusp = 1; - pThis->iResumeOKinRow = 0; + setActionResumeInRow(pWti, pThis, 0); } else { bTreatOKasSusp = 0; } @@ -940,16 +940,16 @@ actionCallDoAction(action_t *pThis, msg_t *pMsg, void *actParams, wti_t *pWti) switch(iRet) { case RS_RET_OK: actionCommitted(pThis, pWti); - pThis->iResumeOKinRow = 0; /* we had a successful call! */ + setActionResumeInRow(pWti, pThis, 0); break; case RS_RET_DEFER_COMMIT: - pThis->iResumeOKinRow = 0; /* we had a successful call! */ + setActionResumeInRow(pWti, pThis, 0); /* we are done, action state remains the same */ break; case RS_RET_PREVIOUS_COMMITTED: /* action state remains the same, but we had a commit. */ pThis->bHadAutoCommit = 1; - pThis->iResumeOKinRow = 0; /* we had a successful call! */ + setActionResumeInRow(pWti, pThis, 0); break; case RS_RET_SUSPENDED: actionRetry(pThis, pWti); @@ -48,7 +48,6 @@ struct action_s { int iSecsExecOnceInterval; /* if non-zero, minimum seconds to wait until action is executed again */ sbool bHadAutoCommit; /* did an auto-commit happen during doAction()? */ time_t ttResumeRtry; /* when is it time to retry the resume? */ - int iResumeOKinRow; /* number of times in a row that resume said OK with an immediate failure following */ 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 */ diff --git a/runtime/wti.h b/runtime/wti.h index 53f1c9fd..35e854a9 100644 --- a/runtime/wti.h +++ b/runtime/wti.h @@ -39,6 +39,7 @@ typedef struct actWrkrInfo { action_t *pAction; void *actWrkrData; + uint16_t uResumeOKinRow;/* number of times in a row that resume said OK with an immediate failure following */ struct { unsigned actState : 3; } flags; @@ -85,4 +86,21 @@ setActionState(wti_t *pWti, action_t *pAction, uint8_t newState) pWti->actWrkrInfo[pAction->iActionNbr].flags.actState = newState; } +static inline uint16_t +getActionResumeInRow(wti_t *pWti, action_t *pAction) +{ + return(pWti->actWrkrInfo[pAction->iActionNbr].uResumeOKinRow); +} + +static inline void +setActionResumeInRow(wti_t *pWti, action_t *pAction, uint16_t val) +{ + pWti->actWrkrInfo[pAction->iActionNbr].uResumeOKinRow = val; +} + +static inline void +incActionResumeInRow(wti_t *pWti, action_t *pAction) +{ + pWti->actWrkrInfo[pAction->iActionNbr].uResumeOKinRow++; +} #endif /* #ifndef WTI_H_INCLUDED */ |