ClRcT
clLogCompEntryUnpackNAdd(ClBufferHandleT        msg,
                         ClLogStreamOwnerDataT  *pStreamOwnerData)
{
    ClRcT             rc        = CL_OK;
    ClLogCompKeyT     compKey   = {0};
    ClLogCompKeyT     *pCompKey = NULL;
    ClLogSOCompDataT  compData  = {0};
    ClLogSOCompDataT  *pData    = NULL;

    CL_LOG_DEBUG_TRACE(("Enter"));

    rc = VDECL_VER(clXdrUnmarshallClLogCompKeyT, 4, 0, 0)(msg, &compKey);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("VDECL_VER(clXdrUnmarshallClLogCompKeyT, 4, 0, 0)(): rc[0x %x]", rc));
        return rc;
    }
    rc = VDECL_VER(clXdrUnmarshallClLogSOCompDataT, 4, 0, 0)(msg, &compData);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("VDECL_VER(clXdrUnmarshallClLogSOCompDataT, 4, 0, 0)(): rc[0x %x]", rc));    
        return rc;
    }

    pCompKey = (ClLogCompKeyT*)clHeapCalloc(1, sizeof(ClLogCompKeyT));
    if( NULL == pCompKey )
    {
        CL_LOG_DEBUG_ERROR(( "clHeapCalloc()"));
        return CL_LOG_RC(CL_ERR_NO_MEMORY);
    }    
    *pCompKey = compKey;
    CL_LOG_DEBUG_VERBOSE(("compKey.nodeAddress: %u", compKey.nodeAddr));
    CL_LOG_DEBUG_VERBOSE(("compKey.compId     : %u", compKey.compId));

    pData = (ClLogSOCompDataT*)clHeapCalloc(1, sizeof(ClLogSOCompDataT));
    if( NULL == pData )
    {
        CL_LOG_DEBUG_ERROR(( "clHeapCalloc()"));
        clHeapFree(pCompKey);
        return CL_LOG_RC(CL_ERR_NO_MEMORY);
    }    
    *pData = compData;
    CL_LOG_DEBUG_VERBOSE(("compData.refCount    : %u", pData->refCount));
    CL_LOG_DEBUG_VERBOSE(("compData.ackerCnt    : %u", pData->ackerCnt));
    CL_LOG_DEBUG_VERBOSE(("compData.nonAckerCnt : %u", pData->nonAckerCnt));

    rc = clCntNodeAdd(pStreamOwnerData->hCompTable, 
                      (ClCntKeyHandleT) pCompKey,
                      (ClCntDataHandleT) pData, NULL);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(( "clCntNodeAdd(): rc[0x %x]", rc));
        clHeapFree(pData);
        clHeapFree(pCompKey);
    }

    CL_LOG_DEBUG_TRACE(("Exit"));
    return CL_OK;
}
/**
 * Adds a new definition of transaction to txn-database
 */
ClRcT clTxnDbNewTxnDefnAdd(
        CL_IN   ClTxnDbHandleT      txnDb,
        CL_IN   ClTxnDefnT          *pNewTxn,
        CL_IN   ClTxnTransactionIdT *pTxnId)
{
    ClRcT       rc  = CL_OK;
    ClTxnDefnT  *pTxnDef;
    CL_FUNC_ENTER();

    rc = clCntDataForKeyGet(txnDb, (ClCntKeyHandleT) pTxnId, 
                            (ClCntDataHandleT *) &pTxnDef);
    if (CL_OK != rc)
    {
        rc = clCntNodeAdd(txnDb, 
                          (ClCntKeyHandleT) pTxnId, 
                          (ClCntDataHandleT) pNewTxn, 0);
    }
    else
    {
        rc = CL_ERR_DUPLICATE;
    }

    CL_FUNC_EXIT();
    return (CL_GET_ERROR_CODE(rc));
}
static ClRcT fileEntryRecoverBaseVersion(ClLogMasterEoDataT *pMasterEoEntry,
        ClBufferHandleT hFileEntryBuf)
{
    ClRcT rc = CL_OK;
    ClLogFileKeyT        fileKey       = {{0}};
    ClLogFileKeyT        *pFileKey     = NULL;
    ClLogFileDataT       *pFileData    = NULL;

    rc = clLogMasterFileKeyUnpack(&fileKey, hFileEntryBuf);
    if( CL_OK != rc )
    {
        return rc;
    }
    clLogInfo(CL_LOG_AREA_MASTER, CL_LOG_CTX_CKPT_READ,
              "Recreating files fileName: %.*s fileLocation: %.*s",
              fileKey.fileName.length, fileKey.fileName.pValue,
              fileKey.fileLocation.length, fileKey.fileLocation.pValue);

    rc = clLogFileKeyCreate(&fileKey.fileName, &fileKey.fileLocation,
                            pMasterEoEntry->maxFiles, &pFileKey);
    if( CL_OK != rc )
    {
        clHeapFree(fileKey.fileName.pValue);
        clHeapFree(fileKey.fileLocation.pValue);
        return rc;
    }
    clHeapFree(fileKey.fileName.pValue);
    clHeapFree(fileKey.fileLocation.pValue);

    /* find out the filelocation is available */
    pFileData = (ClLogFileDataT*) clHeapCalloc(1, sizeof(ClLogFileDataT));
    if( NULL == pFileData )
    {
        CL_LOG_DEBUG_ERROR(("clHeapCalloc()"));
        clLogFileKeyDestroy(pFileKey);
        return rc;
    }

    pFileData->nActiveStreams = 0;
    rc = clLogMasterFileDataRecreate(pFileData, hFileEntryBuf);
    if( CL_OK != rc )
    {
        clLogFileKeyDestroy(pFileKey);
        return rc;
    }

    rc = clCntNodeAdd(pMasterEoEntry->hMasterFileTable,
                      (ClCntKeyHandleT) pFileKey,
                      (ClCntDataHandleT) pFileData, NULL);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clCntNodeAdd()"));
        CL_LOG_CLEANUP(clCntDelete(pFileData->hStreamTable), CL_OK); //FIXME
        clHeapFree(pFileData);
        clLogFileKeyDestroy(pFileKey);
        return rc;
    }

    return rc;
}
static ClRcT clCorDeltaDbContAdd(ClCorDeltaSaveKeyT *deltaDbKey, ClDBRecordT deltaDbData, ClUint32T dataSize)
{
	ClRcT	rc = CL_OK;
	ClCorDeltaSaveKeyT *tempKey = deltaDbKey;
	ClCorDeltaContDataT *tempCont = clHeapCalloc(1, sizeof(ClCorDeltaContDataT));

    CL_ASSERT(tempCont != NULL);

    tempCont->data = deltaDbData;
    tempCont->dataSize = dataSize;

    if( tempKey == NULL || tempCont->data == NULL)
    {
		clLogWrite(CL_LOG_HANDLE_APP, CL_LOG_DEBUG, NULL,
				CL_LOG_MESSAGE_0_MEMORY_ALLOCATION_FAILED);
		CL_DEBUG_PRINT(CL_DEBUG_ERROR,(CL_COR_ERR_STR(CL_COR_ERR_NO_MEM)));
		return CL_COR_SET_RC(CL_COR_ERR_NO_MEM);
    }

    rc = clCntNodeAdd(gCorDeltaSaveKeyTable, (ClCntKeyHandleT) tempKey, (ClCntDataHandleT) tempCont , NULL);
    if(CL_OK != rc)
    {
        if (CL_GET_ERROR_CODE(rc) == CL_ERR_DUPLICATE)
            rc = CL_OK;
        else
            CL_COR_RETURN_ERROR(CL_DEBUG_ERROR, "Could not add node in the Delta Save Key Table", rc);    

        clHeapFree(tempCont);
    }  
	
	return rc;
}
コード例 #5
0
/*
 * Insert the class tab entry into the class id table.
 */
static ClRcT 
omClassEntryReload (ClCharT *pClassName, ClOmClassTypeT classId)
{
	ClRcT		rc = CL_OK;
    ClOmClassControlBlockT *pClassTab = NULL;
    ClCntNodeHandleT nodeHandle = 0;

    CL_FUNC_ENTER();

    if(!pClassName)
    {
        rc = CL_OM_SET_RC(CL_OM_ERR_NULL_PTR);
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("NULL PTR PASSED"));
        CL_FUNC_EXIT();
        return rc;
    }

	CL_DEBUG_PRINT(CL_DEBUG_TRACE, ("OM entry reload for class = %s, class type %d", pClassName, classId));

    /*
     * First check if the class id entry is already present in the om class id table.
     */
    if(clCntNodeFind(ghOmClassHashTbl, (ClCntKeyHandleT)(ClWordT)classId, &nodeHandle) == CL_OK)
        return CL_OK;

	/* Add this class entry into the OM class lookup table */
	rc = clCntNodeFind(ghOmClassNameHashTbl, (ClCntKeyHandleT)pClassName, &nodeHandle);
	if (rc != CL_OK)
    {
		CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Unable to find OM Class name [%s] entry in om class table",
                                        pClassName));
		return (rc);
    }
    
    rc = clCntNodeUserDataGet(ghOmClassNameHashTbl, nodeHandle, (ClCntDataHandleT*)&pClassTab);
    if(rc != CL_OK)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Unable to get data for OM Class [%s] from om class name table",
                                        pClassName));
        return rc;
    }

    /*
     * Insert this entry into the class id table.
     */
    pClassTab->eMyClassType = classId;

    rc = clCntNodeAdd(ghOmClassHashTbl, (ClCntKeyHandleT)(ClWordT)pClassTab->eMyClassType,
                      (ClCntDataHandleT)pClassTab, NULL);
    if(rc != CL_OK)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Unable to add entry [%#x] for class [%s] to OM class id table",
                                        classId, pClassName));
        return rc;
    }

   	CL_FUNC_EXIT();
	return (rc);
}
/* happens only once during the booting of the system */
ClRcT clCorMOIdNodeNameMapAdd(ClCorMOIdPtrT pMoId, ClNameT *nodeName)
{
    ClRcT rc;
    /* Add the mapping in both the hash tables */
    /* In this table key is node Name and value is MoId */
    /* allocate MoId first */
    ClCorMOIdPtrT keyMoId = clHeapAllocate(sizeof(ClCorMOIdT));
	ClNameT		  *dataNodeName  = clHeapAllocate (sizeof(ClNameT));
	ClNameT		  *keyNodeName  = clHeapAllocate (sizeof(ClNameT));
    ClCorNodeDataPtrT dataNode = clHeapAllocate(sizeof(ClCorNodeDataT));
    if(dataNode == NULL)
    { 
        CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Failed to allocate Node Data")); 
        return CL_COR_SET_RC(CL_COR_ERR_NO_MEM) ;
    }
    memset(&dataNode->nodeName, 0, sizeof(ClNameT));
    dataNode->pMoId = clHeapAllocate(sizeof(ClCorMOIdT));

    if( keyMoId == NULL || dataNodeName == NULL || dataNode->pMoId == NULL || keyNodeName == NULL)
    {
		clLogWrite(CL_LOG_HANDLE_APP, CL_LOG_DEBUG, NULL,
				CL_LOG_MESSAGE_0_MEMORY_ALLOCATION_FAILED);
		CL_DEBUG_PRINT(CL_DEBUG_ERROR,(CL_COR_ERR_STR(CL_COR_ERR_NO_MEM)));
		return CL_COR_SET_RC(CL_COR_ERR_NO_MEM);
    }

    memcpy(keyMoId, pMoId, sizeof(ClCorMOIdT));
    memcpy(dataNodeName, nodeName, sizeof(ClNameT));
    memcpy(dataNode->pMoId, pMoId, sizeof(ClCorMOIdT));
    memcpy(&dataNode->nodeName, nodeName, sizeof(ClNameT));
    memcpy(keyNodeName, nodeName, sizeof(ClNameT));

    rc = clCntNodeAdd(nodeNameToMoIdTableHandle, (ClCntKeyHandleT) dataNodeName, (ClCntDataHandleT )dataNode , NULL);
    
    if(CL_OK != rc)
        CL_COR_RETURN_ERROR(CL_DEBUG_ERROR, "Could not add node in nodeNameToMoIdHandle", rc);    
    
    /* MOID to Node Name map - In this table key is MOId and value is node name   */
    rc = clCntNodeAdd(moIdToNodeNameTableHandle, (ClCntKeyHandleT) keyMoId, (ClCntDataHandleT)keyNodeName, NULL);

    if(CL_OK != rc)
        CL_COR_RETURN_ERROR(CL_DEBUG_ERROR, "Could not add node in moIdToNodeNameHandle", rc);    
    
    return CL_OK;
}
/*
 * The cnt add function
 * The information is read from COR and then populated in the container
 * This api would be called as and when the object is created and the corresponding entry 
 * within the container needs to be added.
 */
ClRcT clAlarmPayloadCntAdd(ClAlarmInfoT *pAlarmInfo)
{
	ClRcT rc = CL_OK;
	ClCntNodeHandleT nodeH;
    ClAlarmPayloadCntT *payloadInfo;
    
    ClAlarmPayloadCntKeyT *pCntKey = clHeapAllocate(sizeof(ClAlarmPayloadCntKeyT));
    if(NULL == pCntKey)
    {
          CL_DEBUG_PRINT (CL_DEBUG_CRITICAL,("Memory allocation failed with rc 0x%x ", rc));
          return CL_ALARM_RC(CL_ALARM_ERR_NO_MEMORY);
    }    

    payloadInfo = NULL;
    pCntKey->probCause = pAlarmInfo->probCause;
    pCntKey->specificProblem = pAlarmInfo->specificProblem;
    pCntKey->moId = pAlarmInfo->moId;

    payloadInfo = clHeapAllocate(sizeof(ClAlarmPayloadCntT)+pAlarmInfo->len);
    if(NULL == payloadInfo)
    {
          CL_DEBUG_PRINT (CL_DEBUG_CRITICAL,("Memory allocation failed with rc 0x%x ", rc));
          clHeapFree(pCntKey);
          return CL_ALARM_RC(CL_ALARM_ERR_NO_MEMORY);
    }    
    payloadInfo->len = pAlarmInfo->len;
    memcpy(payloadInfo->buff, pAlarmInfo->buff, payloadInfo->len);

	clOsalMutexLock(gClAlarmPayloadCntMutex);        
    rc = clCntNodeFind(gPayloadCntHandle,(ClCntKeyHandleT)pCntKey,&nodeH);
	if(rc != CL_OK)
	{
		rc = clCntNodeAdd((ClCntHandleT)gPayloadCntHandle,
							(ClCntKeyHandleT)pCntKey,
							(ClCntDataHandleT)payloadInfo,
							NULL);
		if (CL_OK != rc)
		{
			CL_DEBUG_PRINT(CL_DEBUG_ERROR,("clCntNodeAdd failed with rc = %x\n", rc));
            clHeapFree(payloadInfo);
            clHeapFree(pCntKey);
        }
        CL_DEBUG_PRINT(CL_DEBUG_TRACE,("clCntNodeAdd adding payloadInfo->len : %d\n",payloadInfo->len));
	}
	else
	{
		CL_DEBUG_PRINT(CL_DEBUG_INFO,("Node already exist\n"));
        clHeapFree(payloadInfo);
        clHeapFree(pCntKey);
	}
	clOsalMutexUnlock(gClAlarmPayloadCntMutex);
	return rc;
}
コード例 #8
0
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;
}
/**
 * Adds information about participating component in the transaction for 
 * the given job
 * FIXMETHIS IS NOT MULTITHREAD SAFE
 */
ClRcT clTxnAppJobComponentAdd(
        CL_IN   ClTxnAppJobDefnT        *pTxnJobDefn, 
        CL_IN   ClIocPhysicalAddressT   txnCompAddress, 
        CL_IN   ClUint8T                configMask)
{
    ClRcT                   rc  = CL_OK;
    ClTxnAppComponentT      *pNewComp = NULL;

    CL_FUNC_ENTER();

    if (NULL == pTxnJobDefn)
    {
        CL_FUNC_EXIT();
        return (CL_ERR_NULL_POINTER);
    }

    pNewComp = (ClTxnAppComponentT *) clHeapCalloc(1,sizeof(ClTxnAppComponentT));
    if (NULL == pNewComp)
    {
        CL_FUNC_EXIT();
        return (CL_ERR_NO_MEMORY);
    }

    pNewComp->appCompAddress = txnCompAddress;
    pNewComp->configMask = configMask;

    CL_DEBUG_PRINT(CL_DEBUG_TRACE, ("Adding new component to txn-job %p\n", (ClPtrT) pTxnJobDefn));

    rc = clCntNodeAdd(pTxnJobDefn->compList,
                      (ClCntKeyHandleT) &(pNewComp->appCompAddress),
                      (ClCntDataHandleT) pNewComp, 0);
    if (CL_OK == rc)
    {
        pTxnJobDefn->compCount++;
    }
    else
    {
        clHeapFree(pNewComp);
        rc = CL_GET_ERROR_CODE(rc);
    }

    CL_FUNC_EXIT();
    return (rc);
}
コード例 #10
0
ClRcT   _clGmsDbAdd(
            CL_IN  const ClGmsDbT* const  gmsDb,
            CL_IN  const  ClGmsDbTypeT    type,
           /* Suppressing coverity warning for pass by value with below comment */
           // coverity[pass_by_value]
            CL_IN  const  ClGmsDbKeyT     key,
            CL_IN  const  void*    const  data)
{
    ClRcT   rc = CL_OK;
    ClCntKeyHandleT cntKey = NULL;

    if (gmsDb == (const void *)NULL)
        return CL_ERR_NULL_POINTER;

    rc = _clGmsDbGetKey(type, key, &cntKey);
   
    if (rc != CL_OK) return rc;

    rc = clCntNodeAdd(gmsDb->htbl[type], cntKey, (ClCntDataHandleT)data, NULL);

    return rc;
}
コード例 #11
0
/**
 * Add newly created job to transaction.
 * FIXME: THIS IS NOT MULTITHREAD SAFE
 */
ClRcT clTxnNewAppJobAdd(
        CL_IN   ClTxnDefnT          *pTxnDefn, 
        CL_IN   ClTxnAppJobDefnT    *pNewTxnJob)
{
    ClRcT   rc  = CL_OK;

    CL_FUNC_ENTER();

    if ( (NULL == pTxnDefn) || (NULL == pNewTxnJob) )
    {
        CL_FUNC_EXIT();
        return (CL_ERR_NULL_POINTER);
    }

    CL_DEBUG_PRINT(CL_DEBUG_TRACE, ("Inserting new job for txn %p\n", (ClPtrT) pTxnDefn));

    /* With RC2 enhancements, generate unique id for this job and update accordingly */
    clLogDebug("CMN", NULL,  
            "PID[%d], Adding job JOBID : {jobid: [0x%x] ]} for txn with TXNID: { txnId: [0x%x], mgrAdd : [0x%x]}",
            (int)getpid(),
            pNewTxnJob->jobId.jobId,
            pTxnDefn->clientTxnId.txnId,
            pTxnDefn->clientTxnId.txnMgrNodeAddress);

    rc = clCntNodeAdd(pTxnDefn->jobList, 
                      (ClCntKeyHandleT) &(pNewTxnJob->jobId), 
                      (ClCntDataHandleT) pNewTxnJob, 0);
    if (CL_OK != rc)
    {
        rc = CL_GET_ERROR_CODE(rc);
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, 
                ("Adding to the job list failed, [0x%x]", rc));
        return rc;
    }
    pTxnDefn->jobCount++;
    CL_FUNC_EXIT();
    return (rc);
}
コード例 #12
0
ClRcT   _clGmsNameIdDbAdd (ClCntHandleT  *dbPtr,
                           ClNameT       *name,
                           ClGmsGroupIdT  id)
{
    ClRcT   rc = CL_OK;
    ClGmsDbKeyT key = {{0}};
    ClGmsNodeIdPairT  *node = NULL;
    ClCntKeyHandleT cntKey = NULL;

    if ((dbPtr == NULL) || (name == NULL))
    {
        return CL_ERR_NULL_POINTER;
    }

    memcpy(&key.name, name, sizeof(ClNameT));
    rc = _clGmsDbGetKey(CL_GMS_NAME_ID_DB, key, &cntKey);

    if (rc != CL_OK)
    {
        return rc;
    }

    node = (ClGmsNodeIdPairT*)clHeapAllocate(sizeof(ClGmsNodeIdPairT));
    if (node == NULL)
    {
        return CL_ERR_NO_MEMORY;
    }
    memcpy(&node->name, name, sizeof(ClNameT));
    node->groupId = id;

    rc = clCntNodeAdd(*dbPtr, cntKey, (ClCntDataHandleT)node, NULL);
    if (rc != CL_OK)
    {
        clHeapFree(node);
    }
    return rc;
}
ClRcT clCntNodeAddAndNodeGet(ClCntHandleT containerHandle,
           ClCntKeyHandleT userKey,
           ClCntDataHandleT userData,
           ClRuleExprT* pExp, ClCntNodeHandleT* pNodeHandle)
{
    ClRcT rc = CL_OK;

    nullChkRet(pNodeHandle);

    rc = clCntNodeAdd(containerHandle, userKey, userData, pExp);
    if(CL_OK != rc)
    {
        return rc;
    }
    rc = clCntNodeFind (containerHandle, userKey, pNodeHandle);
    CL_ASSERT(rc == CL_OK); /* I just added it, so I should be able to find it! */
    
    if(CL_OK != rc)
    {
        return rc;
    }
        
    return CL_OK;
}
/**
 * API to register a service with transaction agent
 */
ClRcT clTxnAgentServiceRegister(
        CL_IN   ClInt32T                    serviceId, 
        CL_IN   ClTxnAgentCallbacksT        tCallback, 
        CL_OUT  ClTxnAgentServiceHandleT    *pHandle)
{
    /*
       This is registration request from a service hosted in this component.
       (There could be multiple such services).
       Store these callbacks in an appropriate data-structure indexed with 
       service-id (identication of service under considered).
    */
    ClRcT                       rc                  = CL_OK;
    ClUint8T                    serviceCapability   = 0xFF;
    ClTxnAgentCompServiceInfoT  *pNewCompService    = NULL;

    CL_FUNC_ENTER();

    CL_TXN_NULL_CHECK_RETURN(pHandle, CL_ERR_NULL_POINTER, ("Invalid handle\n"));
    if (NULL == clTxnAgntCfg)
    {
        clLogWrite(CL_LOG_HANDLE_APP, CL_LOG_ERROR, CL_TXN_AGENT_LIB,
                   CL_LOG_MESSAGE_0_COMPONENT_UNINITIALIZED);
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Agent library is not initialized. clTxnAgntCfg is NULL\n"));
        CL_FUNC_EXIT();
        return CL_TXN_RC(CL_ERR_NOT_INITIALIZED);
    }

    /* Validate callback function */
    if( (tCallback.fpTxnAgentJobPrepare == NULL) && 
        (tCallback.fpTxnAgentJobRollback == NULL) &&
        (tCallback.fpTxnAgentJobCommit != NULL) )
    {
        serviceCapability = CL_TXN_AGENT_SERVICE_1PC;
        clTxnMutexLock(clTxnAgntCfg->actMtx);
        /* Check if this is not the first one to declare as 1-PC Capable service */
        if ( (clTxnAgntCfg->agentCapability & 
                CL_TXN_AGENT_SERVICE_1PC) == CL_TXN_AGENT_SERVICE_1PC)
        {
            CL_DEBUG_PRINT(CL_DEBUG_ERROR, 
                    ("Txn-Agent does not allow more than one service of 1-PC Type"));
            CL_FUNC_EXIT();
            clTxnMutexUnlock(clTxnAgntCfg->actMtx);
            return CL_TXN_RC(CL_ERR_INVALID_PARAMETER);
        }
        clTxnMutexUnlock(clTxnAgntCfg->actMtx);
    }
    else if ( (tCallback.fpTxnAgentJobPrepare != NULL) &&
              (tCallback.fpTxnAgentJobCommit != NULL)  &&
              (tCallback.fpTxnAgentJobRollback != NULL) )
    {
        serviceCapability = CL_TXN_AGENT_SERVICE_2PC;
    }
    else
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Invalid parameter - callback function not defined properly"));
        CL_FUNC_EXIT();
        return CL_TXN_RC(CL_ERR_INVALID_PARAMETER);
    }

    /* Check if entry already exists or not */
    rc = clCntDataForKeyGet( (ClCntHandleT) clTxnAgntCfg->compServiceMap, 
                              (ClCntKeyHandleT) &serviceId, 
                              (ClCntDataHandleT *) &pNewCompService);
    if ( CL_OK == rc )
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Component-service already registered\n"));
        CL_FUNC_EXIT();
        return (CL_TXN_RC(CL_ERR_DUPLICATE));
    }

    pNewCompService = (ClTxnAgentCompServiceInfoT *) clHeapAllocate(sizeof(ClTxnAgentCompServiceInfoT));
    CL_TXN_NULL_CHECK_RETURN(pNewCompService, CL_ERR_NO_MEMORY, 
                             ("Failed to allocate memory\n"));

    memset(pNewCompService, 0, sizeof(ClTxnAgentCompServiceInfoT));
    pNewCompService->serviceType = serviceId;
    pNewCompService->serviceCapability = serviceCapability;

    pNewCompService->pCompCallbacks = 
        (ClTxnAgentCallbacksT *) clHeapAllocate(sizeof(ClTxnAgentCallbacksT));
    
    
    CL_TXN_NULL_CHECK_RETURN(pNewCompService->pCompCallbacks, CL_ERR_NO_MEMORY,
                             ("Failed to allocate memory\n"));
    memcpy(pNewCompService->pCompCallbacks, &tCallback, sizeof(ClTxnAgentCallbacksT));

    /* Put the entry into hash-map with service-id to be the key */
    rc = clCntNodeAdd(clTxnAgntCfg->compServiceMap, 
                       (ClCntKeyHandleT) &(pNewCompService->serviceType), 
                       (ClCntDataHandleT)pNewCompService, NULL);

    if (CL_OK != rc)
    {
        clHeapFree(pNewCompService->pCompCallbacks);
        clHeapFree(pNewCompService);
    }
    else 
    {
        /* Update agent-cfg */
        if (serviceCapability == CL_TXN_AGENT_SERVICE_1PC)
        {
#ifdef CL_TXN_DEBUG
            CL_DEBUG_PRINT(CL_DEBUG_ERROR,( "Service registered is 1pc\n"));
#endif
            clTxnAgntCfg->agentCapability |= CL_TXN_AGENT_SERVICE_1PC;
        }
        else
            clTxnAgntCfg->agentCapability |= CL_TXN_AGENT_SERVICE_2PC;

        *pHandle = (ClTxnAgentServiceHandleT )pNewCompService;
        clLogNotice("AGT", "INI",
                "Registered [%s] service successfully having serviceId [%d]", 
                (serviceCapability == CL_TXN_AGENT_SERVICE_1PC)?"READ": "2P",
                serviceId);
    }
    CL_TXN_RETURN_RC(rc, ("Failed to register new component-service rc:0x%x\n", rc));
}
ClRcT cpmNodeAdd(ClCharT *nodeName)
{
    ClRcT rc = CL_OK;
    ClCpmLT *cpm = NULL;
    ClUint16T nodeKey = 0;
    ClCpmSlotInfoT slotInfo = {0};

    if (!nodeName)
    {
        clLogError(CPM_LOG_AREA_CPM, CPM_LOG_CTX_CPM_MGM, "NULL pointer passed.");
        goto failure;
    }

    clOsalMutexLock(gpClCpm->cpmTableMutex);
    rc = cpmNodeFindLocked((SaUint8T *)nodeName, &cpm);
    clOsalMutexUnlock(gpClCpm->cpmTableMutex);
    if (cpm)
    {
        clLogWarning(CPM_LOG_AREA_CPM, CPM_LOG_CTX_CPM_MGM, "Node [%s] already exists on this node.", nodeName);
        rc = CL_CPM_RC(CL_ERR_ALREADY_EXIST);
        goto failure;
    }

    cpm = (ClCpmLT*) clHeapAllocate(sizeof(ClCpmLT));
    if (!cpm)
    {
        clLogError(CPM_LOG_AREA_CPM, CPM_LOG_CTX_CPM_MGM,
                   "Unable to allocate memory");
        goto failure;
    }

    memset(cpm, 0, sizeof(ClCpmLT));
    
    strncpy(cpm->nodeName, nodeName, strlen(nodeName));
    
    rc = clCksm16bitCompute((ClUint8T *)cpm->nodeName,
                            strlen(cpm->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;
    }

    /* 
     * Filling the CPML with defaults.  
     */

    saNameSet(&cpm->nodeType, nodeName);
    saNameSet(&cpm->nodeIdentifier, nodeName);
    /*
     * Set the class type to CLASS_C.
     */
    strncpy(cpm->classType, "CL_AMS_NODE_CLASS_C", sizeof(cpm->classType)-1);
    /*
     * Get the MOID of the master node. Assuming that node add is
     * only invoked on the master.
     */
    slotInfo.slotId = clIocLocalAddressGet();

    rc = clCpmSlotInfoGet(CL_CPM_SLOT_ID, &slotInfo);
    if(rc == CL_OK)
    {
        rc = cpmCorMoIdToMoIdNameGet(&slotInfo.nodeMoId, &cpm->nodeMoIdStr);
    }
    if(rc != CL_OK)
    {
        if((CL_GET_ERROR_CODE(rc) != CL_IOC_ERR_COMP_UNREACHABLE) && (CL_GET_ERROR_CODE(rc) != CL_ERR_NOT_EXIST) && (CL_GET_ERROR_CODE(rc) != CL_ERR_NOT_SUPPORTED))
        {
            goto failure;
        }
        else
        {
            rc = CL_OK;
            clLogWarning(CPM_LOG_AREA_CPM, CPM_LOG_CTX_CPM_MGM, "COR server not running so cannot discover the Node's MoId");
        }
    }

    clOsalMutexLock(gpClCpm->cpmTableMutex);

    rc = clCntNodeAdd(gpClCpm->cpmTable,
                      (ClCntKeyHandleT)(ClWordT)nodeKey,
                      (ClCntDataHandleT) cpm,
                      NULL);
    if (CL_OK != rc)
    {
        clLogError(CPM_LOG_AREA_CPM, CPM_LOG_CTX_CPM_MGM,
                   "Failed to add node to the CPM node table, "
                   "error [%#x]",
                   rc);
        clOsalMutexUnlock(gpClCpm->cpmTableMutex);
        goto failure;
    }

    ++gpClCpm->noOfCpm;

    clOsalMutexUnlock(gpClCpm->cpmTableMutex);

    /*
     * Add this to the slotinfo.
     */

    clOsalMutexLock(&gpClCpm->cpmMutex);
    rc = cpmSlotClassAdd(&cpm->nodeType, &cpm->nodeIdentifier, 0);
    clOsalMutexUnlock(&gpClCpm->cpmMutex);

    if(rc != CL_OK)
    {
        clLogError(CPM_LOG_AREA_CPM, CPM_LOG_CTX_CPM_MGM,
                   "Node [%s] class add returned [%#x]", cpm->nodeType.value, rc);
    }

    clLogNotice("DYN", "NODE", "Node [%s] added to the cpm table with identity [%.*s]",
                cpm->nodeName, cpm->nodeIdentifier.length, cpm->nodeIdentifier.value);
                
    return CL_OK;

    failure:
    return rc;
}
ClRcT
_ckptMasterPeerListInfoCreate(ClIocNodeAddressT nodeAddr,
                              ClUint32T         credential,
                              ClUint32T         replicaCount)
{
    CkptPeerInfoT  *pPeerInfo = NULL;
    ClRcT          rc         = CL_OK;


    /*
     * Allocate memory for storing peer info.
     */
    if (NULL == (pPeerInfo = (CkptPeerInfoT*) clHeapCalloc(1, 
                    sizeof(CkptPeerInfoT))))
    {
        rc = CL_CKPT_ERR_NO_MEMORY;
        CKPT_DEBUG_E(("PeerInfo No Memory\n")); 
        return rc;
    }

    /*
     * Copy the passed info.
     */
    pPeerInfo->addr         = nodeAddr;
    pPeerInfo->credential   = credential;
    pPeerInfo->available    = CL_CKPT_NODE_AVAIL;
    pPeerInfo->replicaCount = replicaCount;

    /* 
     * Create the list to store the client hdls that
     * will be opened on that node.
     */
    rc = clCntLlistCreate(ckptCkptListKeyComp, ckptCkptListDeleteCallback,ckptCkptListDeleteCallback, CL_CNT_UNIQUE_KEY, &pPeerInfo->ckptList);
    CKPT_ERR_CHECK(CL_CKPT_SVR,CL_LOG_SEV_ERROR, ("CkptList create failed rc[0x %x]\n",rc), rc);

    /* 
     * Create the list to store the master hdls for checkpoints that
     * will be created on that node.
     */
    rc = clCntLlistCreate(ckptMastHdlListtKeyComp, ckptMastHdlListDeleteCallback, ckptMastHdlListDeleteCallback, CL_CNT_UNIQUE_KEY, &pPeerInfo->mastHdlList);
    CKPT_ERR_CHECK(CL_CKPT_SVR,CL_LOG_SEV_ERROR, ("MastHdlList create failed rc[0x %x]\n",rc), rc);

    if(credential == CL_CKPT_CREDENTIAL_POSITIVE)
        gCkptSvr->masterInfo.availPeerCount++;

    /*
     * Add the node to the master's peer list.
     */
    rc = clCntNodeAdd(gCkptSvr->masterInfo.peerList, (ClPtrT)(ClWordT)nodeAddr, (ClCntDataHandleT)pPeerInfo, NULL);
    CKPT_ERR_CHECK(CL_CKPT_SVR,CL_LOG_SEV_ERROR, ("PeerInfo Add is failed rc[0x %x]\n",rc), rc);
    return rc;        

exitOnError:    
    /*
     * Do the necessary cleanup.
     */
    if (pPeerInfo->ckptList != 0)
        clCntDelete(pPeerInfo->ckptList);
    if (pPeerInfo->mastHdlList != 0)
        clCntDelete(pPeerInfo->mastHdlList);
    clHeapFree(pPeerInfo);
    return rc;
}
コード例 #17
0
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;
}
static ClRcT
clLogSvrCompEntryRecreate(ClLogSvrCommonEoDataT  *pSvrCommonEoEntry,
                          ClLogSvrEoDataT        *pSvrEoEntry,
                          ClCntNodeHandleT       hSvrStreamNode,
                          ClBufferHandleT        msg,
                          ClUint32T              compTableSize)
{
    ClRcT                rc              = CL_OK;
    ClUint32T            count           = 0;
    ClLogSvrStreamDataT  *pSvrStreamData = NULL;
    ClLogSvrCompDataT    *pCompData      = NULL;
    ClLogSvrCompKeyT     *pCompKey       = NULL;

    CL_LOG_DEBUG_TRACE(("Enter"));

    rc = clCntNodeUserDataGet(pSvrEoEntry->hSvrStreamTable, hSvrStreamNode,
                              (ClCntDataHandleT *) &pSvrStreamData);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clCntDataForNodeGet(): rc[0x %x]\n", rc));
        return rc;
    }
    for( count = 0; count < compTableSize; count++ )
    {
        pCompKey = (ClLogSvrCompKeyT*) clHeapCalloc(1, sizeof(ClLogSvrCompKeyT));
        if( NULL == pCompKey )
        {
            CL_LOG_DEBUG_ERROR(("clHeapCalloc()"));
            return CL_LOG_RC(CL_ERR_NULL_POINTER);
        }
        rc = clXdrUnmarshallClUint32T(msg, &pCompKey->componentId);
        if( CL_OK != rc )
        {
            CL_LOG_DEBUG_ERROR(("clXdrMarshallClUint32T(): rc[0x %x]", rc));
            clHeapFree(pCompKey);
            return rc;
        }
        pCompKey->hash = pCompKey->componentId % pSvrCommonEoEntry->maxComponents;

        pCompData = (ClLogSvrCompDataT*) clHeapCalloc(1, sizeof(ClLogSvrCompDataT));
        if( NULL == pCompData )
        {
            CL_LOG_DEBUG_ERROR(("clHeapCalloc()"));
            clHeapFree(pCompKey);
            return CL_LOG_RC(CL_ERR_NULL_POINTER);
        }
        rc = clXdrUnmarshallClUint32T(msg, &pCompData->refCount);
        if( CL_OK != rc )
        {
            CL_LOG_DEBUG_ERROR(("clXdrMarshallClUint32T(): rc[0x %x]", rc));
            clHeapFree(pCompData);
            clHeapFree(pCompKey);
            return rc;
        }
        rc = clXdrUnmarshallClUint32T(msg, &pCompData->portId);
        if( CL_OK != rc )
        {
            CL_LOG_DEBUG_ERROR(("clXdrMarshallClUint32T(): rc[0x %x]", rc));
            clHeapFree(pCompData);
            clHeapFree(pCompKey);
            return rc;
        }

        rc = clCntNodeAdd(pSvrStreamData->hComponentTable,
                          (ClCntKeyHandleT) pCompKey,
                          (ClCntDataHandleT) pCompData, NULL);
        if( CL_OK != rc )
        {
            CL_LOG_DEBUG_ERROR(("clCntNodeAdd(): rc[0x %x]\n", rc));
            clHeapFree(pCompData);
            clHeapFree(pCompKey);
            return rc;
        }
    }

    CL_LOG_DEBUG_TRACE(("Exit"));
    return rc;
}
コード例 #19
0
static ClRcT 
clOmClassNameInitialize (ClOmClassControlBlockT *pClassTab, char *pClassName, ClUint32T maxInstances, 
                         ClUint32T maxSlots)
{
	ClUint32T **tmp_ptr;
	ClUint32T  tmp_size;
	ClRcT		rc = CL_OK;

	CL_ASSERT(pClassTab);
    CL_FUNC_ENTER();

    /* Sanity check for pClassTab */
    if(pClassTab == NULL || !pClassName)
    {
        rc = CL_OM_SET_RC(CL_OM_ERR_NULL_PTR);
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("NULL PTR PASSED"));
        CL_FUNC_EXIT();
        return rc;
    }
	CL_DEBUG_PRINT(CL_DEBUG_TRACE, ("pClassTab = %p, Class = %s, maxInstances = %d, "
                                    "maxSlots = %d", (void *)pClassTab, pClassName, 
                                    (ClUint32T)maxInstances, maxSlots));

	/*  CL_DEBUG_PRINT(CL_DEBUG_TRACE, ("eClass = %d",(ClUint32T)classId)); */

	/*
	 * @todo: To validate the maxSlots field, it is not used 
     * in this release.
	 */

	/* Validate the input arguments */
	if (!maxInstances)
	{
		rc = CL_OM_SET_RC(CL_OM_ERR_INVALID_MAX_INSTANCE);
		CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Invalid (zero) max instances argument "
                                        "(rc = 0x%x)!\r\n", rc)); 
		return (rc);
	}

	/*
	 * Check if the instance table for the specified class is already
	 * allocated. If allocated take either of two actions.
	 * 1. Return an error ot the user and indicate already allocated
	 * 2. Run thru' all the instances and free up the objects that are
 	 *    allocated in the OM context. and release the instance table
	 *    to make room for the new one.
	 */
	if (pClassTab->pInstTab)
	{
		rc = CL_OM_SET_RC(CL_OM_ERR_INSTANCE_TAB_EXISTS);
		CL_DEBUG_PRINT(CL_DEBUG_ERROR, 
                       ("The Instance Table for this class already exists "
                        "(rc = 0x%x)!\r\n", rc));
		return (rc);
	}

	/* Allocate memory for the instance table for the specified class. */
	tmp_size = (maxInstances * sizeof(ClUint32T*));
	if ((tmp_ptr = (ClUint32T **)clHeapAllocate(tmp_size)) == NULL)
	{
		rc = CL_OM_SET_RC(CL_OM_ERR_NO_MEMORY);
		CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Not enough memory available in the "
                                        "system (rc = 0x%x)\r\n", rc));
		return (rc);
	}

	/* Now setup the Peer class table */
	pClassTab->pInstTab = tmp_ptr;

	/* Add this class entry into the OM class lookup table */
	rc = clCntNodeAdd(ghOmClassNameHashTbl, 
                      (ClCntKeyHandleT)pClassName, (ClCntDataHandleT)pClassTab, NULL);
	if (rc != CL_OK)
    {
		CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("%s: Failed to add OM class to hash table, "
                                        "w/ rc 0x%x!\r\n", __FUNCTION__, rc));
		return (rc);
    }
	gOmCfgData.numOfOmClasses++;
   	CL_FUNC_EXIT();
	return (rc);
}
static ClRcT cpmComponentAdd(ClCharT *compName)
{
    ClRcT rc = CL_CPM_RC(CL_ERR_NULL_POINTER);
    ClCpmCompConfigT compConfig = 
    {
        "",
        CL_FALSE,
        CL_AMS_COMP_PROPERTY_SA_AWARE,
        CL_CPM_COMP_SINGLE_PROCESS,
        "invalid",
        {(ClCharT*) "invalid", NULL},
        {NULL},
        "",
        "",
        0,
        0,
        0,
        0,
        0,
        {
            CL_CPM_COMPONENT_DEFAULT_HC_TIMEOUT,
            2 * CL_CPM_COMPONENT_DEFAULT_HC_TIMEOUT,
            CL_AMS_RECOVERY_NO_RECOMMENDATION
        }
    };
    ClCpmComponentT *comp = NULL;
    ClUint16T compKey = 0;
    const ClCharT *config = NULL;
    ClCharT cleanupCMD[CL_MAX_NAME_LENGTH];
        
    if (!compName)
    {
        clLogError(CPM_LOG_AREA_CPM, CPM_LOG_CTX_CPM_MGM,
                   "NULL pointer passed.");
        goto failure;
    }

    cleanupCMD[0] = 0;
    if( (config = getenv("ASP_CONFIG")) )
    {
        snprintf(cleanupCMD, sizeof(cleanupCMD), "%s/%s", config, CL_CPM_COMP_CLEANUP_SCRIPT);
        if(access(cleanupCMD, R_OK | X_OK))
            cleanupCMD[0] = 0;
    }
    rc = cpmCompFind((SaUint8T *)compName, gpClCpm->compTable, &comp);
    if (comp)
    {
        clLogWarning(CPM_LOG_AREA_CPM, CPM_LOG_CTX_CPM_MGM,
                     "Component [%s] already exists on this node",
                     compName);
        rc = CL_CPM_RC(CL_ERR_ALREADY_EXIST);
        goto failure;
    }

    strncpy(compConfig.compName, compName, CL_MAX_NAME_LENGTH-1);
    if(cleanupCMD[0])
        strncpy(compConfig.cleanupCMD, cleanupCMD, sizeof(compConfig.cleanupCMD)-1);

    rc = cpmCompConfigure(&compConfig, &comp);
    if (CL_OK != rc)
    {
        clLogError(CPM_LOG_AREA_CPM, CPM_LOG_CTX_CPM_MGM,
                   "Failed to configure component, error [%#x]",
                   rc);
        goto failure;
    }

    rc = clCksm16bitCompute((ClUint8T *) comp->compConfig->compName,
                            strlen(comp->compConfig->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;
    }

    clOsalMutexLock(gpClCpm->compTableMutex);
    rc = clCntNodeAdd(gpClCpm->compTable,
                      (ClCntKeyHandleT)(ClWordT)compKey,
                      (ClCntDataHandleT) comp,
                      NULL);
    if (CL_OK != rc)
    {
        clLogError(CPM_LOG_AREA_CPM, CPM_LOG_CTX_CPM_MGM,
                   "Failed to add node to the CPM component table, "
                   "error [%#x]",
                   rc);
        clOsalMutexUnlock(gpClCpm->compTableMutex);
        goto failure;
    }
    ++gpClCpm->noOfComponent;
    clOsalMutexUnlock(gpClCpm->compTableMutex);

    return CL_OK;

failure:
    return rc;
}
/*
 * Paket are added in the record after converting them in the nw order so msgid
 * here is network order. Called with lock held.
 */
ClRcT clRmdCreateAndAddRmdSendRecord(ClEoExecutionObjT *pThis,
                                     ClIocAddressT destAddr,
                                     ClUint32T hdrLen,
                                     ClBufferHandleT outMsgHdl,
                                     ClUint32T flags, ClRmdOptionsT *pOptions,
                                     ClRmdAsyncOptionsT *pAsyncOptions,
                                     ClBufferHandleT message,
                                     ClUint64T msgId, ClUint32T payloadLen,
                                     ClRmdRecordSendT ** ppSendRec)
{
    ClRmdRecordSendT *rec;

    ClRcT retVal = CL_OK;
    ClRcT retCode = 0;

    /*
     * it will be called only for async
     */
    CL_FUNC_ENTER();
    rec = (ClRmdRecordSendT*) clHeapAllocate((ClUint32T) sizeof(ClRmdRecordSendT));
    if (rec == NULL)
    {
        CL_FUNC_EXIT();
        return (CL_RMD_RC(CL_ERR_NO_MEMORY));
    }

    rec->flags = flags;
    rec->hdrLen = hdrLen;
    rec->recType.asyncRec.rcvMsg = NULL;
    rec->recType.asyncRec.outLen = payloadLen;
    rec->recType.asyncRec.priority = pOptions->priority;
    rec->recType.asyncRec.destAddr = destAddr;
    rec->recType.asyncRec.sndMsgHdl = message;
    rec->recType.asyncRec.timerID   = 0;
    rec->recType.asyncRec.outMsgHdl = outMsgHdl;

    /*
     * options can't be 0 as we are creating and passing it
     */
    rec->recType.asyncRec.noOfRetry = pOptions->retries;
    rec->recType.asyncRec.timeout = pOptions->timeout;
    rec->recType.asyncRec.cookie = pAsyncOptions->pCookie;
    rec->recType.asyncRec.func = pAsyncOptions->fpCallback;

    RMD_DBG4((" RMD CALL is Async and reply needed create the timer\n"));
    retVal =
        createAsyncSendTimer(&rec->recType.asyncRec,(ClPtrT)(ClWordT)msgId);

    if (retVal != CL_OK)
    {
        clHeapFree(rec);
        CL_FUNC_EXIT();
        return retVal;

    }

    retVal =
        clCntNodeAdd(((ClRmdObjT *) pThis->rmdObj)->sndRecContainerHandle,
                     (ClPtrT)(ClWordT)msgId, (ClCntDataHandleT) rec, NULL);
    if (retVal == CL_OK) *ppSendRec = rec;
    else
    {
        RMD_DBG4((" RMD  createandaddrec:node add failed1."
                  " Delete timer and return.\n"));

        /*
         * Free the timer additionally for Async Call
         */
        if (flags & CL_RMD_CALL_ASYNC)
            retCode = clTimerDeleteAsync(&rec->recType.asyncRec.timerID);

        clHeapFree(rec);
    }

    CL_FUNC_EXIT();
    return retVal;
}
コード例 #22
0
/*
 *  This function used to generate the OM for MOID and store it in OM db
 *  1. Get the OM class type from MOID.
 *  2. Get the OM class from the OM class type.
 *  3. Create the OM object for given MOID
 *  4. Then add OM object handle to prov OM db.
 *  5. Insert the OM object into MoId and OM Object table.
 */
ClRcT
clProvOmObjectPrepare( ClCorMOIdPtrT pFullMoId)
{
    ClCorClassTypeT moClassType = 0;
    ClOmClassTypeT  omClass     = 0;    
    ClHandleT       handle;
    void*           pOmObj      = NULL;
    ClRcT           rc          = CL_OK;
    ClProvTxnDataT  provTxnData = {0};
    ClRcT           retCode     = CL_OK;
    ClCorObjectHandleT corObjHandle = NULL;

    CL_FUNC_ENTER();

    rc = clCorMoIdToClassGet( pFullMoId, CL_COR_MO_CLASS_GET, &moClassType );
    CL_PROV_CHECK_RC1_LOG1( rc, CL_OK, CL_PROV_RC(CL_PROV_INTERNAL_ERROR), CL_LOG_ERROR,
                            CL_PROV_LOG_1_MO_CLASS_GET, rc );

    rc = clOmClassFromInfoModelGet( moClassType, CL_COR_SVC_ID_PROVISIONING_MANAGEMENT,
                                    &omClass );

    CL_PROV_CHECK_RC1_LOG1( rc, CL_OK, CL_PROV_RC(CL_PROV_INTERNAL_ERROR), CL_LOG_ERROR,
                            CL_PROV_LOG_1_GET_OM_CLASS, rc );

    retCode = clOmObjectCreate( omClass, 1, &handle, &pOmObj, ( void* )pFullMoId, sizeof( ClCorMOIdT ) );
    if (NULL == pOmObj)
    {
        CL_PROV_CHECK_RC1_EAQUAL_LOG0( pOmObj, NULL, retCode, CL_LOG_ERROR,
                                       CL_PROV_LOG_1_OM_OBJ_CREATE );
        CL_FUNC_EXIT();
        return retCode;
    }

    clOsalMutexLock( gClProvMutex );
    rc = clCntNodeAdd( gClProvOmHandleInfo, ( ClCntKeyHandleT )(ClWordT)handle, 0, NULL );
    clOsalMutexUnlock( gClProvMutex );
    CL_PROV_CHECK_RC1_LOG1( rc, CL_OK, CL_PROV_RC(CL_PROV_INTERNAL_ERROR), CL_LOG_INFORMATIONAL,
                            CL_PROV_LOG_1_CONTAINER_ADD, rc );

    rc = clOmMoIdToOmIdMapInsert( pFullMoId, handle );
    CL_PROV_CHECK_RC1_LOG1( rc, CL_OK, CL_PROV_RC(CL_PROV_INTERNAL_ERROR), CL_LOG_ERROR,
                            CL_PROV_LOG_1_MAP_MOID_OM, rc );

    provTxnData.provCmd    = CL_COR_OP_CREATE;
    provTxnData.pMoId      = pFullMoId;
    provTxnData.attrId     = CL_COR_INVALID_ATTR_ID;

    /* Call the application's Object Start callback function */

    if ((((CL_OM_PROV_CLASS *) pOmObj )->clProvObjectStart) != NULL)
    {
        (void) (((CL_OM_PROV_CLASS *) pOmObj )->clProvObjectStart(
                                                                  pFullMoId, 0));
    }

    /* Call the Validate callback */
    if( ( (CL_OM_PROV_CLASS *)pOmObj)->clProvObjectValidate )
    {
        retCode = ( (CL_OM_PROV_CLASS *)pOmObj)->clProvObjectValidate(pOmObj, 0, &provTxnData, 1);
    }
    else if( ( (CL_OM_PROV_CLASS *)pOmObj)->clProvValidate )
    {
        retCode = ((CL_OM_PROV_CLASS *) pOmObj)->clProvValidate(pOmObj, 0, &provTxnData);
    }
    else
    {
        retCode = CL_OK;
    }

    if (retCode != CL_OK)
    {
        clLogError("PRV", "VAL", CL_PROV_LOG_1_CREATE_VALIDATE, retCode);

        /* Call the rollback callback */
        if( ( (CL_OM_PROV_CLASS * )pOmObj )->clProvObjectRollback )
        {
            retCode =  ( (CL_OM_PROV_CLASS *)pOmObj)->clProvObjectRollback( pOmObj, 0, &provTxnData, 1);
        }
        else if ( ( (CL_OM_PROV_CLASS *)pOmObj)->clProvRollback )
        {
            retCode = ( ( CL_OM_PROV_CLASS * ) pOmObj )->clProvRollback( pOmObj, 0, &provTxnData );
        }
        else
        {
            retCode = CL_OK;
        }

        if (retCode != CL_OK)
        {
            clLogError("PRV", "VAL", CL_PROV_LOG_1_CREATE_ROLLBACK, retCode);
        }

        /* Call the application's Object End callback function */
        if (((CL_OM_PROV_CLASS *) pOmObj )->clProvObjectEnd != NULL)
        {
            (((CL_OM_PROV_CLASS *) pOmObj )->clProvObjectEnd(
                                                             pFullMoId, 0));
        }

        /* Remove the OM object */
        if ((rc = clOmObjectByReferenceDelete(pOmObj)) != CL_OK)
        {
            clLogError("OMC", "PRE", "Failed to delete the OM object. rc [0x%x]", rc);
        }

        /* Remove the MoId to OM Id mapping */
        if ((rc = clOmMoIdToOmIdMapRemove(pFullMoId)) != CL_OK)
        {
            clLogError("PRV", "PRE", "Failed to remove the MoId to OM Id mapping. rc [0x%x]", rc);
            CL_FUNC_EXIT();
            return rc;
        }

        CL_FUNC_EXIT();
        return (CL_OK);
    }

    /* Validate is successful, call the update callback function */
    if( ( (CL_OM_PROV_CLASS * )pOmObj)->clProvObjectUpdate )
    {
        retCode =  ( (CL_OM_PROV_CLASS *)pOmObj )->clProvObjectUpdate( pOmObj, 0, &provTxnData, 1);
    }
    else if ( ( (CL_OM_PROV_CLASS *)pOmObj)->clProvUpdate )
    {
        retCode = ( ( CL_OM_PROV_CLASS * ) pOmObj )->clProvUpdate( pOmObj, 0, &provTxnData );
    }
    else
    {
        retCode = CL_OK;
    }

    if (retCode != CL_OK)
    {
        clLogError("PRV", "PRE", CL_PROV_LOG_1_CREATE_UPDATE, rc);
    }

    /* Get the object handle */
    rc = clCorMoIdToObjectHandleGet(pFullMoId, &corObjHandle);
    if (rc != CL_OK)
    {
        clLogError("PRV", "PRE", "Failed to get Object Handle from MoId. rc [0x%x]", rc);
        return rc;
    }

    /* Do pre-provisioning for the attributes present in the object */
    if( ( (CL_OM_PROV_CLASS*)pOmObj)->clProvObjectValidate
        &&
        ( (CL_OM_PROV_CLASS *)pOmObj)->clProvObjectUpdate)
    {
        ClProvObjAttrArgsT provObjAttrArgs = {0};
        provObjAttrArgs.pMoId = pFullMoId;
        rc = clCorObjectAttributeWalk( corObjHandle, NULL, clProvObjAttrWalk, &provObjAttrArgs);
        if(rc == CL_OK && provObjAttrArgs.txnDataEntries > 0)
        {
            rc = ((CL_OM_PROV_CLASS*)pOmObj)->clProvObjectValidate(pOmObj, 0, 
                                                                   provObjAttrArgs.pProvTxnData,
                                                                   provObjAttrArgs.txnDataEntries);
            if(rc == CL_OK)
            {
                rc = ((CL_OM_PROV_CLASS*)pOmObj)->clProvObjectUpdate(pOmObj, 0,
                                                                     provObjAttrArgs.pProvTxnData,
                                                                     provObjAttrArgs.txnDataEntries);
            }
            else
            {
                if( ( (CL_OM_PROV_CLASS*)pOmObj)->clProvObjectRollback != NULL)
                {
                    rc =  ( (CL_OM_PROV_CLASS*)pOmObj)->clProvObjectRollback(pOmObj, 0,
                                                                             provObjAttrArgs.pProvTxnData,
                                                                             provObjAttrArgs.txnDataEntries);
                }
            }
        }
        clProvObjAttrFree(&provObjAttrArgs);
    }
    else
    {
        rc = clCorObjectAttributeWalk( corObjHandle, NULL, clProvAttrWalk, pFullMoId );
    }

    /* Calling Object-End callback function */
    if (((CL_OM_PROV_CLASS *) pOmObj )->clProvObjectEnd != NULL)
    {
        (((CL_OM_PROV_CLASS *) pOmObj )->clProvObjectEnd(
                                                         pFullMoId, 0));
    }

    clCorObjectHandleFree(&corObjHandle);

    CL_FUNC_EXIT();
    return (CL_OK);
}