static ClRcT clAmsEntityTriggerRecoveryThreadDelete(void) { ClRcT rc = CL_OK; if(gClAmsEntityTriggerRecoveryCtrl.running && gClAmsEntityTriggerRecoveryCtrl.task) { clOsalMutexLock(&gClAmsEntityTriggerRecoveryCtrl.list.mutex); gClAmsEntityTriggerRecoveryCtrl.running = CL_FALSE; clOsalCondSignal(&gClAmsEntityTriggerRecoveryCtrl.list.cond); clOsalMutexUnlock(&gClAmsEntityTriggerRecoveryCtrl.list.mutex); clOsalTaskJoin(gClAmsEntityTriggerRecoveryCtrl.task); } return rc; }
ClRcT clLogFlushIntervalThreadJoin(ClLogSvrStreamDataT *pStreamData, ClOsalTaskIdT taskId) { ClRcT rc = CL_OK; rc = clOsalMutexLock_L(&pStreamData->flushIntervalMutex); if( CL_OK != rc ) { pStreamData->flushIntervalThreadStatus = CL_LOG_FLUSH_INTERVAL_STATUS_CLOSE; clLogError("SVR", "FLU", "Failed acquire the lock rc [0x %x]", rc); goto exitOnError; } if( pStreamData->flushIntervalThreadStatus != CL_LOG_FLUSH_INTERVAL_STATUS_CLOSE ) { /* still that thread is there */ pStreamData->flushIntervalThreadStatus = CL_LOG_FLUSH_INTERVAL_STATUS_CLOSE; /* Unlock & signal the thread */ clOsalCondSignal_L(&pStreamData->flushIntervalCondvar); clOsalMutexUnlock_L(&pStreamData->flushIntervalMutex); /* Join the thread*/ clLogDebug("SVR", "FLU", "Joining thread [%llu]", taskId); rc = clOsalTaskJoin(taskId); if( CL_OK != rc ) { clLogError("SVR", "FLU", "Joining flush interval thread failed rc[0x %x]" ,rc); } } else { /* Unlock & signal the thread */ clOsalMutexUnlock_L(&pStreamData->flushIntervalMutex); } /* so flushThread is done with its work, delete the mutex & taskId */ exitOnError: clOsalCondDestroy_L(&pStreamData->flushIntervalCondvar); clOsalMutexDestroy_L(&pStreamData->flushIntervalMutex); return rc; }
ClRcT clLogUtilLibFinalize(ClBoolT logLibInit) { ClRcT rc = CL_OK; /* Notify the thread to stop */ rc = clOsalMutexLock(&gLogMutex); if( CL_OK != rc ) { return rc; } gUtilLibInitialized = CL_FALSE; clLogDebugFilterFinalize(); /* * signalling to that guy to wake up */ clOsalCondSignal(&gLogCond); clOsalMutexUnlock(&gLogMutex); /* Wait till that thread finishes its own job */ clOsalTaskJoin(taskId); /* * This is hardcoded, have to find out the best way to solve this problem * once all the data have been flushed, log library will be finalized. */ if( CL_TRUE == logLibInit ) { clLogFinalize(1); } /* * just destroying provided, all initialed libraried will be * finalized by main EO function. */ clOsalCondDestroy(&gLogCond); clOsalMutexDestroy(&gLogMutex); return CL_OK; }