ClRcT _clTxnAgentAppendActiveJob(CL_IN ClBufferHandleT outMsg) { ClRcT rc = CL_OK; ClTxnDefnT *pTxnDefn; ClCntNodeHandleT currTxnNode; ClCharT pOutMsg[1024]; CL_FUNC_ENTER(); rc = clCntFirstNodeGet(clTxnAgntCfg->activeTxnMap, &currTxnNode); while (rc == CL_OK) { ClCntNodeHandleT nodeTxn; ClCntNodeHandleT currJobNode; ClTxnAppJobDefnT *pNewTxnJob; /* Retrieve data-node for node */ rc = clCntNodeUserDataGet(clTxnAgntCfg->activeTxnMap, currTxnNode, (ClCntDataHandleT *)&pTxnDefn); if(CL_OK != rc) { clLogError("AGT", "CLI", "User data get failed with error [0x%x]", rc); return rc; } rc = clCntFirstNodeGet(pTxnDefn->jobList, &currJobNode); while (rc == CL_OK) { ClCntNodeHandleT nodeJob; /* Retrieve data-node for node */ rc = clCntNodeUserDataGet(pTxnDefn->jobList, currJobNode, (ClCntDataHandleT *)&pNewTxnJob); pOutMsg[0] = '\0'; sprintf(pOutMsg, " 0x%x:0x%x\t| 0x%x\t| %30s \n", pTxnDefn->serverTxnId.txnMgrNodeAddress, pTxnDefn->serverTxnId.txnId, pNewTxnJob->jobId.jobId, gCliTxnStatusStr[pNewTxnJob->currentState]); clXdrMarshallArrayClUint8T(&pOutMsg, strlen((char*)pOutMsg), outMsg, 0); nodeJob = currJobNode; rc = clCntNextNodeGet(pTxnDefn->jobList, nodeJob, &currJobNode); } nodeTxn = currTxnNode; rc = clCntNextNodeGet(clTxnAgntCfg->activeTxnMap, nodeTxn, &currTxnNode); } if(CL_GET_ERROR_CODE(rc) == CL_ERR_NOT_EXIST) rc = CL_OK; CL_FUNC_EXIT(); return(rc); }
void clMsgQueueEmpty(ClMsgQueueInfoT *pQInfo) { ClRcT rc; ClCntNodeHandleT nodeHandle = NULL, nextNodeHandle = NULL; ClUint32T i; ClRcT retCode; for(i = 0; i < CL_MSG_QUEUE_PRIORITIES; i++) { rc = clCntFirstNodeGet(pQInfo->pPriorityContainer[i], &nodeHandle); if(CL_GET_ERROR_CODE(rc) == CL_ERR_NOT_EXIST) continue; do { rc = clCntNextNodeGet(pQInfo->pPriorityContainer[i], nodeHandle, &nextNodeHandle); if(CL_GET_ERROR_CODE(rc) != CL_ERR_NOT_EXIST && rc != CL_OK) { clLogError("QUE", "EMT", "Failed to get the next node from container. error code [0x%x].", rc); break; } retCode = clCntNodeDelete(pQInfo->pPriorityContainer[i], nodeHandle); if(retCode != CL_OK) clLogError("QUE", "EMT", "Failed to delete a node from container. error code [0x%x].", retCode); nodeHandle = nextNodeHandle; }while(CL_GET_ERROR_CODE(rc) != CL_ERR_NOT_EXIST); } }
ClRcT _clCorNodeNameToMoIdGet(ClNameT *nodeName, ClCorNodeDataPtrT *dataNode) { ClRcT rc = CL_OK; ClCntNodeHandleT nodeHandle = 0; ClNameT *tempName = NULL; if(nodeName == NULL) return CL_COR_SET_RC(CL_COR_ERR_NULL_PTR); /* Get the data from the hash table */ CL_DEBUG_PRINT(CL_DEBUG_TRACE,(" Node find for node Name %s", nodeName->value)); /* Do the node find and get the node handle for a particular node name. Now walk all the * node for that particular node handle type. */ rc = clCntNodeFind(nodeNameToMoIdTableHandle, (ClCntKeyHandleT)nodeName, &nodeHandle); if(CL_OK != rc) { CL_DEBUG_PRINT(CL_DEBUG_TRACE,("Failed to get the node Handle for the Node Name %s. rc [0x%x]", nodeName->value, rc)); return rc; } while(nodeHandle != 0) { rc = clCntNodeUserKeyGet(nodeNameToMoIdTableHandle, nodeHandle, (ClCntKeyHandleT *) &tempName); if (rc != CL_OK) { CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Failed to get the user key from the node handle. rc[0x%x]", rc)); break; } CL_DEBUG_PRINT(CL_DEBUG_TRACE,("Got the Nodename %s", tempName->value)); rc = clCntNodeUserDataGet(nodeNameToMoIdTableHandle, nodeHandle, (ClCntDataHandleT *)dataNode); if(rc != CL_OK) { CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Failed to get the user data from the node handle. rc [0x%x]", rc)); break; } if((strcmp (nodeName->value, (*dataNode)->nodeName.value)) == 0) { CL_DEBUG_PRINT(CL_DEBUG_TRACE,("Got the MoId for a Node Name %s", (*dataNode)->nodeName.value)); return CL_OK; } rc = clCntNextNodeGet(nodeNameToMoIdTableHandle, nodeHandle, &nodeHandle); if(rc != CL_OK) { CL_DEBUG_PRINT(CL_DEBUG_TRACE,("Failed to get the next node handle. rc[0x%x]", rc)); break; } } if(CL_OK != rc) CL_COR_RETURN_ERROR(CL_DEBUG_TRACE, "Could not get MOId from the node name", rc); return CL_OK; }
ClRcT cpmNodeFindLocked(SaUint8T *name, ClCpmLT **cpmL) { ClUint16T nodeKey = 0; ClCntNodeHandleT hNode = 0; ClCpmLT *tempNode = NULL; ClUint32T rc = CL_OK, numNode=0; rc = clCksm16bitCompute((ClUint8T *) name, strlen((const ClCharT*)name), &nodeKey); CL_CPM_CHECK_2(CL_LOG_SEV_ERROR, CL_CPM_LOG_2_CNT_CKSM_ERR, name, rc, rc, CL_LOG_HANDLE_APP); rc = clCntNodeFind(gpClCpm->cpmTable, (ClPtrT)(ClWordT)nodeKey, &hNode); CL_CPM_CHECK_3(CL_LOG_SEV_ERROR, CL_CPM_LOG_3_CNT_ENTITY_SEARCH_ERR, "node", name, rc, rc, CL_LOG_HANDLE_APP); rc = clCntKeySizeGet(gpClCpm->cpmTable, (ClPtrT)(ClWordT)nodeKey, &numNode); CL_CPM_CHECK_1(CL_LOG_SEV_ERROR, CL_CPM_LOG_1_CNT_KEY_SIZE_GET_ERR, rc, rc, CL_LOG_HANDLE_APP); while (numNode > 0) { rc = clCntNodeUserDataGet(gpClCpm->cpmTable, hNode, (ClCntDataHandleT *) &tempNode); CL_CPM_CHECK_1(CL_LOG_SEV_ERROR, CL_CPM_LOG_1_CNT_NODE_USR_DATA_GET_ERR, rc, rc, CL_LOG_HANDLE_APP); if (!strcmp(tempNode->nodeName, (const ClCharT*)name)) { *cpmL = tempNode; goto done; } if(--numNode) { rc = clCntNextNodeGet(gpClCpm->cpmTable,hNode,&hNode); if(rc != CL_OK) { break; } } } rc = CL_CPM_RC(CL_ERR_DOESNT_EXIST); CL_CPM_CHECK_3(CL_LOG_SEV_ERROR, CL_CPM_LOG_3_CNT_ENTITY_SEARCH_ERR, "node", name, rc, rc, CL_LOG_HANDLE_APP); done: return CL_OK; failure: return rc; }
ClRcT _clTxnAgentAppendServices(CL_IN ClBufferHandleT outMsg) { ClRcT rc = CL_OK; ClTxnAgentCompServiceInfoT *pCompInstance; ClCntNodeHandleT currNode; ClCharT pOutMsg[1024]; CL_FUNC_ENTER(); rc = clCntFirstNodeGet(clTxnAgntCfg->compServiceMap, &currNode); while (rc == CL_OK) { ClCntNodeHandleT node; /* Retrieve data-node for node */ rc = clCntNodeUserDataGet(clTxnAgntCfg->compServiceMap, currNode, (ClCntDataHandleT *)&pCompInstance); if(CL_OK != rc) { clLogError("AGT", "CLI", "User data get failed with error [0x%x]", rc); return rc; } pOutMsg[0] = '\0'; if(pCompInstance->serviceCapability == CL_TXN_AGENT_SERVICE_2PC) { sprintf(pOutMsg, " %6d\t| 2PC Capable \n", pCompInstance->serviceType); } else if(pCompInstance->serviceCapability == CL_TXN_AGENT_SERVICE_1PC) { sprintf(pOutMsg, " %6d\t| 1PC Capable \n", pCompInstance->serviceType); } clXdrMarshallArrayClUint8T(&pOutMsg, strlen((char*)pOutMsg), outMsg, 0); node = currNode; rc = clCntNextNodeGet(clTxnAgntCfg->compServiceMap, node, &currNode); } if(CL_GET_ERROR_CODE(rc) == CL_ERR_NOT_EXIST) rc = CL_OK; CL_FUNC_EXIT(); return(rc); }
/* Cleanup Functions */ void clCorMoIdToNodeNameTablesCleanUp(void) { ClCntNodeHandleT nodeH = 0; ClCntNodeHandleT nextNodeH = 0; clCntFirstNodeGet(nodeNameToMoIdTableHandle, &nodeH); while(nodeH) { clCntNextNodeGet(nodeNameToMoIdTableHandle, nodeH, &nextNodeH); clCntNodeDelete(nodeNameToMoIdTableHandle, nodeH); nodeH = nextNodeH; } nodeH = 0; clCntFirstNodeGet(moIdToNodeNameTableHandle, &nodeH); while(nodeH) { clCntNextNodeGet(moIdToNodeNameTableHandle, nodeH, &nextNodeH); clCntNodeDelete(moIdToNodeNameTableHandle, nodeH); nodeH = nextNodeH; } }
ClUint32T cpmNodeFindByNodeId(ClUint32T nodeId, ClCpmLT **cpmL) { ClRcT rc = CL_OK; ClCntNodeHandleT cpmNode = 0; ClUint32T cpmLCount = 0; ClCpmLT *tempCpmL = NULL; ClUint32T found = 0; cpmLCount = gpClCpm->noOfCpm; if (gpClCpm->pCpmConfig->cpmType == CL_CPM_GLOBAL && cpmLCount != 0) { rc = clCntFirstNodeGet(gpClCpm->cpmTable, &cpmNode); CL_CPM_CHECK_2(CL_LOG_SEV_ERROR, CL_CPM_LOG_2_CNT_FIRST_NODE_GET_ERR, "CPM-L", rc, rc, CL_LOG_HANDLE_APP); while (cpmLCount) { rc = clCntNodeUserDataGet(gpClCpm->cpmTable, cpmNode, (ClCntDataHandleT *) &tempCpmL); CL_CPM_CHECK_1(CL_LOG_SEV_ERROR, CL_CPM_LOG_1_CNT_NODE_USR_DATA_GET_ERR, rc, rc, CL_LOG_HANDLE_APP); if (tempCpmL->pCpmLocalInfo) { if ((ClUint32T) tempCpmL->pCpmLocalInfo->nodeId == nodeId) { *cpmL = tempCpmL; found = 1; break; } } cpmLCount--; if (cpmLCount) { rc = clCntNextNodeGet(gpClCpm->cpmTable, cpmNode, &cpmNode); CL_CPM_CHECK_2(CL_LOG_SEV_ERROR, CL_CPM_LOG_2_CNT_NEXT_NODE_GET_ERR, "CPM-L", rc, rc, CL_LOG_HANDLE_APP); } } } if(found == 1) return CL_OK; else return CL_CPM_RC(CL_ERR_DOESNT_EXIST); failure: *cpmL = NULL; return rc; }
ClRcT clCntAllNodesDelete(ClCntHandleT containerHandle) { CclContainer_t *pContainer = NULL; ClCntNodeHandleT containerNode = CL_HANDLE_INVALID_VALUE; ClCntNodeHandleT nextContainerNode = CL_HANDLE_INVALID_VALUE; ClRcT errorCode = CL_OK; pContainer = (CclContainer_t *) containerHandle; nullChkRet(pContainer); if(pContainer->validContainer != CONTAINER_ID) { returnCntError(CL_ERR_INVALID_HANDLE, "Passed container handle is invalid"); } errorCode = clCntFirstNodeGet(containerHandle, &containerNode); if(CL_OK != errorCode) { /* * Check if container is empty. */ if(CL_GET_ERROR_CODE(errorCode) == CL_ERR_NOT_EXIST) return CL_OK; return errorCode; } while(containerNode) { if(clCntNextNodeGet(containerHandle, containerNode, &nextContainerNode) != CL_OK) { nextContainerNode = 0; } errorCode = clCntNodeDelete(containerHandle, containerNode); if(errorCode != CL_OK) { return(errorCode); } containerNode = nextContainerNode; } return (CL_OK); }
ClRcT clCntNonUniqueKeyFind(ClCntHandleT container, ClCntKeyHandleT key, ClCntDataHandleT givenData, ClInt32T (*cmp)(ClCntDataHandleT data1, ClCntDataHandleT data2), ClCntDataHandleT *pDataHandle) { ClRcT rc = CL_OK; ClCntNodeHandleT node = 0; ClCntNodeHandleT nextNode = 0; ClCntDataHandleT data = 0; ClUint32T sz = 0; if(!container || !key || !givenData || !cmp || !pDataHandle) return CL_CNT_RC(CL_ERR_INVALID_PARAMETER); *pDataHandle = 0; rc = clCntNodeFind(container, key, &node); if(rc != CL_OK) return rc; rc = clCntKeySizeGet(container, key, &sz); if(rc != CL_OK) return rc; while(sz-- > 0 && node) { rc = clCntNodeUserDataGet(container, node, &data); if(rc != CL_OK) return rc; nextNode = 0; if(sz > 0) { rc = clCntNextNodeGet(container, node, &nextNode); if(rc != CL_OK) nextNode = 0; } if(!cmp(givenData, data)) { *pDataHandle = data; return CL_OK; } node = nextNode; } return CL_CNT_RC(CL_ERR_NOT_EXIST); }
ClRcT _clGmsDbGetNext( CL_IN const ClGmsDbT* const gmsDb, CL_IN const ClGmsDbTypeT type, CL_INOUT ClCntNodeHandleT** const gmsOpaque, CL_OUT void** const data) { ClRcT rc = CL_OK; ClCntNodeHandleT *gmsOldOpaque = NULL; if ((gmsDb == (const void *)NULL) || (data == NULL) || (gmsOpaque == NULL)) { return CL_ERR_NULL_POINTER; } gmsOldOpaque = *gmsOpaque; rc = clCntNextNodeGet(gmsDb->htbl[type], (ClCntNodeHandleT) gmsOldOpaque, (ClCntNodeHandleT*)gmsOpaque); if (rc == CL_CNT_RC(CL_ERR_NOT_EXIST)) { *data = NULL; return CL_OK; } if (rc != CL_OK) return rc; rc = clCntNodeUserDataGet((ClCntHandleT) gmsDb->htbl[type], (ClCntNodeHandleT)*gmsOpaque, (ClCntDataHandleT*)(data)); if (rc == CL_CNT_RC(CL_ERR_NOT_EXIST)) { *data = NULL; return CL_OK; } return rc; }
ClRcT cpmInvocationClearCompInvocation(SaNameT *compName) { ClRcT rc = CL_OK; ClCntNodeHandleT nodeHandle, nextNodeHandle; ClCpmInvocationT *invocationData = NULL; void *data = NULL; /* * Check the input parameter */ if (!compName) { CL_CPM_CHECK(CL_LOG_SEV_ERROR, ("Invalid parameter passed \n"), CL_CPM_RC(CL_ERR_NULL_POINTER)); } clOsalMutexLock(gpClCpm->invocationMutex); rc = clCntFirstNodeGet(gpClCpm->invocationTable, &nodeHandle); if (rc != CL_OK) goto withLock; while (nodeHandle) { rc = clCntNodeUserDataGet(gpClCpm->invocationTable, nodeHandle, (ClCntDataHandleT *) &invocationData); if (rc != CL_OK) goto withLock; rc = clCntNextNodeGet(gpClCpm->invocationTable, nodeHandle, &nextNodeHandle); if((data = invocationData->data)) { ClUint32T matched = 0; if ((invocationData->flags & CL_CPM_INVOCATION_AMS)) { matched = !strncmp((const ClCharT *) (((ClAmsInvocationT*) data)->compName.value), (const ClCharT *) compName->value, ((ClAmsInvocationT*) data)->compName.length); } else if ((invocationData->flags & CL_CPM_INVOCATION_CPM)) { matched = !strncmp((const ClCharT *) (((ClCpmComponentT*) data)->compConfig->compName), (const ClCharT *) compName->value, compName->length); } if(matched) { clLogDebug("INVOCATION", "CLEAR", "Clearing invocation for component [%.*s] " "invocation [%#llx]", compName->length, compName->value, invocationData->invocation); if (clCntNodeDelete(gpClCpm->invocationTable, nodeHandle) != CL_OK) goto withLock; if( (invocationData->flags & CL_CPM_INVOCATION_DATA_COPIED) ) clHeapFree(data); clHeapFree(invocationData); } } if (CL_GET_ERROR_CODE(rc) == CL_ERR_NOT_EXIST) break; if (rc != CL_OK) goto withLock; nodeHandle = nextNodeHandle; } clOsalMutexUnlock(gpClCpm->invocationMutex); return CL_OK; withLock: failure: clOsalMutexUnlock(gpClCpm->invocationMutex); return rc; }
static ClRcT __clCntWalk(ClCntHandleT containerHandle, ClCntWalkCallbackT fpUserWalkCallback, ClCntArgHandleT userDataArg, ClInt32T dataLength, ClBoolT failSafe) { CclContainer_t *pContainer = NULL; ClCntNodeHandleT containerNode = CL_HANDLE_INVALID_VALUE; ClCntNodeHandleT nextContainerNode = CL_HANDLE_INVALID_VALUE; ClCntDataHandleT userData = CL_HANDLE_INVALID_VALUE; ClCntKeyHandleT userKey = CL_HANDLE_INVALID_VALUE; BaseLinkedListNode_t *pTemp = NULL; ClRcT errorCode = CL_OK; nullChkRet(fpUserWalkCallback); pContainer = (CclContainer_t *) containerHandle; nullChkRet(pContainer); if(pContainer->validContainer != CONTAINER_ID) { returnCntError(CL_ERR_INVALID_HANDLE, "Passed container handle is invalid"); } errorCode = clCntFirstNodeGet (containerHandle, &containerNode); if(errorCode != CL_OK) { if((CL_GET_ERROR_CODE(errorCode)) == CL_ERR_NOT_EXIST) { /* If the container is empty it means we dont have to walk anymore. * Hence return OK. */ return (CL_OK); } return(errorCode); } while (containerNode) { pTemp = (BaseLinkedListNode_t*) containerNode; if(clCntNextNodeGet(containerHandle, containerNode, &nextContainerNode) != CL_OK) { nextContainerNode = 0; } if ((pTemp->pRbeExpression == NULL) || (clRuleExprEvaluate(pTemp->pRbeExpression, (ClUint32T*) userDataArg, dataLength))) { errorCode = clCntNodeUserKeyGet (containerHandle, containerNode, &userKey); errorCode = clCntNodeUserDataGet (containerHandle, containerNode, &userData); errorCode = fpUserWalkCallback(userKey, userData, userDataArg,dataLength); if(!failSafe && (CL_OK != errorCode)) { return (errorCode); } } containerNode = nextContainerNode; } return(CL_OK); }
ClRcT clCkptMasterPeerUpdateNoLock(ClIocPortT portId, ClUint32T flag, ClIocNodeAddressT localAddr, ClUint8T credential) { ClRcT rc = CL_OK; CkptPeerInfoT *pPeerInfo = NULL; CkptNodeListInfoT *pPeerInfoDH = NULL; ClCntNodeHandleT nodeHdl = 0; ClCntNodeHandleT tempHdl = 0; ClHandleT *pMasterHandle = NULL; /* * Check whether node/component is coming up or going down. */ if(flag == CL_CKPT_SERVER_UP) { /* * Checkpoint server up scenario. */ clLogDebug(CL_CKPT_AREA_MAS_DEP, CL_CKPT_CTX_PEER_ANNOUNCE, "Received welcome message from master, updating the peerlist for [%d]", localAddr); /* Reset the replica list for peer being welcomed without knowing the peer is available or not */ if(localAddr != gCkptSvr->localAddr) { clLogNotice("PEER", "UPDATE", "Resetting the replica list for the peer [%#x] being welcomed", localAddr); clCkptMasterReplicaListUpdateNoLock(localAddr); } /* * Add an entry to the peer list if not existing. * Mark the node as "available" i.e. available for checkpoint * operations like storing replicas etc.. */ rc = clCntDataForKeyGet( gCkptSvr->masterInfo.peerList, (ClPtrT)(ClWordT)localAddr, (ClCntDataHandleT *)&pPeerInfo); if( rc == CL_OK && pPeerInfo != NULL) { CL_ASSERT(pPeerInfo->ckptList != 0); pPeerInfo->credential = credential; pPeerInfo->available = CL_CKPT_NODE_AVAIL; if(localAddr != gCkptSvr->localAddr) { pPeerInfo->replicaCount = 0; } } else { if( CL_OK !=( rc = _ckptMasterPeerListInfoCreate(localAddr, credential,0))) { return rc; } } } else { /* * Node/component down scenario. */ clLogDebug(CL_CKPT_AREA_MAS_DEP, CL_CKPT_CTX_PEER_DOWN, "Updating the peerAddr [%d] for down notification", localAddr); /* * Find the corresponding entry from the peer list. */ if( CL_OK != (rc = clCntDataForKeyGet(gCkptSvr->masterInfo.peerList, (ClCntKeyHandleT)(ClWordT)localAddr, (ClCntDataHandleT *) &pPeerInfo))) { rc = CL_OK; goto exitOnError; } if( flag != CL_CKPT_COMP_DOWN) { clLogDebug(CL_CKPT_AREA_MAS_DEP, CL_CKPT_CTX_PEER_DOWN, "Either ckpt server or node down, " "changing active address"); clCntFirstNodeGet(pPeerInfo->mastHdlList,&nodeHdl); tempHdl = 0; while(nodeHdl != 0) { rc = clCntNodeUserKeyGet(pPeerInfo->mastHdlList,nodeHdl, (ClCntKeyHandleT *)&pMasterHandle); if( CL_OK != rc ) { clLogError(CL_CKPT_AREA_MAS_DEP, CL_CKPT_CTX_PEER_DOWN, "Not able get the data for node handle rc[0x %x]", rc); goto exitOnError; } rc = clCntNextNodeGet(pPeerInfo->mastHdlList, nodeHdl, &tempHdl); /* * Update the active address and inform the clients. */ if( CL_OK != (rc = _clCkpMastertReplicaAddressUpdate(*pMasterHandle, localAddr))) { return rc; } nodeHdl = tempHdl; tempHdl = 0; } } if (flag != CL_CKPT_SVR_DOWN) { /* * Component down/ node down case. * In case of component down close the associated client Hdl. * Incase of node down close all client Hdl. * Delete the ckpt Hdls from the client handle List. */ clLogDebug(CL_CKPT_AREA_MAS_DEP, CL_CKPT_CTX_PEER_DOWN, "Closing the opened handles from this slot id [%d]...", localAddr); clCntFirstNodeGet(pPeerInfo->ckptList,&nodeHdl); while(nodeHdl != 0) { rc = clCntNodeUserDataGet(pPeerInfo->ckptList,nodeHdl, (ClCntDataHandleT *)&pPeerInfoDH); if( CL_OK != rc ) { clLogError(CL_CKPT_AREA_MAS_DEP, CL_CKPT_CTX_PEER_DOWN, "Not able get the data for node handle rc[0x %x]", rc); goto exitOnError; } clCntNextNodeGet(pPeerInfo->ckptList,nodeHdl,&tempHdl); if ( (flag == CL_CKPT_COMP_DOWN && pPeerInfoDH->appPortNum == portId) || (flag == CL_CKPT_NODE_DOWN) ) { /* * Close the checkpoint hdl but dont delete the entry from * masterHdl list. */ if(gCkptSvr->masterInfo.masterAddr == gCkptSvr->localAddr) { clLogInfo(CL_CKPT_AREA_MAS_DEP, CL_CKPT_CTX_PEER_DOWN, "Closing the handle [%#llX]...", pPeerInfoDH->clientHdl); _clCkptMasterCloseNoLock(pPeerInfoDH->clientHdl, localAddr, !CL_CKPT_MASTER_HDL); } } nodeHdl = tempHdl; tempHdl = 0; } } else if (flag == CL_CKPT_SVR_DOWN) { /* * Mark the availability of checkpoint server as UNAVAILABLE. */ if(pPeerInfo->credential == CL_CKPT_CREDENTIAL_POSITIVE) gCkptSvr->masterInfo.availPeerCount--; pPeerInfo->available = CL_CKPT_NODE_UNAVAIL; } if(flag == CL_CKPT_NODE_DOWN || flag == CL_CKPT_SVR_DOWN) { /* * Node down case, delete the entry from master's peer list. */ rc = clCntAllNodesForKeyDelete(gCkptSvr->masterInfo.peerList, (ClPtrT)(ClWordT)localAddr); CKPT_ERR_CHECK(CL_CKPT_SVR,CL_LOG_SEV_ERROR, (" MasterPeerUpdate failed rc[0x %x]\n",rc), rc); } if( flag != CL_CKPT_COMP_DOWN) { /* * Find other nodes to store the replicas of checkpoints for whom * this node was storing the replicas. */ if(gCkptSvr->masterInfo.masterAddr == gCkptSvr->localAddr) { _ckptCheckpointLoadBalancing(); } } } exitOnError: { return rc; } }
static ClRcT cpmNodeRmv(ClCharT *nodeName) { ClRcT rc = CL_OK; ClUint16T nodeKey = 0; ClCntNodeHandleT hNode = 0; ClUint32T numNode = 0; ClCpmLT *cpm = NULL; ClBoolT done = CL_NO; if (!nodeName) { clLogError(CPM_LOG_AREA_CPM, CPM_LOG_CTX_CPM_MGM, "NULL pointer passed."); goto failure; } rc = clCksm16bitCompute((ClUint8T *)nodeName, strlen(nodeName), &nodeKey); if (CL_OK != rc) { clLogError(CPM_LOG_AREA_CPM, CPM_LOG_CTX_CPM_MGM, "Failed to compute checksum for node, " "error [%#x]", rc); goto failure; } clOsalMutexLock(gpClCpm->cpmTableMutex); rc = clCntNodeFind(gpClCpm->cpmTable, (ClCntKeyHandleT)(ClWordT)nodeKey, &hNode); if (CL_OK != rc) { clLogError(CPM_LOG_AREA_CPM, CPM_LOG_CTX_CPM_MGM, "Failed to find node [%s], error [%#x]", nodeName, rc); goto unlock; } rc = clCntKeySizeGet(gpClCpm->cpmTable, (ClCntKeyHandleT)(ClWordT)nodeKey, &numNode); if (CL_OK != rc) { clLogError(CPM_LOG_AREA_CPM, CPM_LOG_CTX_CPM_MGM, "Unable to get key size, error [%#x]", rc); goto unlock; } while (numNode > 0) { rc = clCntNodeUserDataGet(gpClCpm->cpmTable, hNode, (ClCntNodeHandleT *) &cpm); if (CL_OK != rc) { clLogError(CPM_LOG_AREA_CPM, CPM_LOG_CTX_CPM_MGM, "Unable to get user data, error [%#x]", rc); goto unlock; } if (!strncmp(nodeName, cpm->nodeName, CL_MAX_NAME_LENGTH-1)) { clCntNodeDelete(gpClCpm->cpmTable, hNode); done = CL_YES; break; } if (--numNode) { rc = clCntNextNodeGet(gpClCpm->cpmTable, hNode, &hNode); if (CL_OK != rc) { break; } } } if (!done) { rc = CL_CPM_RC(CL_ERR_DOESNT_EXIST); goto unlock; } --gpClCpm->noOfCpm; clOsalMutexUnlock(gpClCpm->cpmTableMutex); /* * Delete from slot table */ clOsalMutexLock(&gpClCpm->cpmMutex); if(cpmSlotClassDelete(nodeName) != CL_OK) { clLogWarning("CPM", "MGMT", "Slot class delete failed for node [%s]", nodeName); } clOsalMutexUnlock(&gpClCpm->cpmMutex); return CL_OK; unlock: clOsalMutexUnlock(gpClCpm->cpmTableMutex); failure: return rc; }
static ClRcT cpmComponentRmv(ClCharT *compName) { ClRcT rc = CL_OK; ClUint16T compKey = 0; ClCntNodeHandleT hNode = 0; ClUint32T numNode = 0; ClCpmComponentT *comp = NULL; ClBoolT done = CL_NO; SaNameT entity = {0}; if (!compName) { clLogError(CPM_LOG_AREA_CPM, CPM_LOG_CTX_CPM_MGM, "NULL pointer passed."); goto failure; } rc = clCksm16bitCompute((ClUint8T *)compName, strlen(compName), &compKey); if (CL_OK != rc) { clLogError(CPM_LOG_AREA_CPM, CPM_LOG_CTX_CPM_MGM, "Failed to compute checksum for component, " "error [%#x]", rc); goto failure; } saNameSet(&entity, compName); /* * Clear pending invocations for the component being removed. */ (void)cpmInvocationClearCompInvocation(&entity); clOsalMutexLock(gpClCpm->compTableMutex); clOsalMutexLock(&gpClCpm->compTerminateMutex); rc = clCntNodeFind(gpClCpm->compTable, (ClCntKeyHandleT)(ClWordT)compKey, &hNode); if (CL_OK != rc) { clLogError(CPM_LOG_AREA_CPM, CPM_LOG_CTX_CPM_MGM, "Failed to find component [%s], error [%#x]", compName, rc); goto unlock; } rc = clCntKeySizeGet(gpClCpm->compTable, (ClCntKeyHandleT)(ClWordT)compKey, &numNode); if (CL_OK != rc) { clLogError(CPM_LOG_AREA_CPM, CPM_LOG_CTX_CPM_MGM, "Unable to get key size, error [%#x]", rc); goto unlock; } while (numNode > 0) { rc = clCntNodeUserDataGet(gpClCpm->compTable, hNode, (ClCntNodeHandleT *) &comp); if (CL_OK != rc) { clLogError(CPM_LOG_AREA_CPM, CPM_LOG_CTX_CPM_MGM, "Unable to get user data, error [%#x]", rc); goto unlock; } if (!strncmp(compName, comp->compConfig->compName, CL_MAX_NAME_LENGTH-1)) { clCntNodeDelete(gpClCpm->compTable, hNode); done = CL_YES; break; } if (--numNode) { rc = clCntNextNodeGet(gpClCpm->compTable, hNode, &hNode); if (CL_OK != rc) { break; } } } if (!done) { rc = CL_CPM_RC(CL_ERR_DOESNT_EXIST); goto unlock; } --gpClCpm->noOfComponent; clOsalMutexUnlock(&gpClCpm->compTerminateMutex); clOsalMutexUnlock(gpClCpm->compTableMutex); return CL_OK; unlock: clOsalMutexUnlock(&gpClCpm->compTerminateMutex); clOsalMutexUnlock(gpClCpm->compTableMutex); failure: return rc; }
ClRcT _cpmClusterConfigList(ClInt32T argc, ClCharT **retStr) { ClCpmLT *cpmL = NULL; ClRcT rc = CL_OK; ClCntNodeHandleT hNode = 0; ClUint32T cpmLCount = 0; ClCharT tempStr[256]; ClCharT *tmpStr = NULL; ClBufferHandleT message; rc = clBufferCreate(&message); CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n Unable to create message \n"), rc); if (argc != ONE_ARGUMENT) { sprintf(tempStr, "Usage: clusterList"); rc = clBufferNBytesWrite(message, (ClUint8T *) tempStr, strlen(tempStr)); CL_CPM_CHECK(CL_DEBUG_ERROR, ("Unable to write message %x\n", rc), rc); goto done; } /* * Print the local stuff first */ sprintf(tempStr, "%s\n", "nodeName | status | iocAddress | iocPort "); rc = clBufferNBytesWrite(message, (ClUint8T *) tempStr, strlen(tempStr)); CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n Unable to write message \n"), rc); sprintf(tempStr, "%s\n", "-----------------------------------------------------------------------"); rc = clBufferNBytesWrite(message, (ClUint8T *) tempStr, strlen(tempStr)); CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n Unable to write message \n"), rc); /* * Now even the CPM/G information is stored in the list. * So no need of printing the above information. */ #if 0 if (gpClCpm->pCpmLocalInfo->status == CL_CPM_EO_DEAD) sprintf(tempStr, "%10s | DEAD | %8d | 0x%x\n", gpClCpm->pCpmLocalInfo->nodeName, gpClCpm->pCpmLocalInfo->cpmAddress.nodeAddress, gpClCpm->pCpmLocalInfo->cpmAddress.portId); else sprintf(tempStr, "%10s | ALIVE | %8d | 0x%x\n", gpClCpm->pCpmLocalInfo->nodeName, gpClCpm->pCpmLocalInfo->cpmAddress.nodeAddress, gpClCpm->pCpmLocalInfo->cpmAddress.portId); rc = clBufferNBytesWrite(message, (ClUint8T *) tempStr, strlen(tempStr)); CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n Unable to write message \n"), rc); #endif /*_cpmListAllSU();*/ /* * Get all the CPMs one by one and delete the stuff. */ rc = clCntFirstNodeGet(gpClCpm->cpmTable, &hNode); CL_CPM_CHECK(CL_DEBUG_ERROR, ("Unable to get first cpmTable Node %x\n", rc), rc); rc = clCntNodeUserDataGet(gpClCpm->cpmTable, hNode, (ClCntDataHandleT *) &cpmL); CL_CPM_CHECK(CL_DEBUG_ERROR, ("Unable to get container Node data %x\n", rc), rc); cpmLCount = gpClCpm->noOfCpm; while (cpmLCount) { if (cpmL->pCpmLocalInfo != NULL) { if (cpmL->pCpmLocalInfo->status == CL_CPM_EO_DEAD) { sprintf(tempStr, "%10s | DEAD | %8d | 0x%x\n", cpmL->nodeName, cpmL->pCpmLocalInfo->cpmAddress.nodeAddress, cpmL->pCpmLocalInfo->cpmAddress.portId); } else { sprintf(tempStr, "%10s | ALIVE | %8d | 0x%x\n", cpmL->nodeName, cpmL->pCpmLocalInfo->cpmAddress.nodeAddress, cpmL->pCpmLocalInfo->cpmAddress.portId); } rc = clBufferNBytesWrite(message, (ClUint8T *) tempStr, strlen(tempStr)); CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n Unable to write message \n"), rc); } else { sprintf(tempStr, "%10s \n", cpmL->nodeName); rc = clBufferNBytesWrite(message, (ClUint8T *) tempStr, strlen(tempStr)); CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n Unable to write message \n"), rc); } #if 0 rc = clCntFirstNodeGet(cpmL->suTable, &hSU); CL_CPM_CHECK(CL_DEBUG_ERROR, ("Unable to get first su Node in cpmL %x\n", rc), rc); if (cpmL->pCpmLocalInfo != NULL) clOsalPrintf("%10s | %8d | %8d | 0x%8x| 0x%8x \n", cpmL->pCpmLocalInfo->nodeName, cpmL->pCpmLocalInfo->status, cpmL->pCpmLocalInfo->nodeId, cpmL->pCpmLocalInfo->cpmAddress.nodeAddress, cpmL->pCpmLocalInfo->cpmAddress.portId); else clOsalPrintf("%10s \n", cpmL->nodeName); suCount = cpmL->noOfsu; while (suCount) { rc = clCntNodeUserDataGet(cpmL->suTable, hSU, (ClCntDataHandleT *) &su); CL_CPM_CHECK(CL_DEBUG_ERROR, ("Unable to get first container su Node data %x\n", rc), rc); clOsalPrintf("\t %10s |%15s |%11s |%16s \n", su->suName, _cpmPresenceStateNameGet(su->suPresenceState), _cpmOperStateNameGet(su->suOperState), _cpmReadinessStateNameGet(su->suReadinessState)); tempCompRef = su->suCompList; while (tempCompRef != NULL) { clOsalPrintf ("-----------------------------------------------------------------------\n"); clOsalPrintf("\t\t%10s %14d |%15s |%11s |%16s \n", tempCompRef->ref->compConfig->compName, tempCompRef->ref->compRestartCount, _cpmPresenceStateNameGet(tempCompRef->ref-> compPresenceState), _cpmOperStateNameGet(tempCompRef->ref-> compOperState), _cpmReadinessStateNameGet(tempCompRef->ref-> compReadinessState)); tempCompRef = tempCompRef->pNext; } suCount--; if (suCount) { rc = clCntNextNodeGet(cpmL->suTable, hSU, &hSU); CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n Unable to Get Node Data \n"), rc); } } #endif sprintf(tempStr, "%s", "-----------------------------------------------------------------------\n"); rc = clBufferNBytesWrite(message, (ClUint8T *) tempStr, strlen(tempStr)); CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n Unable to write message \n"), rc); cpmLCount--; if (cpmLCount) { rc = clCntNextNodeGet(gpClCpm->cpmTable, hNode, &hNode); CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n Unable to Get Node Data \n"), rc); rc = clCntNodeUserDataGet(gpClCpm->cpmTable, hNode, (ClCntDataHandleT *) &cpmL); CL_CPM_CHECK(CL_DEBUG_ERROR, ("Unable to get container Node data %d\n", rc), rc); } } /* * Bug 4986 : * Moved the code to NULL terminate the string * below the done: label, so that the usage string * written to the buffer is also NULL terminated. */ done: /* * NULL terminate the string */ sprintf(tempStr, "%s", "\0"); rc = clBufferNBytesWrite(message, (ClUint8T *) tempStr, 1); CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n Unable to write message \n"), rc); rc = clBufferFlatten(message, (ClUint8T **) &tmpStr); CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n Unable to flatten message \n"), rc); *retStr = tmpStr; clBufferDelete(&message); return rc; failure: clBufferDelete(&message); return rc; }
ClRcT _clCpmComponentListAll(ClInt32T argc, ClCharT **retStr) { ClCntNodeHandleT hNode = 0; ClCpmComponentT *comp = NULL; ClUint32T rc = CL_OK, count; ClCpmEOListNodeT *eoList = NULL; ClCharT state[10] = "\0"; ClCharT status[10] = "\0"; ClCharT tempStr[256]; ClCharT *tmpStr = NULL; ClBufferHandleT message; ClCharT cpmCompName[CL_MAX_NAME_LENGTH] = {0}; rc = clBufferCreate(&message); CL_CPM_CHECK(CL_DEBUG_ERROR, ("Unable to create message %x\n", rc), rc); if (argc != ONE_ARGUMENT) { rc = clBufferNBytesWrite(message, (ClUint8T *) STR_AND_SIZE("Usage: compList")); CL_CPM_CHECK(CL_DEBUG_ERROR, ("Unable to write message %x\n", rc), rc); rc = CL_CPM_RC(CL_ERR_INVALID_PARAMETER); goto done; } count = gpClCpm->noOfComponent; snprintf(cpmCompName, CL_MAX_NAME_LENGTH-1, "%s_%s", CL_CPM_COMPONENT_NAME, gpClCpm->pCpmLocalInfo->nodeName); rc = clCntFirstNodeGet(gpClCpm->compTable, &hNode); CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n Unable to Get First component \n"), rc); rc = clBufferNBytesWrite(message, (ClUint8T *) STR_AND_SIZE("################### List Of Components ########################\n")); CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n Unable to write message \n"), rc); rc = clCntNodeUserDataGet(gpClCpm->compTable, hNode,(ClCntDataHandleT *) &comp); CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n Unable to Get Node Data \n"), rc); rc = clBufferNBytesWrite(message, STR_AND_SIZE(" CompName | compId | eoPort | PID | RestartCount | PresenceState\n")); CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n Unable to write message \n"), rc); rc = clBufferNBytesWrite(message, STR_AND_SIZE("\t\t ID | Port | Name | Health |Recv Threads \n")); CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n Unable to write message \n"), rc); rc = clBufferNBytesWrite(message, STR_AND_SIZE("========================================================================================\n")); CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n Unable to write message \n"), rc); while (count) { if (strcmp(comp->compConfig->compName, cpmCompName)!=0) /* Skip if it is the CPM component */ { eoList = comp->eoHandle; int len = sprintf(tempStr, "%30s| 0x%x | 0x%x |%8d |%14d |%15s\n", comp->compConfig->compName, comp->compId, comp->eoPort, comp->processId, comp->compRestartCount, _cpmPresenceStateNameGet(comp->compPresenceState)); if (comp->compConfig->compProperty != CL_AMS_COMP_PROPERTY_SA_AWARE) { if(!eoList || !eoList->eoptr) { len += snprintf(tempStr + len, sizeof(tempStr) - len, "\t\t 0x%x | 0x%x |%10s |%10s |%04d \n", 0, 0, "-", "-", 0); } } rc = clBufferNBytesWrite(message, (ClUint8T *) tempStr,len); CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n Unable to write message \n"), rc); while (eoList != NULL && eoList->eoptr != NULL) { compMgrStateStatusGet(eoList->status, eoList->eoptr->state, status, sizeof(status), state, sizeof(state)); int noOfThreads = (eoList->eoptr->appType == CL_EO_USE_THREAD_FOR_RECV) ? eoList->eoptr->noOfThreads + 1: eoList->eoptr->noOfThreads; int len = sprintf(tempStr, "\t\t 0x%llx | 0x%x |%10s |%10s |%04d \n", eoList->eoptr->eoID, eoList->eoptr->eoPort, eoList->eoptr->name, status, noOfThreads); rc = clBufferNBytesWrite(message, (ClUint8T *) tempStr, len); CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n Unable to write message \n"), rc); eoList = eoList->pNext; } rc = clBufferNBytesWrite(message, STR_AND_SIZE("-----------------------------------------------------------------------------------------\n")); CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n Unable to write message \n"), rc); } count--; if (count) { rc = clCntNextNodeGet(gpClCpm->compTable, hNode, &hNode); CL_CPM_CHECK(CL_DEBUG_ERROR, ("Unable to Get Node Data %x\n", rc), rc); rc = clCntNodeUserDataGet(gpClCpm->compTable, hNode, (ClCntDataHandleT *) &comp); CL_CPM_CHECK(CL_DEBUG_ERROR, ("Unable to Get Node user Data %x\n", rc), rc); } } /* * Bug 4986 : * Moved the code to NULL terminate the string * below the done: label, so that the usage string * written to the buffer is also NULL terminated. */ done: /* * NULL terminate the string */ rc = clBufferNBytesWrite(message, (ClUint8T *) "\0", 1); CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n Unable to write message \n"), rc); rc = clBufferFlatten(message, (ClUint8T **) &tmpStr); CL_CPM_CHECK(CL_DEBUG_ERROR, ("Unable to flatten the message \n"), rc); *retStr = tmpStr; clBufferDelete(&message); return rc; failure: clBufferDelete(&message); return rc; }
ClRcT clCpmExecutionObjectListShow(ClInt32T argc, ClIocNodeAddressT compAddr, ClUint32T flag, ClEoIdT eoId, ClCharT **retStr) { /* * ClCpmEOListNodeT* ptr = gpClCpm->eoList; */ ClCpmEOListNodeT *ptr = NULL; ClCharT name[32] = "\0"; ClCharT state[10] = "\0"; ClCharT status[10] = "\0"; ClUint32T compCount = 0; ClCntNodeHandleT hNode = 0; ClCpmComponentT *comp = NULL; ClRcT rc = CL_OK; ClCharT tempStr[256]; ClCharT *tmpStr = NULL; ClBufferHandleT message = 0; rc = clBufferCreate(&message); CL_CPM_CHECK(CL_DEBUG_ERROR, ("Unable to create message %x\n", rc), rc); if (argc != ONE_ARGUMENT) { sprintf(tempStr, "Usage: EOShow"); rc = clBufferNBytesWrite(message, (ClUint8T *) tempStr, strlen(tempStr)); CL_CPM_CHECK(CL_DEBUG_ERROR, ("Unable to write message %x\n", rc), rc); goto done; } sprintf(tempStr, "\n ID | Port | Name | Health | EO State | Recv Threads "); rc = clBufferNBytesWrite(message, (ClUint8T *) tempStr, strlen(tempStr)); CL_CPM_CHECK(CL_DEBUG_ERROR, ("Unable to write message %x\n", rc), rc); sprintf(tempStr, "\n ===================================================================== "); rc = clBufferNBytesWrite(message, (ClUint8T *) tempStr, strlen(tempStr)); CL_CPM_CHECK(CL_DEBUG_ERROR, ("Unable to write message %x\n", rc), rc); /* * take the semaphore */ if ((rc = clOsalMutexLock(gpClCpm->eoListMutex)) != CL_OK) CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Could not get Lock successfully------\n")); rc = clCntFirstNodeGet(gpClCpm->compTable, &hNode); CL_CPM_LOCK_CHECK(CL_DEBUG_ERROR, ("Unable to Get First component \n"), rc); rc = clCntNodeUserDataGet(gpClCpm->compTable, hNode, (ClCntDataHandleT *) &comp); CL_CPM_LOCK_CHECK(CL_DEBUG_ERROR, ("Unable to Get Node Data \n"), rc); compCount = gpClCpm->noOfComponent; while (compCount != 0) { ptr = comp->eoHandle; if (flag == 0) { while (ptr != NULL && ptr->eoptr != NULL) { strcpy(name, ptr->eoptr->name); /* * Obtain the state and status in string format */ compMgrStateStatusGet(ptr->status, ptr->eoptr->state, status, sizeof(status), state, sizeof(state)); if (ptr->eoptr->appType == CL_EO_USE_THREAD_FOR_RECV) sprintf(tempStr, "\n 0x%llx| 0x%x | %10s | %10s | %10s | %04d ", ptr->eoptr->eoID, ptr->eoptr->eoPort, name, status, state, (ptr->eoptr->noOfThreads + 1)); else sprintf(tempStr, "\n 0x%llx| 0x%x | %10s | %10s | %10s | %04d ", ptr->eoptr->eoID, ptr->eoptr->eoPort, name, status, state, ptr->eoptr->noOfThreads); rc = clBufferNBytesWrite(message, (ClUint8T *) tempStr, strlen(tempStr)); CL_CPM_LOCK_CHECK(CL_DEBUG_ERROR, ("\n Unable to write message \n"), rc); ptr = ptr->pNext; } } else { while (ptr != NULL && ptr->eoptr != NULL) { if (ptr->eoptr->eoID == eoId) { /* * obtain the state and status in string format */ compMgrStateStatusGet(ptr->status, ptr->eoptr->state, status, sizeof(status), state, sizeof(state)); strcpy(name, ptr->eoptr->name); if (ptr->eoptr->appType == CL_EO_USE_THREAD_FOR_RECV) sprintf(tempStr, "\n 0x%llx| 0x%x | %10s | %10s | %10s | %04d | ", ptr->eoptr->eoID, ptr->eoptr->eoPort, name, status, state, ptr->eoptr->noOfThreads + 1); else sprintf(tempStr, "\n 0x%llx| 0x%x | %10s | %10s | %10s | %04d | ", ptr->eoptr->eoID, ptr->eoptr->eoPort, name, status, state, ptr->eoptr->noOfThreads); rc = clBufferNBytesWrite(message, (ClUint8T *) tempStr, strlen(tempStr)); CL_CPM_LOCK_CHECK(CL_DEBUG_ERROR, ("\n Unable to write message \n"), rc); break; } ptr = ptr->pNext; } #if 0 if (ptr == NULL) CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("EOID not found\n")); #endif } compCount--; if (compCount) { rc = clCntNextNodeGet(gpClCpm->compTable, hNode, &hNode); CL_CPM_LOCK_CHECK(CL_DEBUG_ERROR, ("\n Unable to Get Node Data \n"), rc); rc = clCntNodeUserDataGet(gpClCpm->compTable, hNode, (ClCntDataHandleT *) &comp); CL_CPM_LOCK_CHECK(CL_DEBUG_ERROR, ("\n Unable to Get Node Data \n"), rc); } } /* * Release the semaphore */ rc = clOsalMutexUnlock(gpClCpm->eoListMutex); CL_CPM_CHECK(CL_DEBUG_ERROR, ("COMP_MGR: Could not UnLock successfully------\n"), rc); /* * Bug 4986 : * Moved the code to NULL terminate the string * below the done: label, so that the usage string * written to the buffer is also NULL terminated. */ done: /* * NULL terminate the string */ sprintf(tempStr, "%s", "\0"); rc = clBufferNBytesWrite(message, (ClUint8T *) tempStr, 1); CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n Unable to write message \n"), rc); /* * Construct the return buffer */ rc = clBufferFlatten(message, (ClUint8T **) &tmpStr); CL_CPM_CHECK(CL_DEBUG_ERROR, ("Unable to flatten the message \n"), rc); *retStr = tmpStr; clBufferDelete(&message); return (CL_OK); withlock: /* * Release the semaphore */ rc = clOsalMutexUnlock(gpClCpm->eoListMutex); CL_CPM_CHECK(CL_DEBUG_ERROR, ("COMP_MGR: Could not UnLock successfully------\n"), rc); failure: clBufferDelete(&message); return rc; }
ClRcT cpmPrintDBXML(FILE *fp) { ClRcT rc = CL_OK; ClCntNodeHandleT cpmNode = 0; ClUint32T cpmLCount = 0; ClCpmLT *cpmL = NULL; fprintf(fp,"<cpm>\n"); /* * Walk through the cpm table to find and display SCs */ clOsalMutexLock(gpClCpm->cpmTableMutex); cpmLCount = gpClCpm->noOfCpm; if (gpClCpm->pCpmConfig->cpmType == CL_CPM_GLOBAL && cpmLCount != 0) { rc = clCntFirstNodeGet(gpClCpm->cpmTable, &cpmNode); if(rc != CL_OK) { clLogError(CPM_LOG_AREA_DB,CPM_LOG_CTX_DB_XML,CL_CPM_LOG_2_CNT_FIRST_NODE_GET_ERR, "CPM-L", rc); clLogWrite((CL_LOG_HANDLE_APP), (CL_LOG_SEV_DEBUG), NULL, CL_CPM_LOG_2_CNT_FIRST_NODE_GET_ERR, ("CPM-L"), (rc)); goto out_unlock; } while (cpmLCount) { rc = clCntNodeUserDataGet(gpClCpm->cpmTable, cpmNode, (ClCntDataHandleT *) &cpmL); if(rc != CL_OK) { clLogError(CPM_LOG_AREA_DB,CPM_LOG_CTX_DB_XML,CL_CPM_LOG_1_CNT_NODE_USR_DATA_GET_ERR, rc); clLogWrite((CL_LOG_HANDLE_APP), (CL_LOG_SEV_DEBUG), NULL, CL_CPM_LOG_1_CNT_NODE_USR_DATA_GET_ERR, rc); goto out_unlock; } if (cpmL->pCpmLocalInfo) { /* * If the node is a SC, display its data */ if(!strcmp((const ClCharT *)cpmL->nodeType.value, (const ClCharT *)gpClCpm->pCpmLocalInfo->nodeType.value) || (ClUint32T) cpmL->pCpmLocalInfo->nodeId == gpClCpm->activeMasterNodeId || (ClUint32T) cpmL->pCpmLocalInfo->nodeId == gpClCpm->deputyNodeId) { fprintf(fp,"<node value=\"%s\">\n",cpmL->pCpmLocalInfo->nodeName); fprintf(fp,"<id value=\"%d\"/>\n",cpmL->pCpmLocalInfo->nodeId); fprintf(fp,"<ha_state value=\"%s\"/>\n",(ClUint32T) cpmL->pCpmLocalInfo->nodeId == gpClCpm->activeMasterNodeId ? "active" : "standby"); fprintf(fp,"</node>\n"); } } cpmLCount--; if (cpmLCount) { rc = clCntNextNodeGet(gpClCpm->cpmTable, cpmNode, &cpmNode); if(rc != CL_OK) { clLogError(CPM_LOG_AREA_DB,CPM_LOG_CTX_DB_XML,CL_CPM_LOG_2_CNT_NEXT_NODE_GET_ERR, "CPM-L", rc); clLogWrite((CL_LOG_HANDLE_APP), (CL_LOG_SEV_DEBUG), NULL, CL_CPM_LOG_2_CNT_NEXT_NODE_GET_ERR, ("CPM-L"), (rc)); goto out_unlock; } } } } rc = CL_OK; out_unlock: clOsalMutexUnlock(gpClCpm->cpmTableMutex); fprintf(fp,"</cpm>\n"); return rc; }