diff options
author | Michael Biebl <biebl@debian.org> | 2014-03-13 17:57:11 +0100 |
---|---|---|
committer | Michael Biebl <biebl@debian.org> | 2014-03-13 17:57:11 +0100 |
commit | 29867b5cc18d25191fbbdcc4af4f79cc3a4da43e (patch) | |
tree | 1ffedd33b2a2e167aeb4b01a6c5c72aeb98a1b90 /runtime/wtp.c | |
parent | 5fccf771f37973a2cea543fbdf1ed94ed9706faf (diff) | |
download | rsyslog-29867b5cc18d25191fbbdcc4af4f79cc3a4da43e.tar.gz |
Imported Upstream version 7.6.1upstream/7.6.1
Diffstat (limited to 'runtime/wtp.c')
-rw-r--r-- | runtime/wtp.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/runtime/wtp.c b/runtime/wtp.c index 19151e7..895c1ff 100644 --- a/runtime/wtp.c +++ b/runtime/wtp.c @@ -233,9 +233,9 @@ wtpShutdownAll(wtp_t *pThis, wtpState_t tShutdownCmd, struct timespec *ptTimeout /* lock mutex to prevent races (may otherwise happen during idle processing and such...) */ d_pthread_mutex_lock(pThis->pmutUsr); wtpSetState(pThis, tShutdownCmd); - pthread_cond_broadcast(pThis->pcondBusy); /* wake up all workers */ /* awake workers in retry loop */ for(i = 0 ; i < pThis->iNumWorkerThreads ; ++i) { + pthread_cond_signal(&pThis->pWrkr[i]->pcondBusy); wtiWakeupThrd(pThis->pWrkr[i]); } d_pthread_mutex_unlock(pThis->pmutUsr); @@ -455,7 +455,7 @@ wtpAdviseMaxWorkers(wtp_t *pThis, int nMaxWrkr) { DEFiRet; int nMissing; /* number workers missing to run */ - int i; + int i, nRunning; ISOBJ_TYPE_assert(pThis, wtp); @@ -475,7 +475,13 @@ wtpAdviseMaxWorkers(wtp_t *pThis, int nMaxWrkr) CHKiRet(wtpStartWrkr(pThis)); } } else { - pthread_cond_signal(pThis->pcondBusy); + /* we have needed number of workers, but they may be sleeping */ + for(i = 0, nRunning = 0; i < pThis->iNumWorkerThreads && nRunning < nMaxWrkr; ++i) { + if (wtiGetState(pThis->pWrkr[i]) != WRKTHRD_STOPPED) { + pthread_cond_signal(&pThis->pWrkr[i]->pcondBusy); + nRunning++; + } + } } @@ -490,7 +496,6 @@ DEFpropSetMeth(wtp, wtpState, wtpState_t) DEFpropSetMeth(wtp, iNumWorkerThreads, int) DEFpropSetMeth(wtp, pUsr, void*) DEFpropSetMethPTR(wtp, pmutUsr, pthread_mutex_t) -DEFpropSetMethPTR(wtp, pcondBusy, pthread_cond_t) DEFpropSetMethFP(wtp, pfChkStopWrkr, rsRetVal(*pVal)(void*, int)) DEFpropSetMethFP(wtp, pfRateLimiter, rsRetVal(*pVal)(void*)) DEFpropSetMethFP(wtp, pfGetDeqBatchSize, rsRetVal(*pVal)(void*, int*)) |