summaryrefslogtreecommitdiffstats
path: root/runtime/wti.c
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/wti.c')
-rw-r--r--runtime/wti.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/runtime/wti.c b/runtime/wti.c
index 1be008df..3b6bf1b9 100644
--- a/runtime/wti.c
+++ b/runtime/wti.c
@@ -380,6 +380,7 @@ wtiWorker(wti_t *pThis)
wtp_t *pWtp; /* our worker thread pool */
int bInactivityTOOccured = 0;
rsRetVal localRet;
+ rsRetVal terminateRet;
DEFiRet;
ISOBJ_TYPE_assert(pThis, wti);
@@ -406,15 +407,21 @@ wtiWorker(wti_t *pThis)
wtpSetInactivityGuard(pThis->pWtp, 0, LOCK_MUTEX); /* must be set before usr mutex is locked! */
BEGIN_MTX_PROTECTED_OPERATIONS(pWtp->pmutUsr, LOCK_MUTEX);
- /* first check if we are in shutdown process */
- if(wtpChkStopWrkr(pWtp, LOCK_MUTEX, MUTEX_ALREADY_LOCKED)) {
- break; /* end worker thread run */
+ /* first check if we are in shutdown process (but evaluate a bit later) */
+ terminateRet = wtpChkStopWrkr(pWtp, LOCK_MUTEX, MUTEX_ALREADY_LOCKED);
+ if(terminateRet == RS_RET_TERMINATE_NOW) {
+ // TODO: we need to free the old batch! -- rgerhards, 2009-05-26 MULTI
+ break;
}
/* try to execute and process whatever we have */
localRet = pWtp->pfDoWork(pWtp->pUsr, pThis, iCancelStateSave);
if(localRet == RS_RET_IDLE) {
+ if(terminateRet == RS_RET_TERMINATE_WHEN_IDLE) {
+ break; /* end of loop */
+ }
+
if(bInactivityTOOccured) {
/* we had an inactivity timeout in the last run and are still idle, so it is time to exit... */
break; /* end worker thread run */