summaryrefslogtreecommitdiffstats
path: root/runtime/wtp.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2013-11-07 12:57:36 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2013-11-07 12:57:36 +0100
commitfb81cf202c0277f48c75f777fa47e4db4e59f0a3 (patch)
tree804c7265d82e0bb7127b31a9a7d68cc4b616e279 /runtime/wtp.c
parentec32919ca05598f11f538060c406d8668a35e229 (diff)
parent9035771b7dbea738b8a22949a7f0a6514525fafb (diff)
downloadrsyslog-fb81cf202c0277f48c75f777fa47e4db4e59f0a3.tar.gz
rsyslog-fb81cf202c0277f48c75f777fa47e4db4e59f0a3.tar.bz2
rsyslog-fb81cf202c0277f48c75f777fa47e4db4e59f0a3.zip
Merge branch 'master' into master-ruleeng
Conflicts: runtime/wti.c runtime/wti.h
Diffstat (limited to 'runtime/wtp.c')
-rw-r--r--runtime/wtp.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/runtime/wtp.c b/runtime/wtp.c
index 1b960eb9..66942e6b 100644
--- a/runtime/wtp.c
+++ b/runtime/wtp.c
@@ -235,9 +235,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);
@@ -457,7 +457,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);
@@ -477,7 +477,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++;
+ }
+ }
}
@@ -492,7 +498,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*))