diff options
author | Pavel Levshin <pavel@levshin.spb.ru> | 2013-11-06 18:37:47 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2013-11-06 18:37:47 +0100 |
commit | 772cba6f2e34660fa74a7e2f5ec2823a2cdb6b04 (patch) | |
tree | dd485659f80ef4cc00b28b1194a73fef0f35f5d6 /runtime/wti.c | |
parent | 6b0e236cdf3d55299de70cf41dafdefec286f103 (diff) | |
download | rsyslog-772cba6f2e34660fa74a7e2f5ec2823a2cdb6b04.tar.gz rsyslog-772cba6f2e34660fa74a7e2f5ec2823a2cdb6b04.tar.bz2 rsyslog-772cba6f2e34660fa74a7e2f5ec2823a2cdb6b04.zip |
improve worker thread pool handling
among others, make possible that workers really timeout and the pool
thus shrinks
Diffstat (limited to 'runtime/wti.c')
-rw-r--r-- | runtime/wti.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/runtime/wti.c b/runtime/wti.c index f91fb5a9..77197a95 100644 --- a/runtime/wti.c +++ b/runtime/wti.c @@ -171,6 +171,7 @@ BEGINobjDestruct(wti) /* be sure to specify the object type also in END and CODE CODESTARTobjDestruct(wti) /* actual destruction */ batchFree(&pThis->batch); + pthread_cond_destroy(&pThis->pcondBusy); DESTROY_ATOMIC_HELPER_MUT(pThis->mutIsRunning); free(pThis->pszDbgHdr); @@ -181,6 +182,7 @@ ENDobjDestruct(wti) */ BEGINobjConstruct(wti) /* be sure to specify the object type also in END macro! */ INIT_ATOMIC_HELPER_MUT(pThis->mutIsRunning); + pthread_cond_init(&pThis->pcondBusy, NULL); ENDobjConstruct(wti) @@ -249,10 +251,10 @@ doIdleProcessing(wti_t *pThis, wtp_t *pWtp, int *pbInactivityTOOccured) if(pThis->bAlwaysRunning) { /* never shut down any started worker */ - d_pthread_cond_wait(pWtp->pcondBusy, pWtp->pmutUsr); + d_pthread_cond_wait(&pThis->pcondBusy, pWtp->pmutUsr); } else { timeoutComp(&t, pWtp->toWrkShutdown);/* get absolute timeout */ - if(d_pthread_cond_timedwait(pWtp->pcondBusy, pWtp->pmutUsr, &t) != 0) { + if(d_pthread_cond_timedwait(&pThis->pcondBusy, pWtp->pmutUsr, &t) != 0) { DBGPRINTF("%s: inactivity timeout, worker terminating...\n", wtiGetDbgHdr(pThis)); *pbInactivityTOOccured = 1; /* indicate we had a timeout */ } |