From 7c74c432a7547f9ea49626b6966fe1e63e919439 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 1 Nov 2013 18:06:58 +0100 Subject: some debug aids & useful commments for going forward --- action.c | 12 +++++++++++- runtime/wti.h | 14 +++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/action.c b/action.c index 86c482fe..d1014f35 100644 --- a/action.c +++ b/action.c @@ -562,7 +562,8 @@ static inline void actionSetState(action_t *pThis, wti_t *pWti, uint8_t newState) { setActionState(pWti, pThis, newState); - DBGPRINTF("Action %p transitioned to state: %s\n", pThis, getActStateName(pThis, pWti)); + DBGPRINTF("Action %d transitioned to state: %s\n", + pThis->iActionNbr, getActStateName(pThis, pWti)); } /* Handles the transient commit state. So far, this is @@ -758,6 +759,7 @@ static inline rsRetVal actionPrepare(action_t *pThis, int *pbShutdownImmediate, * action state accordingly */ if(getActionState(pWti, pThis) == ACT_STATE_RDY) { +dbgprintf("DDDDD: calling beginTransaction for action %d\n", pThis->iActionNbr); iRet = pThis->pMod->mod.om.beginTransaction(pWti->actWrkrInfo[pThis->iActionNbr].actWrkrData); switch(iRet) { case RS_RET_OK: @@ -935,6 +937,7 @@ actionCallDoAction(action_t *pThis, msg_t *pMsg, void *actParams, wti_t *pWti) CHKiRet(actionCheckAndCreateWrkrInstance(pThis, pWti)); pThis->bHadAutoCommit = 0; +dbgprintf("DDDDD: calling doAction for action %d\n", pThis->iActionNbr); iRet = pThis->pMod->mod.om.doAction(actParams, pMsg->msgFlags, pWti->actWrkrInfo[pThis->iActionNbr].actWrkrData); switch(iRet) { @@ -1004,6 +1007,11 @@ finishBatch(action_t *pThis, batch_t *pBatch, wti_t *pWti) DEFiRet; ASSERT(pThis != NULL); +// Testing for new engine: +dbgprintf("DDDD: iActionNbr %d\n", iActionNbr); +for(i = 0 ; i < iActionNbr ; ++i) { + dbgprintf("DDDD: finishBatch, act %d state %u\n", i, getActionStateByNbr(pWti, i)); +} if(getActionState(pWti, pThis) == ACT_STATE_RDY) { /* we just need to flag the batch as commited */ @@ -1012,6 +1020,7 @@ finishBatch(action_t *pThis, batch_t *pBatch, wti_t *pWti) CHKiRet(actionPrepare(pThis, pBatch->pbShutdownImmediate, pWti)); if(getActionState(pWti, pThis) == ACT_STATE_ITX) { +dbgprintf("DDDDD: calling endTransaction for action %d\n", pThis->iActionNbr); iRet = pThis->pMod->mod.om.endTransaction(pWti->actWrkrInfo[pThis->iActionNbr].actWrkrData); switch(iRet) { case RS_RET_OK: @@ -1385,6 +1394,7 @@ doSubmitToActionQ(action_t *pAction, msg_t *pMsg, wti_t *pWti) { DEFiRet; + // TODO: bug? Isn't that supposed to be checked in direct mode as well??? if(getActionState(pWti, pAction) == ACT_STATE_DIED) { DBGPRINTF("action %p died, do NOT execute\n", pAction); FINALIZE; diff --git a/runtime/wti.h b/runtime/wti.h index 35e854a9..3758c62d 100644 --- a/runtime/wti.h +++ b/runtime/wti.h @@ -29,12 +29,18 @@ #include "action.h" -#define ACT_STATE_DIED 0 /* action permanently failed and now disabled - MUST BE ZERO! */ +/* TODO: check if we really need the unused value -- I think we can just use the ITX state + * when we check at "end of batch" (in wti processing). In that case, we can set RDY = 0 + * and remove unused. -- rgerhards 2013-11-01 + */ +#define ACT_STATE_UNUSED 0 /* action has not yet been used - MUST BE ZERO! */ #define ACT_STATE_RDY 1 /* action ready, waiting for new transaction */ #define ACT_STATE_ITX 2 /* transaction active, waiting for new data or commit */ #define ACT_STATE_COMM 3 /* transaction finished (a transient state) */ #define ACT_STATE_RTRY 4 /* failure occured, trying to restablish ready state */ #define ACT_STATE_SUSP 5 /* suspended due to failure (return fail until timeout expired) */ +#define ACT_STATE_DIED 6 /* action permanently failed and now disabled */ +/* note: 3 bit bit field --> highest value is 7! */ typedef struct actWrkrInfo { action_t *pAction; @@ -74,6 +80,12 @@ PROTOTYPEObjClassInit(wti); PROTOTYPEpropSetMeth(wti, pszDbgHdr, uchar*); PROTOTYPEpropSetMeth(wti, pWtp, wtp_t*); +static inline uint8_t +getActionStateByNbr(wti_t *pWti, int iActNbr) +{ + return((uint8_t) pWti->actWrkrInfo[iActNbr].flags.actState); +} + static inline uint8_t getActionState(wti_t *pWti, action_t *pAction) { -- cgit v1.2.3