ClRcT cpmInvocationAdd(ClUint32T cbType, void *data, ClInvocationT *invocationId, ClUint32T flags) { ClRcT rc = CL_OK; ClCpmInvocationT *temp = NULL; ClUint32T invocationKey = 0; if (cbType < 0x1LL || cbType >= CL_CPM_MAX_CALLBACK || invocationId == NULL) CL_CPM_CHECK(CL_LOG_SEV_ERROR, ("Invalid parameter passed \n"), CL_CPM_RC(CL_ERR_INVALID_PARAMETER)); temp = (ClCpmInvocationT *) clHeapAllocate(sizeof(ClCpmInvocationT)); if (temp == NULL) CL_CPM_CHECK(CL_LOG_SEV_ERROR, ("Unable to allocate memory \n"), CL_CPM_RC(CL_ERR_NO_MEMORY)); clOsalMutexLock(gpClCpm->invocationMutex); invocationKey = gpClCpm->invocationKey++; CL_CPM_INVOCATION_ID_GET((ClUint64T) cbType, (ClUint64T) invocationKey, *invocationId); temp->invocation = *invocationId; temp->data = data; temp->flags = flags; rc = clCntNodeAdd(gpClCpm->invocationTable, (ClCntKeyHandleT)&temp->invocation, (ClCntDataHandleT) temp, NULL); if (rc != CL_OK) { clLogError("NEW", "INVOCATION", "Invocation add for key [%#llx] returned [%#x]", temp->invocation, rc); goto withLock; } clLogDebug("NEW", "INVOCATION", "Added entry for invocation [%#llx]", temp->invocation); clOsalMutexUnlock(gpClCpm->invocationMutex); return rc; withLock: clOsalMutexUnlock(gpClCpm->invocationMutex); failure: if (temp != NULL) clHeapFree(temp); return rc; }
ClRcT cpmInvocationGetWithLock(ClInvocationT invocationId, ClUint32T *cbType, void **data) { ClRcT rc = CL_OK; ClCntNodeHandleT cntNodeHandle = 0; ClCpmInvocationT *invocationData = NULL; /* * Check the input parameter */ if ((data == NULL) || (cbType == NULL)) CL_CPM_CHECK(CL_LOG_SEV_ERROR, ("Invalid parameter passed \n"), CL_CPM_RC(CL_ERR_NULL_POINTER)); rc = clCntNodeFind(gpClCpm->invocationTable, (ClCntKeyHandleT)&invocationId, &cntNodeHandle); if (rc != CL_OK) goto failure; rc = clCntNodeUserDataGet(gpClCpm->invocationTable, cntNodeHandle, (ClCntDataHandleT *) &invocationData); if (rc != CL_OK) goto failure; *data = invocationData->data; CL_CPM_INVOCATION_CB_TYPE_GET(invocationId, *cbType); return rc; failure: return rc; }
ClRcT cliEOSetState(ClUint32T argc, ClCharT **argv, ClCharT **retStr) { ClRcT rc = CL_OK; ClEoIdT eoId; ClEoStateT state; ClCharT tempStr[256]; if (argc < THREE_ARGUMENT) { sprintf(tempStr, "%s%s%s", "Usage: EOStateSet <eoId> <state>\n", "\teoId[DEC]: Id assigned to an EO\n", "\tState[STRING]: SUSPEND/RESUME\n"); rc = CL_CPM_RC(CL_ERR_INVALID_PARAMETER); goto done; } else { eoId = cpmCliStrToInt(argv[1]); if (0 == strcmp(argv[2], "SUSPEND")) state = CL_EO_STATE_SUSPEND; else if (0 == strcmp(argv[2], "RESUME")) state = CL_EO_STATE_RESUME; else { sprintf(tempStr, "\n Improper state: State: SUSPEND/RESUME\n"); rc = CL_CPM_RC(CL_ERR_INVALID_PARAMETER); goto done; } rc = clCpmExecutionObjectStateSet(clIocLocalAddressGet(), eoId, state); if (rc == CL_OK) sprintf(tempStr, "\n State update Successful"); else sprintf(tempStr, "\n State update Failed"); } done: *retStr = (ClCharT *) clHeapAllocate(strlen(tempStr) + 1); if (*retStr == NULL) CL_CPM_CHECK(CL_DEBUG_ERROR, ("\n MAlloc Failed \n"), CL_CPM_RC(CL_ERR_NO_MEMORY)); strcpy(*retStr, tempStr); 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 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; }
ClRcT cpmInvocationAddKey(ClUint32T cbType, void *data, ClInvocationT invocationId, ClUint32T flags) { ClRcT rc = CL_OK; ClCpmInvocationT *temp = NULL; ClUint32T invocationKey = 0; if (cbType < 0x1LL || cbType >= CL_CPM_MAX_CALLBACK) CL_CPM_CHECK(CL_LOG_SEV_ERROR, ("Invalid parameter passed \n"), CL_CPM_RC(CL_ERR_INVALID_PARAMETER)); temp = (ClCpmInvocationT *) clHeapAllocate(sizeof(ClCpmInvocationT)); if (temp == NULL) CL_CPM_CHECK(CL_LOG_SEV_ERROR, ("Unable to allocate memory \n"), CL_CPM_RC(CL_ERR_NO_MEMORY)); clOsalMutexLock(gpClCpm->invocationMutex); temp->invocation = invocationId; temp->data = data; temp->flags = flags; CL_CPM_INVOCATION_KEY_GET(invocationId, invocationKey); rc = clCntNodeAdd(gpClCpm->invocationTable, (ClCntKeyHandleT)&temp->invocation, (ClCntDataHandleT) temp, NULL); if (rc != CL_OK) { if(CL_GET_ERROR_CODE(rc) == CL_ERR_DUPLICATE) { clLogWarning("ADD", "INVOCATION", "Invocation entry [%#llx] already exists", invocationId); rc = CL_OK; } else { clLogError("ADD", "INVOCATION", "Invocation entry [%#llx] returned [%#x]", invocationId, rc); } goto withLock; } /* * Try preventing reuse of the invocation key for new invocations. */ if(gpClCpm->invocationKey <= invocationKey) { gpClCpm->invocationKey = invocationKey + 1; } clLogDebug("ADD", "INVOCATION", "Added entry for invocation [%#llx]", invocationId); clOsalMutexUnlock(gpClCpm->invocationMutex); return rc; withLock: clOsalMutexUnlock(gpClCpm->invocationMutex); failure: if (temp != NULL) clHeapFree(temp); return rc; }