ClRcT clMsgQueueStatusGet_4_0_0( SaNameT *pQName, SaMsgQueueStatusT *pQueueStatus) { ClRcT rc = CL_OK; ClMsgQueueRecordT *pQEntry; SaMsgQueueHandleT qHandle; CL_MSG_INIT_CHECK(rc); if( rc != CL_OK) { goto error_out; } CL_OSAL_MUTEX_LOCK(&gClQueueDbLock); if(clMsgQNameEntryExists(pQName, &pQEntry) == CL_FALSE) { CL_OSAL_MUTEX_UNLOCK(&gClQueueDbLock); rc = CL_MSG_RC(CL_ERR_DOESNT_EXIST); clLogError("QUE", "STAT", "Queue [%.*s] does not exist. error code [0x%x].", pQName->length, pQName->value, rc); goto error_out; } qHandle = pQEntry->qHandle; CL_OSAL_MUTEX_UNLOCK(&gClQueueDbLock); rc = clMsgQueueStatusGet(qHandle, pQueueStatus); if(rc != CL_OK) clLogTrace("QUE", "STAT", "Failed to get the status of the queue [%.*s]. error code [0x%x].", pQName->length, pQName->value, rc); error_out: return rc; }
ClRcT clMsgQueueRetentionTimeSet(SaMsgQueueHandleT qHandle, SaTimeT *pRetenTime) { ClRcT rc; ClRcT retCode; ClMsgQueueInfoT *pQInfo; CL_OSAL_MUTEX_LOCK(&gClLocalQsLock); rc = clHandleCheckout(gClMsgQDatabase, qHandle, (void **)&pQInfo); if(rc != CL_OK) { CL_OSAL_MUTEX_UNLOCK(&gClLocalQsLock); clLogError("QUE", "RET", "Failed to checkout the queue handle. error code [0x%x].", rc); goto error_out; } CL_OSAL_MUTEX_LOCK(&pQInfo->qLock); CL_OSAL_MUTEX_UNLOCK(&gClLocalQsLock); if(pQInfo->state == CL_MSG_QUEUE_CLOSED) { rc = CL_MSG_RC(CL_ERR_INVALID_HANDLE); clLogError("QUE", "RET", "Queue [%.*s] is in closed state. Cannot change retention time. error code [0x%x].", pQInfo->pQueueEntry->qName.length, pQInfo->pQueueEntry->qName.value, rc); goto error_out_1; } if(pQInfo->creationFlags != 0) { rc = CL_MSG_RC(CL_ERR_BAD_OPERATION); clLogError("QUE", "RET", "Retention time can be set for only for non-persistent queues. error code [0x%x].", rc); goto error_out_1; } pQInfo->retentionTime = *pRetenTime; error_out_1: CL_OSAL_MUTEX_UNLOCK(&pQInfo->qLock); retCode = clHandleCheckin(gClMsgQDatabase, qHandle); if(retCode != CL_OK) clLogError("QUE", "RET", "Failed to checkin queue handle. error code [0x%x].", retCode); error_out: return rc; }
static ClRcT clMsgUnblockThreadsOfQueue(ClMsgQueueInfoT *pQInfo) { ClRcT rc; if(pQInfo->numThreadsBlocked != 0) { pQInfo->numThreadsBlocked = 0; rc = clOsalCondBroadcast(pQInfo->qCondVar); } else { rc = CL_MSG_RC(CL_ERR_DOESNT_EXIST); } return rc; }
ClRcT clMsgQueueUnlinkToServer(ClNameT *pQName) { ClRcT rc; /* Look up msg queue in the cached checkpoint */ ClMsgQueueCkptDataT queueData; if(clMsgQCkptExists((ClNameT *)pQName, &queueData) == CL_FALSE) { rc = CL_MSG_RC(CL_ERR_DOESNT_EXIST); clLogError("MSG", "UNL", "Failed to get the message queue information."); goto error_out; } /* Get Ioc address of the given MSG queue */ ClIdlHandleObjT idlObj = {0}; ClIdlHandleT idlHandle = 0; memcpy(&idlObj, &gIdlUcastObj, sizeof(idlObj)); if ((queueData.creationFlags == SA_MSG_QUEUE_PERSISTENT) && (queueData.qServerAddress.nodeAddress != 0)) { idlObj.address.address.iocAddress.iocPhyAddress = queueData.qServerAddress; } rc = clIdlHandleInitialize(&idlObj, &idlHandle); if(rc != CL_OK) { clLogError("MSG", "UNL", "Failed to initialize the IDL handle. error code [0x%x].", rc); goto error_out; } rc = VDECL_VER(clMsgQueueUnlinkClientSync, 4, 0, 0)(idlHandle, (ClNameT *)pQName); if(rc != CL_OK) { clLogError("MSG", "UNL", "Failed to close the message queue at message server. error code [0x%x].", rc); } clIdlHandleFinalize(idlHandle); error_out: return rc; }
/* * Called with the msg finalize lock held. */ static int safMsgFinalize(ClBoolT *pLockStatus) { ClRcT rc = CL_OK; if(pLockStatus && !*pLockStatus) return CL_MSG_RC(CL_ERR_INVALID_STATE); CL_MSG_INIT_CHECK(rc); if( rc != CL_OK) { return rc; } gClMsgInit = CL_FALSE; if(pLockStatus) { *pLockStatus = CL_FALSE; clOsalMutexUnlock(&gClMsgFinalizeLock); } clMsgFinalizeBlocker(); rc = clMsgFinalizeBlockFin(); if(rc != CL_OK) clLogError("MSG", "INI", "Failed to cleanup the msg-finalize blocker. error code [0x%x].", rc); clMsgDebugCliDeregister(); clMsgCommIdlFinalize(); /* Finalize the IDL generated code. */ rc = clMsgCltClientTableDeregister(); if(rc != CL_OK) clLogError("MSG", "FIN", "Failed to deregister Client Table. error code [0x%x].", rc); rc = clMsgIdlClientTableDeregister(); if(rc != CL_OK) clLogError("MSG", "FIN", "Failed to deregister Server Table. error code [0x%x].", rc); clMsgIdlClientUninstall(); rc = clMsgCltSrvClientTableDeregister(); if(rc != CL_OK) clLogError("MSG", "FIN", "Failed to deregister Client Server Table. error code [0x%x].", rc); clMsgCltSrvClientUninstall(); /* Finalize cached ckpt for MSG queue & MSG queue group */ rc = clMsgQCkptFinalize(); if(rc != CL_OK) clLogError("MSG", "FIN", "clMsgQCkptFinalize(): error code [0x%x].", rc); /* Finalize database for maintaining queues. */ clMsgReceiverDatabaseFin(); rc = clMsgQueueFinalize(); if(rc != CL_OK) clLogError("MSG", "FIN", "Failed to finalize queue databases. error code [0x%x].", rc); rc = clCpmNotificationCallbackUninstall(&gMsgNotificationHandle); if(rc != CL_OK) clLogError("MSG", "FIN", "Failed to uninstall the notification callback function. error code [0x%x].", rc); rc = clOsalMutexDestroy(&gClGroupDbLock); if(rc != CL_OK) clLogError("MSG", "FIN", "Failed to destroy the group db lock. error code [0x%x].", rc); rc = clHandleDatabaseDestroy(gMsgClientHandleDb); if(rc != CL_OK) clLogError("MSG", "FIN", "Failed to destroy the client handle database. error code [0x%x].", rc); 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