summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2013-11-01 18:17:30 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2013-11-01 18:17:30 +0100
commitfbfc3984633113ac7e4e018afb3d10cb8a3d3e50 (patch)
tree89ef719f12a37ac4d5306c6b021f009b327b40ef
parent7c74c432a7547f9ea49626b6966fe1e63e919439 (diff)
downloadrsyslog-fbfc3984633113ac7e4e018afb3d10cb8a3d3e50.tar.gz
rsyslog-fbfc3984633113ac7e4e018afb3d10cb8a3d3e50.tar.bz2
rsyslog-fbfc3984633113ac7e4e018afb3d10cb8a3d3e50.zip
refactor: move action resume retry counter to wti_t
-rw-r--r--action.c7
-rw-r--r--action.h3
-rw-r--r--runtime/wti.h19
3 files changed, 24 insertions, 5 deletions
diff --git a/action.c b/action.c
index d1014f35..69479bad 100644
--- a/action.c
+++ b/action.c
@@ -613,7 +613,8 @@ static inline void actionSuspend(action_t *pThis, wti_t *pWti)
* since caching, and this would break logic (and it actually did so!)
*/
datetime.GetTime(&ttNow);
- pThis->ttResumeRtry = ttNow + pThis->iResumeInterval * (pThis->iNbrResRtry / 10 + 1);
+ pThis->ttResumeRtry = ttNow + pThis->iResumeInterval *
+ (getActionNbrResRtry(pWti, pThis) / 10 + 1);
actionSetState(pThis, pWti, ACT_STATE_SUSP);
DBGPRINTF("action suspended, earliest retry=%d\n", (int) pThis->ttResumeRtry);
}
@@ -665,7 +666,7 @@ actionDoRetry(action_t *pThis, wti_t *pWti, int *pbShutdownImmediate)
if((pThis->iResumeRetryCount != -1 && iRetries >= pThis->iResumeRetryCount)) {
actionSuspend(pThis, pWti);
} else {
- ++pThis->iNbrResRtry;
+ incActionNbrResRtry(pWti, pThis);
++iRetries;
iSleepPeriod = pThis->iResumeInterval;
srSleep(iSleepPeriod, 0);
@@ -679,7 +680,7 @@ actionDoRetry(action_t *pThis, wti_t *pWti, int *pbShutdownImmediate)
}
if(getActionState(pWti, pThis) == ACT_STATE_RDY) {
- pThis->iNbrResRtry = 0;
+ setActionNbrResRtry(pWti, pThis, 0);
}
finalize_it:
diff --git a/action.h b/action.h
index 176af319..50191032 100644
--- a/action.h
+++ b/action.h
@@ -50,7 +50,6 @@ struct action_s {
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 */
int iNbrNoExec; /* number of matches that did not yet yield to an exec */
int iExecEveryNthOccur;/* execute this action only every n-th occurence (with n=0,1 -> always) */
int iExecEveryNthOccurTO;/* timeout for n-th occurence feature */
@@ -68,7 +67,7 @@ struct action_s {
* in this order. */
qqueue_t *pQueue; /* action queue */
pthread_mutex_t mutAction; /* primary action mutex */
- uchar *pszName; /* action name (for documentation) */
+ uchar *pszName; /* action name */
DEF_ATOMIC_HELPER_MUT(mutCAS);
/* for statistics subsystem */
statsobj_t *statsobj;
diff --git a/runtime/wti.h b/runtime/wti.h
index 3758c62d..0cb3dc9c 100644
--- a/runtime/wti.h
+++ b/runtime/wti.h
@@ -46,6 +46,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 */
+ int iNbrResRtry; /* number of retries since last suspend */
struct {
unsigned actState : 3;
} flags;
@@ -115,4 +116,22 @@ incActionResumeInRow(wti_t *pWti, action_t *pAction)
{
pWti->actWrkrInfo[pAction->iActionNbr].uResumeOKinRow++;
}
+
+static inline int
+getActionNbrResRtry(wti_t *pWti, action_t *pAction)
+{
+ return(pWti->actWrkrInfo[pAction->iActionNbr].iNbrResRtry);
+}
+
+static inline void
+setActionNbrResRtry(wti_t *pWti, action_t *pAction, uint16_t val)
+{
+ pWti->actWrkrInfo[pAction->iActionNbr].iNbrResRtry = val;
+}
+
+static inline void
+incActionNbrResRtry(wti_t *pWti, action_t *pAction)
+{
+ pWti->actWrkrInfo[pAction->iActionNbr].iNbrResRtry++;
+}
#endif /* #ifndef WTI_H_INCLUDED */