diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2009-07-20 08:58:03 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2009-07-20 08:58:03 +0200 |
commit | 01acb7928e4e72b08279da15d376adff9c3c3840 (patch) | |
tree | 1b176ee8f3b6e304db72386ca5a4872c1dcbdf88 /runtime/wtp.c | |
parent | 88132c79f1e75edb2caf5d3f9ad1685834785be7 (diff) | |
download | rsyslog-01acb7928e4e72b08279da15d376adff9c3c3840.tar.gz rsyslog-01acb7928e4e72b08279da15d376adff9c3c3840.tar.xz rsyslog-01acb7928e4e72b08279da15d376adff9c3c3840.zip |
some more threading changes
... as well as some cleanup
Diffstat (limited to 'runtime/wtp.c')
-rw-r--r-- | runtime/wtp.c | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/runtime/wtp.c b/runtime/wtp.c index 46b5f4bb..4d4d0f0e 100644 --- a/runtime/wtp.c +++ b/runtime/wtp.c @@ -157,20 +157,6 @@ CODESTARTobjDestruct(wtp) ENDobjDestruct(wtp) -/* wake up at least one worker thread. - * rgerhards, 2008-01-20 - */ -rsRetVal -wtpWakeupWrkr(wtp_t *pThis) -{ - DEFiRet; - - /* TODO; mutex? I think not needed, as we do not need predictable exec order -- rgerhards, 2008-01-28 */ - ISOBJ_TYPE_assert(pThis, wtp); - pthread_cond_signal(pThis->pcondBusy); - RETiRet; -} - /* wake up all worker threads. * rgerhards, 2008-01-16 */ @@ -239,7 +225,9 @@ finalize_it: #pragma GCC diagnostic ignored "-Wempty-body" /* Send a shutdown command to all workers and see if they terminate. - * A timeout may be specified. + * A timeout may be specified. This function may also be called with + * the current number of workers being 0, in which case it does not + * shut down any worker. * rgerhards, 2008-01-14 */ rsRetVal @@ -383,8 +371,6 @@ wtpStartWrkr(wtp_t *pThis, int bLockMutex) BEGIN_MTX_PROTECTED_OPERATIONS(&pThis->mutWtp, bLockMutex); - pThis->iCurNumWrkThrd++; - /* find free spot in thread table. */ for(i = 0 ; i < pThis->iNumWorkerThreads ; ++i) { if(wtiGetState(pThis->pWrkr[i]) == WRKTHRD_STOPPED) { @@ -395,6 +381,8 @@ wtpStartWrkr(wtp_t *pThis, int bLockMutex) if(i == pThis->iNumWorkerThreads) ABORT_FINALIZE(RS_RET_NO_MORE_THREADS); + pThis->iCurNumWrkThrd++; /* we got one more! */ + pWti = pThis->pWrkr[i]; wtiSetState(pWti, WRKTHRD_RUNNING); pthread_attr_init(&attr); @@ -445,7 +433,7 @@ wtpAdviseMaxWorkers(wtp_t *pThis, int nMaxWrkr) } } else { if(nMaxWrkr > 0) { - wtpWakeupWrkr(pThis); + pthread_cond_signal(pThis->pcondBusy); } } |