ClRcT clLogClntStreamOpen(ClLogHandleT hLog, SaNameT *pStreamName, SaNameT *pNodeName, ClStringT *pShmName, ClUint32T shmSize, ClLogStreamHandleT *phStream, ClUint32T recSize) { ClRcT rc = CL_OK; ClLogClntEoDataT *pClntEoEntry = NULL; ClBoolT addedTable = CL_FALSE; ClBoolT addedEntry = CL_FALSE; ClCntNodeHandleT hClntStreamNode = CL_HANDLE_INVALID_VALUE; ClLogClntStreamDataT *pUserData = NULL; CL_LOG_DEBUG_TRACE(("Enter")); CL_LOG_PARAM_CHK((NULL == pStreamName), CL_LOG_RC(CL_ERR_NULL_POINTER)); CL_LOG_PARAM_CHK((NULL == pNodeName), CL_LOG_RC(CL_ERR_NULL_POINTER)); CL_LOG_PARAM_CHK((NULL == pShmName), CL_LOG_RC(CL_ERR_NULL_POINTER)); CL_LOG_PARAM_CHK((sizeof(ClLogStreamHeaderT) > shmSize), CL_LOG_RC(CL_ERR_INVALID_PARAMETER)); CL_LOG_PARAM_CHK((NULL == phStream), CL_LOG_RC(CL_ERR_NULL_POINTER)); rc = clLogClntEoEntryGet(&pClntEoEntry); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clLogClntEoEntryGet(): rc[0x %x]", rc)); return rc; } rc = clOsalMutexLock_L(&(pClntEoEntry->clntStreamTblLock)); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clOsalMutexLock(): rc[0x %x]", rc)); return rc; } if( CL_HANDLE_INVALID_VALUE == pClntEoEntry->hClntStreamTable ) { rc = clCntHashtblCreate(pClntEoEntry->maxStreams, clLogStreamKeyCompare, clLogStreamHashFn, clLogClntStreamDeleteCb, clLogClntStreamDeleteCb, CL_CNT_UNIQUE_KEY, &(pClntEoEntry->hClntStreamTable)); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clCntHashtblCreate(): rc[0x %x]", rc)); CL_LOG_CLEANUP( clOsalMutexUnlock_L(&(pClntEoEntry->clntStreamTblLock)),CL_OK); return rc; } addedTable = CL_TRUE; CL_LOG_DEBUG_VERBOSE(("Created the HashTable")); } rc = clLogClntStreamEntryGet(pClntEoEntry, pStreamName, pNodeName, pShmName, shmSize, &hClntStreamNode, &addedEntry); if( CL_OK != rc) { if( CL_TRUE == addedTable ) { CL_LOG_CLEANUP(clCntDelete(pClntEoEntry->hClntStreamTable), CL_OK); } CL_LOG_CLEANUP(clOsalMutexUnlock_L(&(pClntEoEntry->clntStreamTblLock)), CL_OK); return rc; } CL_LOG_DEBUG_VERBOSE(("Got the stream entry")); rc = clLogHandleStreamHandleCreate(hLog, hClntStreamNode, phStream); if( CL_OK != rc) { if( CL_TRUE == addedEntry ) { CL_LOG_CLEANUP(clCntNodeDelete(pClntEoEntry->hClntStreamTable, hClntStreamNode), CL_OK); } if( CL_TRUE == addedTable ) { CL_LOG_CLEANUP(clCntDelete(pClntEoEntry->hClntStreamTable), CL_OK); } CL_LOG_CLEANUP(clOsalMutexUnlock_L(&(pClntEoEntry->clntStreamTblLock)), CL_OK); return rc; } CL_LOG_DEBUG_VERBOSE(("Created the streamhandle")); rc = clCntNodeUserDataGet(pClntEoEntry->hClntStreamTable, hClntStreamNode, (ClCntDataHandleT *) &pUserData); if( CL_OK != rc ) { CL_LOG_CLEANUP(clHandleDestroy(pClntEoEntry->hClntHandleDB, *phStream), CL_OK); *phStream = CL_HANDLE_INVALID_VALUE; if( CL_TRUE == addedEntry ) { CL_LOG_CLEANUP(clCntNodeDelete(pClntEoEntry->hClntStreamTable, hClntStreamNode), CL_OK); } if( CL_TRUE == addedTable ) { CL_LOG_CLEANUP(clCntDelete(pClntEoEntry->hClntStreamTable), CL_OK); } CL_LOG_CLEANUP(clOsalMutexUnlock_L(&(pClntEoEntry->clntStreamTblLock)), CL_OK); return rc; } #ifdef NO_SAF pUserData->recSize=recSize; #endif CL_LOG_DEBUG_VERBOSE(("Got stream entry")); rc = clBitmapBitSet(pUserData->hStreamBitmap, CL_HDL_IDX(*phStream)); if( CL_OK != rc ) { CL_LOG_CLEANUP(clHandleDestroy(pClntEoEntry->hClntHandleDB, *phStream), CL_OK); *phStream = CL_HANDLE_INVALID_VALUE; if( CL_TRUE == addedEntry ) { CL_LOG_CLEANUP(clCntNodeDelete(pClntEoEntry->hClntStreamTable, hClntStreamNode), CL_OK); } if( CL_TRUE == addedTable ) { CL_LOG_CLEANUP(clCntDelete(pClntEoEntry->hClntStreamTable), CL_OK); } CL_LOG_CLEANUP(clOsalMutexUnlock_L(&(pClntEoEntry->clntStreamTblLock)), CL_OK); return rc; } CL_LOG_DEBUG_VERBOSE(("Updated stream bitmap")); rc = clLogHandleInitHandleStreamAdd(hLog, *phStream); if( CL_OK != rc ) { CL_LOG_CLEANUP(clBitmapBitClear(pUserData->hStreamBitmap, CL_HDL_IDX(*phStream)), CL_OK); CL_LOG_CLEANUP(clHandleDestroy(pClntEoEntry->hClntHandleDB, *phStream), CL_OK); *phStream = CL_HANDLE_INVALID_VALUE; if( CL_TRUE == addedEntry ) { CL_LOG_CLEANUP(clCntNodeDelete(pClntEoEntry->hClntStreamTable, hClntStreamNode), CL_OK); } if( CL_TRUE == addedTable ) { CL_LOG_CLEANUP(clCntDelete(pClntEoEntry->hClntStreamTable), CL_OK); } CL_LOG_CLEANUP(clOsalMutexUnlock_L(&(pClntEoEntry->clntStreamTblLock)), CL_OK); return rc; } CL_LOG_DEBUG_VERBOSE(("Updated init handle")); rc = clOsalMutexUnlock_L(&(pClntEoEntry->clntStreamTblLock)); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clOsalMutexUnlock(): rc[0x %x]", rc)); return rc; } CL_LOG_DEBUG_TRACE(("Exit")); return rc; }
ClRcT clLogFileOpen(ClLogHandleT hLog, ClCharT *fileName, ClCharT *fileLocation, ClBoolT isDelete, ClLogFileHandleT *phFile) { ClRcT rc = CL_OK; ClLogClntFileKeyT *pFileKey = NULL; ClUint32T operatingLvl = 0; ClIocAddressT address = {{0}}; ClIdlHandleT hLogIdl = CL_HANDLE_INVALID_VALUE; CL_LOG_DEBUG_TRACE(("Enter")); CL_LOG_PARAM_CHK((NULL == fileName), CL_LOG_RC(CL_ERR_NULL_POINTER)); CL_LOG_PARAM_CHK((NULL == fileLocation), CL_LOG_RC(CL_ERR_NULL_POINTER)); CL_LOG_PARAM_CHK((NULL == phFile), CL_LOG_RC(CL_ERR_NULL_POINTER)); rc = clLogHandleCheck(hLog, CL_LOG_INIT_HANDLE); if( CL_OK != rc ) { return rc; } rc = clLogClntFileKeyCreate(fileName, fileLocation, &pFileKey); if( CL_OK != rc ) { return rc; } rc = clLogFileHdlrAddressGet(&pFileKey->fileLocation, &address); if( CL_OK != rc ) { clLogClntFileKeyDestroy(pFileKey); return rc; } CL_LOG_DEBUG_ERROR(("FileOwner's Address: %d", address.iocPhyAddress.nodeAddress)); rc = clLogClntIdlHandleInitialize(address, &hLogIdl); if( CL_OK != rc ) { clLogClntFileKeyDestroy(pFileKey); return rc; } rc = VDECL_VER(clLogFileHdlrFileOpenClientSync, 4, 0, 0)(hLogIdl, &pFileKey->fileName, &pFileKey->fileLocation, &operatingLvl); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("VDECL_VER(clLogFileHdlrFileOpen, 4, 0, 0)(): rc[0x %x]", rc)); clLogClntFileKeyDestroy(pFileKey); return rc; } rc = clLogFileHdlrHandleCreate(hLog, isDelete, operatingLvl, pFileKey, phFile); if( CL_OK != rc ) { clLogClntFileKeyDestroy(pFileKey); return rc; } rc = clLogHandleInitHandleStreamAdd(hLog, *phFile); if( CL_OK != rc ) { CL_LOG_CLEANUP(clLogFileHdlrFileHandleDelete(*phFile, &hLog), CL_OK); return rc; } CL_LOG_DEBUG_TRACE(("Exit")); return rc; }