action: refactor worker instance table handling

This commit is contained in:
Rainer Gerhards 2015-03-31 17:28:53 +02:00
parent d849fd6d88
commit 09522af762
3 changed files with 19 additions and 13 deletions

View File

@ -1347,6 +1347,23 @@ processBatchMain(void *__restrict__ const pVoid,
} }
/* remove an action worker instance from our table of
* workers. To be called from worker handler (wti).
*/
void
actionRemoveWorker(action_t *const __restrict__ pAction,
void *const __restrict__ actWrkrData)
{
pAction->nWrkr--;
for(int w = 0 ; w < pAction->wrkrDataTableSize ; ++w) {
if(pAction->wrkrDataTable[w] == actWrkrData) {
pAction->wrkrDataTable[w] = NULL;
break; /* done */
}
}
}
/* call the HUP handler for a given action, if such a handler is defined. /* call the HUP handler for a given action, if such a handler is defined.
* Note that the action must be able to service HUP requests concurrently * Note that the action must be able to service HUP requests concurrently
* to any current doAction() processing. * to any current doAction() processing.

View File

@ -102,6 +102,7 @@ rsRetVal activateActions(void);
rsRetVal actionNewInst(struct nvlst *lst, action_t **ppAction); rsRetVal actionNewInst(struct nvlst *lst, action_t **ppAction);
rsRetVal actionProcessCnf(struct cnfobj *o); rsRetVal actionProcessCnf(struct cnfobj *o);
void actionCommitAllDirect(wti_t *pWti); void actionCommitAllDirect(wti_t *pWti);
void actionRemoveWorker(action_t *const pAction, void *const actWrkrData);
/* external data */ /* external data */
extern int iActionNbr; extern int iActionNbr;

View File

@ -356,19 +356,7 @@ wtiWorker(wti_t *__restrict__ const pThis)
dbgprintf("wti %p, action %d, ptr %p\n", pThis, i, wrkrInfo->actWrkrData); dbgprintf("wti %p, action %d, ptr %p\n", pThis, i, wrkrInfo->actWrkrData);
if(wrkrInfo->actWrkrData != NULL) { if(wrkrInfo->actWrkrData != NULL) {
pAction = wrkrInfo->pAction; pAction = wrkrInfo->pAction;
actionRemoveWorker(pAction, wrkrInfo->actWrkrData);
// TODO: move this to action.c/h
pAction->nWrkr--;
for(int w = 0 ; w < pAction->wrkrDataTableSize ; ++w) {
if(pAction->wrkrDataTable[w] == wrkrInfo->actWrkrData) {
pAction->wrkrDataTable[w] = NULL;
break; /* done */
}
}
DBGPRINTF("wti %p: action %d now has %d workers\n",
pThis, pAction->iActionNbr, pAction->nWrkr);
// end TODO
pAction->pMod->mod.om.freeWrkrInstance(wrkrInfo->actWrkrData); pAction->pMod->mod.om.freeWrkrInstance(wrkrInfo->actWrkrData);
if(pAction->isTransactional) { if(pAction->isTransactional) {
/* free iparam "cache" - we need to go through to max! */ /* free iparam "cache" - we need to go through to max! */