ClRcT clLogClientInstall(void) { ClEoExecutionObjT* pEoObj = NULL; ClRcT rc = CL_OK; rc = clEoMyEoObjectGet(&pEoObj); if (CL_OK != rc) { return rc; } rc = clEoClientInstallTables(pEoObj,CL_EO_SERVER_SYM_MOD(gAspFuncTable,Log)); if (CL_OK != rc) { return rc; } rc = clOsalTaskKeyCreate(&LogidlSyncKey,NULL); if (CL_OK != rc) { return rc; } rc = clHandleDatabaseCreate(NULL,&LogidlDatabaseHdl); return rc; }
/* Library initialize function. Not reentrant! Creates GMS handle database */ ClRcT clGmsLibInitialize(void) { ClRcT rc = CL_OK; ClEoExecutionObjT *eo = NULL; if (lib_initialized == CL_FALSE) { if (gmsHandleDb == CL_HANDLE_INVALID_VALUE) { rc = clHandleDatabaseCreate(gms_handle_instance_destructor, &gmsHandleDb); if (rc != CL_OK) { goto error_exit; } } /* * FIXME: On the long run, when multiple EOs can exist in same process, * the following function installation may be devorced from the lib * initialization, so that it can be called multiple times. */ rc = clEoMyEoObjectGet(&eo); if (rc != CL_OK) { goto error_exit; } rc = clGmsClientRmdTableInstall(eo); if (rc != CL_OK) { if ((clEoClientUninstall( eo , CL_GMS_CLIENT_TABLE_ID )) != CL_OK) { clLogError(GEN,NA, "\nclEoClientUninstall failed"); } goto error_exit; } rc = clGmsClientClientTableRegistrer(eo); if (rc != CL_OK) { return rc; } rc = clGmsClientTableRegister(eo); if (rc != CL_OK) { return rc; } lib_initialized = CL_TRUE; } error_exit: return rc; }
ClRcT clLogSvrEoDataInit(ClLogSvrEoDataT *pSvrEoEntry, ClLogSvrCommonEoDataT *pSvrCommonEoEntry) { ClRcT rc = CL_OK; CL_LOG_DEBUG_TRACE(("Enter")); pSvrEoEntry->hSvrStreamTable = CL_HANDLE_INVALID_VALUE; pSvrEoEntry->nextDsId = CL_LOG_DSID_START; rc = clOsalMutexInit_L(&pSvrEoEntry->svrStreamTableLock); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clOsalMutexCreate(): rc[0x %x]", rc)); return rc; } rc = clBitmapCreate(&pSvrEoEntry->hDsIdMap, pSvrCommonEoEntry->maxStreams); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clBitmapCreate(): rc[0x %x]", rc)); CL_LOG_CLEANUP(clOsalMutexDestroy_L(&pSvrEoEntry->svrStreamTableLock), CL_OK); return rc; } rc = clHandleDatabaseCreate(NULL, &pSvrEoEntry->hFlusherDB); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clHandleDatabaseCreate(): rc[0x %x]", rc)); CL_LOG_CLEANUP(clBitmapDestroy(pSvrEoEntry->hDsIdMap), CL_OK); CL_LOG_CLEANUP(clOsalMutexDestroy_L(&pSvrEoEntry->svrStreamTableLock), CL_OK); return rc; } rc = clLogConfigDataGet(NULL, NULL, NULL, &pSvrEoEntry->maxFlushLimit); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clLogConfigDataGet(): rc[0x %x]", rc)); CL_LOG_CLEANUP(clHandleDatabaseDestroy(pSvrEoEntry->hFlusherDB), CL_OK); CL_LOG_CLEANUP(clBitmapDestroy(pSvrEoEntry->hDsIdMap), CL_OK); CL_LOG_CLEANUP(clOsalMutexDestroy_L(&pSvrEoEntry->svrStreamTableLock), CL_OK); return rc; } pSvrEoEntry->hCpm = CL_HANDLE_INVALID_VALUE; pSvrEoEntry->logCompId = 0; pSvrEoEntry->gmsInit = CL_FALSE; pSvrEoEntry->evtInit = CL_FALSE; pSvrEoEntry->ckptInit = CL_FALSE; pSvrEoEntry->logInit = CL_FALSE; pSvrEoEntry->hTimer = CL_FALSE; CL_LOG_DEBUG_TRACE(("Exit")); return rc; }
/* * clDispatchLibInitialize function initiates the dispatch library. The * handle databse is created here. It is called only once in the life * time of the application, and hence it is expected to be called by * EO */ ClRcT clDispatchLibInitialize(void) { ClRcT rc = CL_OK; if (databaseHandle != CL_HANDLE_INVALID_VALUE) { return CL_ERR_INITIALIZED; } /* Create the handle database */ rc = clHandleDatabaseCreate(clDispatchHandleDestructor, &databaseHandle); return rc; }
/****************************************************************************** Static Functions *******************************************************************************/ static ClRcT clAmsLibInitialize(void) { ClRcT rc = CL_OK; ClEoExecutionObjT *eo; if (lib_initialized == CL_FALSE) { if ( (rc = clHandleDatabaseCreate( ams_handle_instance_destructor, &handle_database)) != CL_OK ) goto error_exit; /* * XXX: On the long run, when multiple EOs can exist in same process, * the following function installation may be devorced from the lib * initialization, so that it can be called multiple times. */ if ( ( rc = clEoMyEoObjectGet( &eo)) != CL_OK ) goto error_exit; if ( ( rc = clEoClientInstall( eo, CL_AMS_CLIENT_TABLE_ID, cl_ams_client_callback_list, /* * cdata passsed to each function call */ 0, (int)(sizeof(cl_ams_client_callback_list)/ sizeof(ClEoPayloadWithReplyCallbackT)))) != CL_OK ) goto error_exit; lib_initialized = CL_TRUE; } return CL_OK; error_exit: return CL_AMS_RC (rc); }
static ClRcT saClmLibInitialize() { ClRcT rc = CL_OK; if (isInitDone() == CL_TRUE) { /* Initialize has already happened. so just return */ return rc; } rc = clHandleDatabaseCreate(saClmHandleInstanceDestructor, &databaseHandle); if (rc != CL_OK) { clLogError("DB","CRE", "Handle database create failed with rc 0x%x\n",rc); } return rc; }
ClRcT clMsgQueueInitialize(void) { ClRcT rc, retCode; rc = clHandleDatabaseCreate(NULL, &gClMsgQDatabase); if(rc != CL_OK) { clLogError("QUE", "INI", "Failed to create a Queue Handle database. error code [0x%x].", rc); goto error_out; } rc = clOsalMutexInit(&gClLocalQsLock); if(rc != CL_OK) { clLogError("QUE", "INI", "Failed to initialize the \"all local queues' lock\". error code [0x%x].", rc); goto error_out_1; } rc = clOsalMutexInit(&gClQueueDbLock); if(rc != CL_OK) { clLogError("QUE", "INI", "Failed to initialize queue db mutex. error code [0x%x].", rc); goto error_out_2; } goto out; error_out_2: retCode = clOsalMutexDestroy(&gClLocalQsLock); if(retCode != CL_OK) clLogError("QUE", "INI", "Failed to destroy the local queues' mutex. error code [0x%x].", retCode); error_out_1: retCode = clHandleDatabaseDestroy(gClMsgQDatabase); if(retCode != CL_OK) clLogError("QUE", "INI", "Failed to delete the Queue Handle database. error code [0x%x].", retCode); error_out: out: return rc; }
static ClRcT initializeAmf(void) { ClRcT rc = CL_OK; ClRcT retCode; ClIocPhysicalAddressT notificationForComp = { CL_IOC_BROADCAST_ADDRESS, 0}; clLogCompName = (ClCharT*) "MSG"; /* Override generated eo name with a short name for our server */ clAppConfigure(&clEoConfig,clEoBasicLibs,clEoClientLibs); clMsgRegisterWithCpm(); if(gClMsgInit == CL_TRUE) { rc = CL_MSG_RC(CL_ERR_INITIALIZED); clLogError("MSG", "INI", "The Message Service is already initialized. error code [0x%x].", rc); goto error_out; } gLocalAddress = clIocLocalAddressGet(); gLocalPortId = CL_IOC_MSG_PORT; /* Initializing a database to maintain client information */ rc = clHandleDatabaseCreate((void (*)(void*))NULL, &gMsgClientHandleDb); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to initialize the handle database. error code [0x%x].", rc); goto error_out; } /* Initializing IDL for server to server and server to client communication. */ rc = clMsgCommIdlInitialize(); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to initialize the IDL. error code [0x%x].", rc); goto error_out_2; } /* Initializing a database for maintaining queues. */ rc = clMsgQueueInitialize(); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to initialize the queue databases. error code [0x%x].", rc); goto error_out_3; } rc = clMsgReceiverDatabaseInit(); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to initialize \"receiver database\". error code [0x%x].", rc); goto error_out_4; } rc = clOsalMutexInit(&gClMsgFinalizeLock); CL_ASSERT(rc == CL_OK); rc = clOsalCondInit(&gClMsgFinalizeCond); CL_ASSERT(rc == CL_OK); /* Initializing the Group-Information */ rc = clOsalMutexInit(&gClGroupDbLock); CL_ASSERT(rc == CL_OK); rc = clCpmNotificationCallbackInstall(notificationForComp, &clMsgNotificationReceiveCallback, NULL, &gMsgNotificationHandle); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to install the notification callback function. error code [0x%x].", rc); goto error_out_5; } /* Initializing the IDL generated code. */ rc = clMsgIdlClientInstall(); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to install Server Table. error code [0x%x].", rc); goto error_out_6; } rc = clMsgIdlClientTableRegister(CL_IOC_MSG_PORT); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to register Server Table. error code [0x%x].", rc); goto error_out_7; } rc = clMsgCltClientTableRegister(CL_IOC_MSG_PORT); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to register Client Table. error code [0x%x].", rc); goto error_out_8; } rc = clMsgCltSrvClientInstall(); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to install Client Server Table. error code [0x%x].", rc); goto error_out_9; } rc = clMsgCltSrvClientTableRegister(CL_IOC_MSG_PORT); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to register Client Server Table. error code [0x%x].", rc); goto error_out_10; } rc = clMsgFinalizeBlockInit(); if(rc != CL_OK) { clLogError("MSG", "INI", "Failed to initialize the msg-finalize blocker. error code [0x%x].", rc); goto error_out_11; } clMsgDebugCliRegister(); rc = clOsalTaskCreateDetached("MsgCkptInitAsync", CL_OSAL_SCHED_OTHER, CL_OSAL_THREAD_PRI_NOT_APPLICABLE, 0, clMsgCachedCkptInitAsync, NULL); CL_ASSERT(rc == CL_OK); goto out; error_out_11: retCode = clMsgCltSrvClientTableDeregister(); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to deregister Client Table. error code [0x%x].", retCode); error_out_10: retCode = clMsgCltSrvClientUninstall(); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to destroy the just opened handle database. error code [0x%x].", retCode); error_out_9: retCode = clMsgCltClientTableDeregister(); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to deregister Client Table. error code [0x%x].", retCode); error_out_8: retCode = clMsgIdlClientTableDeregister(); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to deregister Server Table. error code [0x%x].", retCode); error_out_7: retCode = clMsgIdlClientUninstall(); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to destroy the just opened handle database. error code [0x%x].", retCode); error_out_6: retCode = clCpmNotificationCallbackUninstall(&gMsgNotificationHandle); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to uninstall the notification callback function. error code [0x%x].", retCode); error_out_5: retCode = clOsalMutexDestroy(&gClGroupDbLock); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to destroy the group db mutex. error code [0x%x].", retCode); retCode = clOsalCondDestroy(&gClMsgFinalizeCond); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to destroy the finalization condition. error code [0x%x].", retCode); retCode = clOsalMutexDestroy(&gClMsgFinalizeLock); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to destroy the finalization mutex. error code [0x%x].", retCode); clMsgReceiverDatabaseFin(); error_out_4: retCode = clMsgQueueFinalize(); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to finalize the queue databases. error code [0x%x].", retCode); error_out_3: clMsgCommIdlFinalize(); error_out_2: retCode = clHandleDatabaseDestroy(gMsgClientHandleDb); if(retCode != CL_OK) clLogError("MSG", "INI", "Failed to destroy the handle database. error code [0x%x].", retCode); error_out: out: return rc; }//end of intializeAmf
ClRcT clDebugLibInitialize(void) { ClEoExecutionObjT *pEoObj = NULL; ClDebugObjT *pDebugObj = NULL; ClRcT rc = CL_OK; ClNameT compName = {0}; rc = clEoMyEoObjectGet(&pEoObj); if (CL_OK != rc) { return rc; } pDebugObj = clHeapCalloc(1, sizeof(ClDebugObjT)); if (NULL == pDebugObj) { clLogWrite(CL_LOG_HANDLE_APP,CL_LOG_CRITICAL,CL_DEBUG_LIB_CLIENT, CL_LOG_MESSAGE_0_MEMORY_ALLOCATION_FAILED); return CL_DEBUG_RC(CL_ERR_NO_MEMORY); } rc = clOsalTaskKeyCreate(&pDebugObj->debugTaskKey, NULL); if(rc != CL_OK) { CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Debug task key create returned with [%#x]\n", rc)); clHeapFree(pDebugObj); return CL_DEBUG_RC(CL_GET_ERROR_CODE(rc)); } rc = clHandleDatabaseCreate(NULL, &pDebugObj->hDebugFnDB); if( CL_OK != rc ) { CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("clHandleDatabaseCreate(): rc[0x %x]", rc)); clHeapFree(pDebugObj); return CL_DEBUG_RC(CL_ERR_NO_MEMORY); } /* Getting the compName from CPM */ rc = clCpmComponentNameGet(0, &compName); if( CL_OK != rc ) { CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("clCpmComponentNameGet(): rc[0x %x]", rc)); clLogWrite(CL_LOG_HANDLE_APP,CL_LOG_WARNING,CL_DEBUG_LIB_CLIENT, CL_LOG_MESSAGE_1_INVALID_PARAMETER, "CompNameGet is not proper"); return rc; } pDebugObj->numFunc = 0; /* Assining the compName */ memset(pDebugObj->compName, '\0', CL_DEBUG_COMP_NAME_LEN); if( compName.length < CL_DEBUG_COMP_NAME_LEN ) { memcpy(pDebugObj->compName, compName.value, compName.length); pDebugObj->compName[compName.length] = '\0'; } else { clLogWrite(CL_LOG_HANDLE_APP,CL_LOG_WARNING,CL_DEBUG_LIB_CLIENT, CL_LOG_MESSAGE_1_INVALID_PARAMETER,"CompName is Invalid"); return CL_DEBUG_RC(CL_ERR_INVALID_PARAMETER); } /* Assigning compPrompt to DEFAULT */ memset(pDebugObj->compPrompt, '\0', CL_DEBUG_COMP_PROMPT_LEN); strcpy(pDebugObj->compPrompt, "DEFAULT"); rc = clEoClientInstallTablesWithCookie( pEoObj, CL_EO_SERVER_SYM_MOD(gAspFuncTable, DEBUGCli), pDebugObj); if (CL_OK != rc) { CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("clEoClientInstall(): rc[0x %x]", rc)); clHandleDatabaseDestroy(pDebugObj->hDebugFnDB); clHeapFree(pDebugObj); return rc; } rc = clDebugClientTableRegister(pEoObj); if(CL_OK != rc) { clEoClientUninstallTables(pEoObj, CL_EO_SERVER_SYM_MOD(gAspFuncTable, DEBUGCli)); clHandleDatabaseDestroy(pDebugObj->hDebugFnDB); clHeapFree(pDebugObj); return rc; } rc = clEoPrivateDataSet(pEoObj, CL_EO_DEBUG_OBJECT_COOKIE_ID, pDebugObj); if (CL_OK != rc) { CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("clEoPrivateDataSet(): rc[0x %x]", rc)); clEoClientUninstallTables(pEoObj, CL_EO_SERVER_SYM_MOD(gAspFuncTable, DEBUGCli)); clHandleDatabaseDestroy(pDebugObj->hDebugFnDB); clHeapFree(pDebugObj); return rc; } clEoDebugRegister(); return rc; }
ClRcT clRmdObjInit(ClRmdObjHandleT *p) { ClRcT retCode = CL_OK; ClRmdObjT *pRmdObject = NULL; //unsigned long timeStamp = 0; struct timeval tm1; #ifdef DEBUG static ClUint8T rmdAddedTodbgComp = CL_FALSE; if (CL_FALSE == rmdAddedTodbgComp) { retCode = dbgAddComponent(COMP_PREFIX, COMP_NAME, COMP_DEBUG_VAR_PTR); rmdAddedTodbgComp = CL_TRUE; if (CL_OK != retCode) { clLogError("OBG","INI","dbgAddComponent FAILED "); CL_FUNC_EXIT(); return retCode; } } #endif CL_FUNC_ENTER(); if (NULL == p) { RMD_DBG1((" RMD Invalid Object handle passed\n")); CL_FUNC_EXIT(); return ((CL_RMD_RC(CL_ERR_INVALID_PARAMETER))); } retCode = clOsalInitialize(NULL); retCode = clTimerInitialize(NULL); pRmdObject = (ClRmdObjT *) clHeapAllocate(sizeof(ClRmdObjT)); if (NULL == pRmdObject) { RMD_DBG1((" RMD No Memory\n")); CL_FUNC_EXIT(); return ((CL_RMD_RC(CL_ERR_NO_MEMORY))); } gettimeofday(&tm1, NULL); //timeStamp = tm1.tv_sec * 1000000 + tm1.tv_usec; pRmdObject->msgId = 1; retCode = clOsalMutexCreate(&pRmdObject->semaForSendHashTable); if (CL_OK != CL_GET_ERROR_CODE(retCode)) { RMD_DBG1((" RMD send Mutex creation failed\n")); CL_FUNC_EXIT(); return (retCode); } retCode = clOsalMutexCreate(&pRmdObject->semaForRecvHashTable); if (CL_OK != CL_GET_ERROR_CODE(retCode)) { RMD_DBG1((" RMD recv Mutex creation failed\n")); IGNORE_RETURN(clOsalMutexDelete(pRmdObject->semaForSendHashTable)); CL_FUNC_EXIT(); return (retCode); } retCode = clCntHashtblCreate(NUMBER_OF_RECV_BUCKETS, recvKeyCompare, recvHashFunction, recvHashDeleteCallBack, recvHashDeleteCallBack, CL_CNT_UNIQUE_KEY, &pRmdObject->rcvRecContainerHandle); if (CL_OK != CL_GET_ERROR_CODE(retCode)) { RMD_DBG1((" RMD send Hash table creation failed\n")); IGNORE_RETURN(clOsalMutexDelete(pRmdObject->semaForRecvHashTable)); IGNORE_RETURN(clOsalMutexDelete(pRmdObject->semaForSendHashTable)); CL_FUNC_EXIT(); return (retCode); } retCode = clCntHashtblCreate(NUMBER_OF_SEND_BUCKETS, sendKeyCompare, sendHashFunction, sendHashDeleteCallBack, sendHashDestroyCallBack, CL_CNT_UNIQUE_KEY, &pRmdObject->sndRecContainerHandle); if (CL_OK != CL_GET_ERROR_CODE(retCode)) { RMD_DBG1((" RMD recv Hash table creation failed\n")); IGNORE_RETURN(clCntDelete(pRmdObject->rcvRecContainerHandle)); IGNORE_RETURN(clOsalMutexDelete(pRmdObject->semaForRecvHashTable)); IGNORE_RETURN(clOsalMutexDelete(pRmdObject->semaForSendHashTable)); CL_FUNC_EXIT(); return (retCode); } pRmdObject->responseCntxtDbHdl = 0; retCode = clHandleDatabaseCreate(NULL, &pRmdObject->responseCntxtDbHdl); if (retCode != CL_OK) { RMD_DBG1((" RMD Sync Handle Database create failed\n")); IGNORE_RETURN(clCntDelete(pRmdObject->sndRecContainerHandle)); IGNORE_RETURN(clCntDelete(pRmdObject->rcvRecContainerHandle)); IGNORE_RETURN(clOsalMutexDelete(pRmdObject->semaForRecvHashTable)); IGNORE_RETURN(clOsalMutexDelete(pRmdObject->semaForSendHashTable)); CL_FUNC_EXIT(); return retCode; } pRmdObject->numAtmostOnceEntry = 0; pRmdObject->lastAtmostOnceCleanupTime = clOsalStopWatchTimeGet(); pRmdObject->rmdStats.nRmdCalls = 0; pRmdObject->rmdStats.nFailedCalls = 0; pRmdObject->rmdStats.nResendRequests = 0; pRmdObject->rmdStats.nRmdReplies = 0; pRmdObject->rmdStats.nBadReplies = 0; pRmdObject->rmdStats.nRmdRequests = 0; pRmdObject->rmdStats.nBadRequests = 0; pRmdObject->rmdStats.nCallTimeouts = 0; pRmdObject->rmdStats.nDupRequests = 0; pRmdObject->rmdStats.nAtmostOnceCalls = 0; pRmdObject->rmdStats.nResendReplies = 0; pRmdObject->rmdStats.nReplySend = 0; pRmdObject->rmdStats.nRmdCallOptimized = 0; *p = (ClRmdObjHandleT) pRmdObject; CL_FUNC_EXIT(); return (CL_OK); }