|
Lines 445-450
static void actionCommitted(action_t *pThis)
Link Here
|
| 445 |
static void actionRetry(action_t *pThis) |
445 |
static void actionRetry(action_t *pThis) |
| 446 |
{ |
446 |
{ |
| 447 |
actionSetState(pThis, ACT_STATE_RTRY); |
447 |
actionSetState(pThis, ACT_STATE_RTRY); |
|
|
448 |
pThis->iResumeOKinRow++; |
| 448 |
} |
449 |
} |
| 449 |
|
450 |
|
| 450 |
|
451 |
|
|
Lines 480-502
static inline void actionSuspend(action_t *pThis, time_t ttNow)
Link Here
|
| 480 |
/* actually do retry processing. Note that the function receives a timestamp so |
481 |
/* actually do retry processing. Note that the function receives a timestamp so |
| 481 |
* that we do not need to call the (expensive) time() API. |
482 |
* that we do not need to call the (expensive) time() API. |
| 482 |
* Note that we do the full retry processing here, doing the configured number of |
483 |
* Note that we do the full retry processing here, doing the configured number of |
| 483 |
* iterations. |
484 |
* iterations. -- rgerhards, 2009-05-07 |
| 484 |
* rgerhards, 2009-05-07 |
485 |
* We need to guard against module which always return RS_RET_OK from their tryResume() |
|
|
486 |
* entry point. This is invalid, but has harsh consequences: it will cause the rsyslog |
| 487 |
* engine to go into a tight loop. That obviously is not acceptable. As such, we track the |
| 488 |
* count of iterations that a tryResume returning RS_RET_OK is immediately followed by |
| 489 |
* an unsuccessful call to doAction(). If that happens more than 1,000 times, we assume |
| 490 |
* the return acutally is a RS_RET_SUSPENDED. In order to go through the various |
| 491 |
* resumption stages, we do this for every 1000 requests. This magic number 1000 may |
| 492 |
* not be the most appropriate, but it should be thought of a "if nothing else helps" |
| 493 |
* kind of facility: in the first place, the module should return a proper indication |
| 494 |
* of its inability to recover. -- rgerhards, 2010-04-26. |
| 485 |
*/ |
495 |
*/ |
| 486 |
static rsRetVal actionDoRetry(action_t *pThis, time_t ttNow) |
496 |
static rsRetVal actionDoRetry(action_t *pThis, time_t ttNow) |
| 487 |
{ |
497 |
{ |
| 488 |
int iRetries; |
498 |
int iRetries; |
| 489 |
int iSleepPeriod; |
499 |
int iSleepPeriod; |
|
|
500 |
int bTreatOKasSusp; |
| 490 |
DEFiRet; |
501 |
DEFiRet; |
| 491 |
|
502 |
|
| 492 |
ASSERT(pThis != NULL); |
503 |
ASSERT(pThis != NULL); |
| 493 |
|
504 |
|
| 494 |
iRetries = 0; |
505 |
iRetries = 0; |
| 495 |
while(pThis->eState == ACT_STATE_RTRY) { |
506 |
while(pThis->eState == ACT_STATE_RTRY) { |
|
|
507 |
dbgprintf("YYY: resume in row %d\n", pThis->iResumeOKinRow); |
| 496 |
iRet = pThis->pMod->tryResume(pThis->pModData); |
508 |
iRet = pThis->pMod->tryResume(pThis->pModData); |
| 497 |
if(iRet == RS_RET_OK) { |
509 |
if((pThis->iResumeOKinRow > 999) && (pThis->iResumeOKinRow % 1000 == 0)) { |
|
|
510 |
bTreatOKasSusp = 1; |
| 511 |
} else { |
| 512 |
bTreatOKasSusp = 0; |
| 513 |
} |
| 514 |
if((iRet == RS_RET_OK) && (!bTreatOKasSusp)) { |
| 498 |
actionSetState(pThis, ACT_STATE_RDY); |
515 |
actionSetState(pThis, ACT_STATE_RDY); |
| 499 |
} else if(iRet == RS_RET_SUSPENDED) { |
516 |
} else if(iRet == RS_RET_SUSPENDED || bTreatOKasSusp) { |
| 500 |
/* max retries reached? */ |
517 |
/* max retries reached? */ |
| 501 |
if((pThis->iResumeRetryCount != -1 && iRetries >= pThis->iResumeRetryCount)) { |
518 |
if((pThis->iResumeRetryCount != -1 && iRetries >= pThis->iResumeRetryCount)) { |
| 502 |
actionSuspend(pThis, ttNow); |
519 |
actionSuspend(pThis, ttNow); |
|
Lines 715-727
actionCallDoAction(action_t *pThis, msg_t *pMsg)
Link Here
|
| 715 |
switch(iRet) { |
732 |
switch(iRet) { |
| 716 |
case RS_RET_OK: |
733 |
case RS_RET_OK: |
| 717 |
actionCommitted(pThis); |
734 |
actionCommitted(pThis); |
|
|
735 |
pThis->iResumeOKinRow = 0; /* we had a successful call! */ |
| 718 |
break; |
736 |
break; |
| 719 |
case RS_RET_DEFER_COMMIT: |
737 |
case RS_RET_DEFER_COMMIT: |
|
|
738 |
pThis->iResumeOKinRow = 0; /* we had a successful call! */ |
| 720 |
/* we are done, action state remains the same */ |
739 |
/* we are done, action state remains the same */ |
| 721 |
break; |
740 |
break; |
| 722 |
case RS_RET_PREVIOUS_COMMITTED: |
741 |
case RS_RET_PREVIOUS_COMMITTED: |
| 723 |
/* action state remains the same, but we had a commit. */ |
742 |
/* action state remains the same, but we had a commit. */ |
| 724 |
pThis->bHadAutoCommit = 1; |
743 |
pThis->bHadAutoCommit = 1; |
|
|
744 |
pThis->iResumeOKinRow = 0; /* we had a successful call! */ |
| 725 |
break; |
745 |
break; |
| 726 |
case RS_RET_SUSPENDED: |
746 |
case RS_RET_SUSPENDED: |
| 727 |
actionRetry(pThis); |
747 |
actionRetry(pThis); |