summaryrefslogtreecommitdiffstats
path: root/action.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2010-05-17 14:24:27 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2010-05-17 14:24:27 +0200
commitaf8582e50914cfc719be1a1a80eeb81030d611c5 (patch)
tree0ece18d61b635e07c4f1f6bfeefe31a96286b2ad /action.c
parent74f8bf146546275e296a3d5af17cc4c6d0397778 (diff)
downloadrsyslog-af8582e50914cfc719be1a1a80eeb81030d611c5.tar.gz
rsyslog-af8582e50914cfc719be1a1a80eeb81030d611c5.tar.xz
rsyslog-af8582e50914cfc719be1a1a80eeb81030d611c5.zip
added new cancel-reduced action thread termination method
We now manage to cancel threads that block inside a retry loop to terminate without the need to cancel the thread. Avoiding cancellation helps keep the system complexity minimal and thus provides for better stability. This also solves some issues with improper shutdown when inside an action retry loop.
Diffstat (limited to 'action.c')
-rw-r--r--action.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/action.c b/action.c
index 7751fe0a..c8622764 100644
--- a/action.c
+++ b/action.c
@@ -503,7 +503,7 @@ static rsRetVal actionDoRetry(action_t *pThis, time_t ttNow)
ASSERT(pThis != NULL);
iRetries = 0;
- while(pThis->eState == ACT_STATE_RTRY) {
+ while((*pThis->pbShutdownImmediate == 0) && pThis->eState == ACT_STATE_RTRY) {
iRet = pThis->pMod->tryResume(pThis->pModData);
if((pThis->iResumeOKinRow > 999) && (pThis->iResumeOKinRow % 1000 == 0)) {
bTreatOKasSusp = 1;
@@ -522,6 +522,9 @@ static rsRetVal actionDoRetry(action_t *pThis, time_t ttNow)
iSleepPeriod = pThis->iResumeInterval;
ttNow += iSleepPeriod; /* not truly exact, but sufficiently... */
srSleep(iSleepPeriod, 0);
+ if(*pThis->pbShutdownImmediate) {
+ ABORT_FINALIZE(RS_RET_FORCE_TERM);
+ }
}
} else if(iRet == RS_RET_DISABLE_ACTION) {
actionDisable(pThis);
@@ -532,6 +535,7 @@ static rsRetVal actionDoRetry(action_t *pThis, time_t ttNow)
pThis->iNbrResRtry = 0;
}
+finalize_it:
RETiRet;
}
@@ -859,6 +863,7 @@ tryDoAction(action_t *pAction, batch_t *pBatch, int *pnElem, int *pbShutdownImme
i = pBatch->iDoneUpTo; /* all messages below that index are processed */
iElemProcessed = 0;
iCommittedUpTo = i;
+ pAction->pbShutdownImmediate = pbShutdownImmediate;
while(iElemProcessed <= *pnElem && i < pBatch->nElem) {
if(*pbShutdownImmediate)
ABORT_FINALIZE(RS_RET_FORCE_TERM);
@@ -920,8 +925,9 @@ submitBatch(action_t *pAction, batch_t *pBatch, int nElem, int *pbShutdownImmedi
bDone = 0;
do {
localRet = tryDoAction(pAction, pBatch, &nElem, pbShutdownImmediate);
- if(localRet == RS_RET_FORCE_TERM)
- FINALIZE;
+ if(localRet == RS_RET_FORCE_TERM) {
+ ABORT_FINALIZE(RS_RET_FORCE_TERM);
+ }
if( localRet == RS_RET_OK
|| localRet == RS_RET_PREVIOUS_COMMITTED
|| localRet == RS_RET_DEFER_COMMIT) {