diff options
-rw-r--r-- | runtime/queue.c | 20 | ||||
-rw-r--r-- | runtime/wtp.c | 25 | ||||
-rw-r--r-- | runtime/wtp.h | 1 |
3 files changed, 10 insertions, 36 deletions
diff --git a/runtime/queue.c b/runtime/queue.c index 0ef0174e..9123a3f5 100644 --- a/runtime/queue.c +++ b/runtime/queue.c @@ -1289,17 +1289,15 @@ tryShutdownWorkersWithinActionTimeout(qqueue_t *pThis) d_pthread_mutex_lock(pThis->mut); if(pThis->bRunsDA) { d_pthread_mutex_unlock(pThis->mut); - if(wtpGetCurNumWrkr(pThis->pqDA->pWtpReg, LOCK_MUTEX) > 0) { - /* and now the same for the DA queue */ - dbgoprint((obj_t*) pThis, "trying immediate shutdown of DA queue workers\n"); - iRetLocal = wtpShutdownAll(pThis->pqDA->pWtpReg, wtpState_SHUTDOWN_IMMEDIATE, &tTimeout); - if(iRetLocal == RS_RET_TIMED_OUT) { - dbgoprint((obj_t*) pThis, "immediate shutdown timed out on DA queue (this is acceptable " - "and triggers cancellation)\n"); - } else if(iRetLocal != RS_RET_OK) { - dbgoprint((obj_t*) pThis, "unexpected iRet state %d after trying immediate shutdown of the DA " - "queue in disk save mode. Continuing, but results are unpredictable\n", iRetLocal); - } + /* and now the same for the DA queue */ + dbgoprint((obj_t*) pThis, "trying immediate shutdown of DA queue workers\n"); + iRetLocal = wtpShutdownAll(pThis->pqDA->pWtpReg, wtpState_SHUTDOWN_IMMEDIATE, &tTimeout); + if(iRetLocal == RS_RET_TIMED_OUT) { + dbgoprint((obj_t*) pThis, "immediate shutdown timed out on DA queue (this is acceptable " + "and triggers cancellation)\n"); + } else if(iRetLocal != RS_RET_OK) { + dbgoprint((obj_t*) pThis, "unexpected iRet state %d after trying immediate shutdown of the DA " + "queue in disk save mode. Continuing, but results are unpredictable\n", iRetLocal); } } else { d_pthread_mutex_unlock(pThis->mut); diff --git a/runtime/wtp.c b/runtime/wtp.c index 4d4d0f0e..e1ebcd4c 100644 --- a/runtime/wtp.c +++ b/runtime/wtp.c @@ -304,8 +304,8 @@ wtpWrkrExecCancelCleanup(void *arg) // TODO: the mutex_lock is dangerous, if we are cancelled within some function // that already has the mutex locked... d_pthread_mutex_lock(&pThis->mutWtp); - pThis->iCurNumWrkThrd--; wtiSetState(pWti, WRKTHRD_STOPPED); + pThis->iCurNumWrkThrd--; pthread_cond_signal(&pThis->condThrdTrm); /* activate anyone waiting on thread shutdown */ d_pthread_mutex_unlock(&pThis->mutWtp); @@ -463,29 +463,6 @@ DEFpropSetMethFP(wtp, pfOnWorkerStartup, rsRetVal(*pVal)(void*)) DEFpropSetMethFP(wtp, pfOnWorkerShutdown, rsRetVal(*pVal)(void*)) -/* return the current number of worker threads. - * TODO: atomic operation would bring a nice performance - * enhancemcent - * rgerhards, 2008-01-27 - */ -int -wtpGetCurNumWrkr(wtp_t *pThis, int bLockMutex) -{ - DEFVARS_mutexProtection; - int iNumWrkr; - - BEGINfunc - ISOBJ_TYPE_assert(pThis, wtp); - - BEGIN_MTX_PROTECTED_OPERATIONS(&pThis->mutWtp, bLockMutex); - iNumWrkr = pThis->iCurNumWrkThrd; - END_MTX_PROTECTED_OPERATIONS(&pThis->mutWtp); - - ENDfunc - return iNumWrkr; -} - - /* set the debug header message * The passed-in string is duplicated. So if the caller does not need * it any longer, it must free it. Must be called only before object is finalized. diff --git a/runtime/wtp.h b/runtime/wtp.h index 88683ea2..358ced3a 100644 --- a/runtime/wtp.h +++ b/runtime/wtp.h @@ -86,7 +86,6 @@ rsRetVal wtpWakeupAllWrkr(wtp_t *pThis); rsRetVal wtpCancelAll(wtp_t *pThis); rsRetVal wtpSetDbgHdr(wtp_t *pThis, uchar *pszMsg, size_t lenMsg); rsRetVal wtpShutdownAll(wtp_t *pThis, wtpState_t tShutdownCmd, struct timespec *ptTimeout); -int wtpGetCurNumWrkr(wtp_t *pThis, int bLockMutex); PROTOTYPEObjClassInit(wtp); PROTOTYPEpropSetMethFP(wtp, pfChkStopWrkr, rsRetVal(*pVal)(void*, int)); PROTOTYPEpropSetMethFP(wtp, pfRateLimiter, rsRetVal(*pVal)(void*)); |