/* add an entry to our unacked frame list. The sendbuf object is handed over and must * no longer be accessed by the caller. * NOTE: we do not need mutex locks. This changes when we have a background transfer * thread (which we currently do not have). * rgerhards, 2008-03-20 */ relpRetVal relpSessAddUnacked(relpSess_t *pThis, relpSendbuf_t *pSendbuf) { relpSessUnacked_t *pUnackedLstEntry; ENTER_RELPFUNC; RELPOBJ_assert(pThis, Sess); RELPOBJ_assert(pSendbuf, Sendbuf); if((pUnackedLstEntry = calloc(1, sizeof(relpSessUnacked_t))) == NULL) ABORT_FINALIZE(RELP_RET_OUT_OF_MEMORY); pUnackedLstEntry->pSendbuf = pSendbuf; DLL_Add(pUnackedLstEntry, pThis->pUnackedLstRoot, pThis->pUnackedLstLast); ++pThis->lenUnackedLst; if(pThis->lenUnackedLst >= pThis->sizeWindow) { /* in theory, we would need to check if the session is initialized, as * we would mess up session state in that case. However, as the init * process is just one frame, we can never run into the situation that * the window is exhausted during init, so we do not check it. */ relpSessSetSessState(pThis, eRelpSessState_WINDOW_FULL); if(pThis->lenUnackedLst >= pThis->sizeWindow) pThis->pEngine->dbgprint("Warning: exceeding window size, max %d, curr %d\n", pThis->lenUnackedLst, pThis->sizeWindow); } pThis->pEngine->dbgprint("ADD sess %p unacked %d, sessState %d\n", pThis, pThis->lenUnackedLst, pThis->sessState); finalize_it: LEAVE_RELPFUNC; }
/* get ptr to call stack - if none exists, create a new stack */ static dbgThrdInfo_t *dbgGetThrdInfo(void) { dbgThrdInfo_t *pThrd; pthread_mutex_lock(&mutCallStack); if((pThrd = pthread_getspecific(keyCallStack)) == NULL) { /* construct object */ pThrd = calloc(1, sizeof(dbgThrdInfo_t)); pThrd->thrd = pthread_self(); (void) pthread_setspecific(keyCallStack, pThrd); DLL_Add(CallStack, pThrd); } pthread_mutex_unlock(&mutCallStack); return pThrd; }
/* constructor & add new entry to list */ dbgMutLog_t *dbgMutLogAddEntry(pthread_mutex_t *pmut, short mutexOp, dbgFuncDB_t *pFuncDB, int lockLn) { dbgMutLog_t *pLog; pLog = calloc(1, sizeof(dbgMutLog_t)); assert(pLog != NULL); /* fill data members */ pLog->mut = pmut; pLog->thrd = pthread_self(); pLog->mutexOp = mutexOp; pLog->lockLn = lockLn; pLog->pFuncDB = pFuncDB; DLL_Add(MutLog, pLog); return pLog; }