ClRcT
clLogStreamOwnerEntrySerialiser(ClUint32T  dsId,
                                ClAddrT    *pBuffer,
                                ClUint32T  *pSize,
                                ClPtrT     cookie)
{
    ClRcT      rc          = CL_OK;
    ClBufferHandleT  msg = (ClBufferHandleT) cookie;

    CL_LOG_DEBUG_TRACE(("Enter"));

    rc = clBufferLengthGet(msg, pSize);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clBufferLengthGet(): rc[0x %x]", rc));
        return rc;
    }
    *pBuffer = (ClAddrT)clHeapCalloc(*pSize, sizeof(ClUint8T));
    if( NULL == *pBuffer )
    {
        CL_LOG_DEBUG_ERROR(("clHeapCalloc()"));
        return rc;
    }    
    rc = clBufferNBytesRead(msg, (ClUint8T *) *pBuffer, pSize); 
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clBufferNBytesRead(): rc[0x %x]", rc));
        clHeapFree(*pBuffer);
        return rc;
    }
        
    CL_LOG_DEBUG_TRACE(("Exit"));
    return rc;
}    
ClRcT
clLogMasterCompData2BufferGet(ClLogCompDataT  *pCompData,
                              ClUint8T        **ppBuffer,
                              ClUint32T       *pDataSize)
{
    ClRcT            rc  = CL_OK;
    ClBufferHandleT  msg = CL_HANDLE_INVALID_VALUE;

    CL_LOG_DEBUG_TRACE(("Enter"));

    rc = clBufferCreate(&msg);
    if(CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clBufferCreate(): rc[0x %x]", rc));
        return rc;
    }

    rc = VDECL_VER(clXdrMarshallClLogCompDataT, 4, 0, 0)(pCompData, msg, 0);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clLogMarshallClLogCompDataT(): rc[0x %x]", rc));
        CL_LOG_CLEANUP(clBufferDelete(&msg), CL_OK);
        return rc;
    }

    rc = clBufferLengthGet(msg, pDataSize);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clBufferLengthGet(): rc[0x %x]", rc));
        CL_LOG_CLEANUP(clBufferDelete(&msg), CL_OK);
        return rc;
    }

    *ppBuffer = (ClUint8T*) clHeapCalloc(*pDataSize, sizeof(ClUint8T));
    if( NULL == *ppBuffer )
    {
        CL_LOG_DEBUG_ERROR(("clHeapCalloc()"));
        CL_LOG_CLEANUP(clBufferDelete(&msg), CL_OK);
        return CL_LOG_RC(CL_ERR_NO_MEMORY);
    }

    rc = clBufferNBytesRead(msg, *ppBuffer, pDataSize);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clBufferNBytesRead(): rc[0x %x]", rc));
        clHeapFree(*ppBuffer);
        CL_LOG_CLEANUP(clBufferDelete(&msg), CL_OK);
        return rc;
    }
    CL_LOG_CLEANUP(clBufferDelete(&msg), CL_OK);

    CL_LOG_DEBUG_TRACE(("Exit"));
    return CL_OK;
}
ClRcT clDebugPrintFinalize(ClDebugPrintHandleT* handle, char** buf)
{
    ClUint32T len = 0;
    ClRcT rc = CL_OK;
    ClBufferHandleT* msg = (ClBufferHandleT*)handle;

    if (NULL == buf)
    {
        return CL_DEBUG_RC(CL_ERR_NULL_POINTER);
    }

    rc = clBufferLengthGet(*msg, &len);
    if (CL_OK != rc)
    {
        return rc;
    }

    *buf = (char*)clHeapAllocate(len + 1);
    if (CL_OK != rc)
    {
        return CL_DEBUG_RC(CL_ERR_NO_MEMORY);
    }

    rc = clBufferNBytesRead(*msg, (ClUint8T*)*buf, &len);
    if (CL_OK != rc)
    {
        clHeapFree(*buf);
        *buf = NULL;
        return rc;
    }
    (*buf)[len] = '\0';

    clBufferDelete(msg);
    *msg = 0;

    return rc;
}
/**
 * Serializer function for transaction state
 */
static ClRcT _clTxnServiceCkptTxnStatePack(
    CL_IN   ClUint32T   dataSetId,
    CL_OUT  ClAddrT     *ppData,
    CL_OUT  ClUint32T   *pDataLen,
    CL_IN   ClPtrT      cookie)
{
    ClRcT                   rc  = CL_OK;
    ClTxnTransactionIdT     *pTxnId;
    ClBufferHandleT  msgHandle;
    ClUint32T               msgLen;

    CL_FUNC_ENTER();

    pTxnId = (ClTxnTransactionIdT *) cookie;

    CL_DEBUG_PRINT(CL_DEBUG_TRACE, ("To checkpoint recovery-log of txn 0x%x:0x%x",
                                    pTxnId->txnMgrNodeAddress, pTxnId->txnId));

    rc = clBufferCreate(&msgHandle);

    if (CL_OK == rc)
    {
        rc = clTxnRecoveryLogPack(pTxnId, msgHandle);

        *ppData = NULL;
        *pDataLen = 0;
        if (CL_OK == rc)
        {
            /* Copy the state-information from message-buffer to ppData */
            rc = clBufferLengthGet(msgHandle, &msgLen);
        }

        if (CL_OK == rc)
        {
            *pDataLen = msgLen;
            *ppData = (ClInt8T *) clHeapAllocate(msgLen);
            if ( *ppData == NULL )
            {
                CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Failed to allocate memory"));
                rc = CL_ERR_NO_MEMORY;
            }
        }

        if (CL_OK == rc)
        {
            rc = clBufferNBytesRead(msgHandle, (ClUint8T *) *ppData, &msgLen);
            if (CL_OK != rc)
            {
                clHeapFree(*ppData);
                *pDataLen = 0x0;
                CL_DEBUG_PRINT(CL_DEBUG_ERROR,
                               ("Failed to pack/serialize txn-defn[0x%x:0x%x] for ckpt. rc:0x%x",
                                pTxnId->txnMgrNodeAddress, pTxnId->txnId, rc));
                rc = CL_GET_ERROR_CODE(rc);
            }
        }
        rc = clBufferDelete(&msgHandle);
    }
    CL_FUNC_EXIT();
    return (rc);
}
/**
 * Internal function to pack/prepare state oa given transaction
 */
static ClRcT _clTxnServiceCkptTxnPack(
    CL_IN   ClUint32T   dataSetId,
    CL_OUT  ClAddrT     *ppData,
    CL_OUT  ClUint32T   *pDataLen,
    CL_IN   ClPtrT      cookie)
{
    ClRcT                   rc = CL_OK;
    ClTxnDefnT              *pTxnDefn;
    ClBufferHandleT  txnStateBuf;
    ClUint32T               msgLen;

    CL_FUNC_ENTER();

    pTxnDefn = (ClTxnDefnT *) cookie;

    if (pTxnDefn == NULL)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Null argument"));
        CL_FUNC_EXIT();
        return (CL_ERR_NULL_POINTER);
    }

    CL_DEBUG_PRINT(CL_DEBUG_TRACE,
                   ("Packing for data-set 0x%x for txn[0x%x:0x%x]", dataSetId,
                    pTxnDefn->serverTxnId.txnMgrNodeAddress, pTxnDefn->serverTxnId.txnId));

    /* Validate between dataSetId and txn-Id */
#if 0
    if ( (dataSetId  - CL_TXN_CKPT_TXN_DATA_SET_ID_OFFSET) != pTxnId->txnId)
    {
        CL_TXN_RETURN_RC(CL_ERR_INVALID_PARAMETER,
                         ("Invalid data-set(0x%x) for transaction-id(0x%x)\n",
                          dataSetId, pTxnId->txnId));
    }
#endif

    rc = clBufferCreate (&txnStateBuf);

    if (CL_OK == rc)
    {
        rc = clTxnStreamTxnCfgInfoPack (pTxnDefn, txnStateBuf);

        *ppData = NULL;
        *pDataLen = 0;

        if (CL_OK == rc)
        {
            /* Copy the state-information from message-buffer to ppData */
            rc = clBufferLengthGet(txnStateBuf, &msgLen);
        }

        if (CL_OK == rc)
        {
            *pDataLen = msgLen;
            *ppData = (ClInt8T *) clHeapAllocate(msgLen);
            if ( *ppData == NULL )
            {
                CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Failed to allocate memory"));
                rc = CL_ERR_NO_MEMORY;
            }
        }

        if (CL_OK == rc)
        {
            rc = clBufferNBytesRead(txnStateBuf, (ClUint8T *) *ppData, &msgLen);
            if (CL_OK != rc)
            {
                clHeapFree(*ppData);
                *pDataLen = 0x0;
                CL_DEBUG_PRINT(CL_DEBUG_ERROR,
                               ("Failed to pack/serialize txn-defn[0x%x:0x%x] for ckpt. rc:0x%x",
                                pTxnDefn->serverTxnId.txnMgrNodeAddress, pTxnDefn->serverTxnId.txnId, rc));
                rc = CL_GET_ERROR_CODE(rc);
            }


        }

        rc = clBufferDelete(&txnStateBuf);

    }
    CL_FUNC_EXIT();
    return (rc);
}
/**
 * Internal Function - used to pack/prepare data-set for checkpointing
 * transaction-service
 */
static ClRcT _clTxnServiceCkptAppStatePack(
    CL_IN   ClUint32T   dataSetId,
    CL_OUT  ClAddrT     *ppData,
    CL_OUT  ClUint32T   *pDataLen,
    CL_IN   ClPtrT      cookie)
{
    ClRcT                       rc = CL_OK;
    ClBufferHandleT      txnSrvcStateBuff;

    CL_FUNC_ENTER();
    /* Walk through the list of transactions available in activeTxnMap.
       For each transaction, call clTxnStreamTxnCfgInfoPack()
       For the received message-buffer, append it to the master message-buffer.
    */

    if ( (ppData == NULL) || (pDataLen == NULL) )
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Null arguements"));
        CL_FUNC_EXIT();
        return CL_ERR_NULL_POINTER;
    }

    rc = clBufferCreate (&txnSrvcStateBuff);

    if (CL_OK == rc)
    {
        clXdrMarshallClUint32T( &(clTxnServiceCfg->txnIdCounter), txnSrvcStateBuff, 0);

        /* Copy to buffer */
        *pDataLen = 0;
        *ppData = NULL;

        if (CL_OK == rc)
        {
            ClUint32T   ckptDataLen;

            rc = clBufferLengthGet(txnSrvcStateBuff, &ckptDataLen);

            if ( (CL_OK == rc) && ( ckptDataLen != 0) )
            {
                *ppData = (ClAddrT) clHeapAllocate(ckptDataLen);
                *pDataLen = ckptDataLen;
                if ( *ppData != NULL )
                {
                    rc = clBufferNBytesRead(txnSrvcStateBuff,
                                            (ClUint8T *) *ppData, &ckptDataLen);
                    if (CL_OK != rc)
                    {
                        *pDataLen = 0x0;
                        clHeapFree(*ppData);
                        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("Failed to create txn-service checkpoint. rc:0x%x", rc));
                        rc = CL_GET_ERROR_CODE(rc);
                    }


                }
                else
                {
                    rc = CL_ERR_NO_MEMORY;
                }
            }
            else
            {
                CL_DEBUG_PRINT(CL_DEBUG_ERROR,
                               ("Error while packing or no data rc:0x%x data-len:0%x", rc, ckptDataLen));
            }
        }

        rc = clBufferDelete(&txnSrvcStateBuff);

    }
    CL_FUNC_EXIT();
    return (rc);
}
ClRcT clEvtCpmReplyCb(ClUint32T data, ClBufferHandleT inMsgHandle,
                      ClBufferHandleT outMsgHandle)
{
    ClUint32T rc = CL_OK;

#if 0
    ClCpmLcmResponseT response = { {0, 0}, 0 };
    ClUint32T msgLength = 0;
    ClCharT logmsg[CL_MAX_NAME_LENGTH] = { 0 };
    ClCharT requesttype[CL_MAX_NAME_LENGTH] = { 0 };

    CL_FUNC_ENTER();
    rc = clBufferLengthGet(inMsgHandle, &msgLength);
    if (msgLength == sizeof(ClCpmLcmResponseT))
    {
        rc = clBufferNBytesRead(inMsgHandle, (ClUint8T *) &response,
                                &msgLength);
        if (rc != CL_OK)
        {
            clOsalPrintf("Unable to read the message. \n");
            goto failure;
        }
    }
    else
    {
        clOsalPrintf("Buffer read failure !\n");
        goto failure;
    }

    printf("Received reply for %s...\n", response.name);

    switch (response.requestType)
    {
    case CL_CPM_HEALTHCHECK:
        strcpy(requesttype, "CL_CPM_HEALTHCHECK");
        break;
    case CL_CPM_TERMINATE:
        strcpy(requesttype, "CL_CPM_TERMINATE");
        break;
    case CL_CPM_PROXIED_INSTANTIATE:
        strcpy(requesttype, "CL_CPM_PROXIED_INSTANTIATE");
        break;
    case CL_CPM_PROXIED_CLEANUP:
        strcpy(requesttype, "CL_CPM_PROXIED_CLEANUP");
        break;
    case CL_CPM_EXTN_HEALTHCHECK:
        strcpy(requesttype, "CL_CPM_EXTN_HEALTHCHECK");
        break;
    case CL_CPM_INSTANTIATE:
        strcpy(requesttype, "CL_CPM_INSTANTIATE");
        break;
    case CL_CPM_CLEANUP:
        strcpy(requesttype, "CL_CPM_CLEANUP");
        break;
    case CL_CPM_RESTART:
        strcpy(requesttype, "CL_CPM_RESTART");
        break;
    default:
        strcpy(requesttype, "Invalid request");
        break;
    }

    sprintf(logmsg, "%s %s request %s.\n", response.name, requesttype,
            response.returnCode == CL_OK ? "success" : "failure");
    printf(logmsg);

    CL_FUNC_EXIT();
    return CL_OK;

failure:
    CL_FUNC_EXIT();
#endif

    printf("Invoked the Callback for CPM API succesfully\n\r\n");

    return rc;
}
static ClRcT
clLogSvrStreamEntryPack(ClUint32T  dsId,
                        ClAddrT    *ppBuffer,
                        ClUint32T  *pBuffSize,
                        ClPtrT     cookie)
{
    ClRcT             rc            = CL_OK;
    ClBufferHandleT   msg           = CL_HANDLE_INVALID_VALUE;
    ClCntNodeHandleT  svrStreamNode = cookie;
    ClLogSvrEoDataT   *pSvrEoEntry  = NULL;

    CL_LOG_DEBUG_TRACE(("Enter"));

    CL_LOG_PARAM_CHK((NULL == ppBuffer), CL_LOG_RC(CL_ERR_NULL_POINTER));
    CL_LOG_PARAM_CHK((NULL == pBuffSize), CL_LOG_RC(CL_ERR_NULL_POINTER));

    rc = clLogSvrEoEntryGet(&pSvrEoEntry, NULL);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clLogSvrEoEntryGet(): rc[0x %x]\n", rc));
        return rc;
    }
    rc = clBufferCreate(&msg);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clBufferCreate(): rc[0x %x]", rc));
        return rc;
    }
    rc = clLogSvrStreamInfoPack(pSvrEoEntry, svrStreamNode, msg);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clLogSvrStreamInfoPack(): rc[0x %x]", rc));
        clBufferDelete(&msg);
        return rc;
    }
    rc = clBufferLengthGet(msg, pBuffSize);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clBufferLengthGet(): rc[0x %x]", rc));
        clBufferDelete(&msg);
        return rc;
    }
    *ppBuffer = (ClAddrT) clHeapCalloc(*pBuffSize, sizeof(ClUint8T));
    if( NULL == *ppBuffer )
    {
        CL_LOG_DEBUG_ERROR(("clHeapCalloc(): rc[0x %x]", rc));
        clBufferDelete(&msg);
        return rc;
    }
    rc = clBufferNBytesRead(msg, (ClUint8T *)*ppBuffer, pBuffSize);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clBufferNBytesWrite(): rc[0x %x]", rc));
        clHeapFree(*ppBuffer);
        clBufferDelete(&msg);
        return rc;
    }
    CL_LOG_CLEANUP(clBufferDelete(&msg), CL_OK);

    CL_LOG_DEBUG_TRACE(("Exit"));
    return rc;
}
static ClRcT
clLogSvrDsIdMapPack(ClUint32T  dsId,
                    ClAddrT    *ppBuffer,
                    ClUint32T  *pBuffSize,
                    ClPtrT      cookie)
{
    ClRcT            rc           = CL_OK;
    ClLogSvrEoDataT  *pSvrEoEntry = (ClLogSvrEoDataT *) cookie;
    ClBufferHandleT  inMsg        = CL_HANDLE_INVALID_VALUE;

    CL_LOG_DEBUG_TRACE(("Enter"));

    CL_LOG_PARAM_CHK((NULL == ppBuffer), CL_LOG_RC(CL_ERR_NULL_POINTER));
    CL_LOG_PARAM_CHK((NULL == pSvrEoEntry), CL_LOG_RC(CL_ERR_NULL_POINTER));
    CL_LOG_PARAM_CHK((CL_LOG_DSID_START != dsId),
                     CL_LOG_RC(CL_ERR_INVALID_PARAMETER));

    rc = clBufferCreate(&inMsg);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clBufferCreate(): rc[0x %x]", rc));
        return rc;
    }
    rc = clXdrMarshallClUint32T(&pSvrEoEntry->nextDsId, inMsg, 0);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clBufferCreate(): rc[0x %x]", rc));
        clBufferDelete(&inMsg);
        return rc;
    }
    rc = clLogBitmapPack(pSvrEoEntry->hDsIdMap, inMsg);
    if( CL_OK != rc )
    {
        clBufferDelete(&inMsg);
        return rc;
    }
    rc = clBufferLengthGet(inMsg, pBuffSize);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clBufferLengthGet(): rc[0x %x]", rc));
        clBufferDelete(&inMsg);
        return rc;
    }
    *ppBuffer = (ClAddrT) clHeapCalloc(*pBuffSize, sizeof(ClUint8T));
    if( NULL == *ppBuffer )
    {
        clBufferDelete(&inMsg);
        CL_LOG_DEBUG_ERROR(("clHeapCalloc(): rc[0x %x]", rc));
        return rc;
    }
    rc = clBufferNBytesRead(inMsg,(ClUint8T *) *ppBuffer, pBuffSize);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clBufferNBytesWrite(): rc[0x %x]", rc));
        clHeapFree(*ppBuffer);
        clBufferDelete(&inMsg);
        return rc;
    }
    CL_LOG_CLEANUP(clBufferDelete(&inMsg), CL_OK);

    CL_LOG_DEBUG_TRACE(("Exit"));
    return rc;
}
static ClRcT
clLogMasterFileEntryPack(ClLogMasterEoDataT  *pMasterEoEntry,
                         ClCntNodeHandleT    hFileNode,
                         ClCkptSectionIdT    *pSecId,
                         ClUint8T            **ppBuffer,
                         ClUint32T           *pBufferLen)
{
    ClBufferHandleT  hFileEntryBuf = CL_HANDLE_INVALID_VALUE;
    ClLogFileKeyT    *pFileKey     = NULL;
    ClLogFileDataT   *pFileData    = NULL;
    ClRcT            rc            = CL_OK;
    ClVersionT       version       = {  CL_RELEASE_VERSION, CL_MAJOR_VERSION, CL_MINOR_VERSION };
    CL_LOG_DEBUG_TRACE(("Enter"));

    rc = clCntNodeUserKeyGet(pMasterEoEntry->hMasterFileTable, hFileNode, (ClCntKeyHandleT *) &pFileKey);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clCntNodeUserKeyGet(): rc[0x %x]", rc));
        return rc;
    }

    rc = clCntNodeUserDataGet(pMasterEoEntry->hMasterFileTable, hFileNode, (ClCntDataHandleT *) &pFileData);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clCntNodeUserDataGet(): rc[0x %x]", rc));
        return rc;
    }

    rc = clLogMasterFileEntrySecIdGet(pFileKey, pSecId);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clLogMasterFileEntrySecIdGet(): rc[0x %x]", rc));
        return rc;
    }

    rc = clBufferCreate(&hFileEntryBuf);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clBufferCreate(): rc[0x %x]", rc));
        clHeapFree(pSecId->id);
        return rc;
    }
    rc = clXdrMarshallClVersionT(&version, hFileEntryBuf, 0);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clXdrMarshallClVersionT(): rc[%#x]", rc));
        CL_LOG_CLEANUP(clBufferDelete(&hFileEntryBuf), CL_OK);
        clHeapFree(pSecId->id);
        return rc;
    }

    rc = clLogMasterFileKeyPack(pFileKey, hFileEntryBuf);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clLogMasterFileKeyPack(): rc[0x %x]", rc));
        CL_LOG_CLEANUP(clBufferDelete(&hFileEntryBuf), CL_OK);
        clHeapFree(pSecId->id);
        return rc;
    }

    rc = clLogMasterFileDataPack(pFileData, hFileEntryBuf);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clLogMasterFileDataPack(): rc[0x %x]", rc));
        CL_LOG_CLEANUP(clBufferDelete(&hFileEntryBuf), CL_OK);
        clHeapFree(pSecId->id);
        return rc;
    }

    rc = clBufferLengthGet(hFileEntryBuf, pBufferLen);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clBufferLengthGet: rc[0x %x]", rc));
        CL_LOG_CLEANUP(clBufferDelete(&hFileEntryBuf), CL_OK);
        clHeapFree(pSecId->id);
        return rc;
    }

    /* rc = clBufferFlatten(hFileEntryBuf, ppBuffer); */
    *ppBuffer = (ClUint8T*) clHeapCalloc(*pBufferLen, sizeof(ClCharT));
    if( NULL == *ppBuffer )
    {
        CL_LOG_DEBUG_ERROR(("clHeapCalloc()"));
        CL_LOG_CLEANUP(clBufferDelete(&hFileEntryBuf), CL_OK);
        clHeapFree(pSecId->id);
        return rc;
    }
    rc = clBufferNBytesRead(hFileEntryBuf, (ClUint8T *) *ppBuffer, pBufferLen);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clBufferFlatten(): rc[0x %x]", rc));
        clHeapFree(*ppBuffer);
        CL_LOG_CLEANUP(clBufferDelete(&hFileEntryBuf), CL_OK);
        clHeapFree(pSecId->id);
        return rc;
    }
    CL_LOG_CLEANUP(clBufferDelete(&hFileEntryBuf), CL_OK);

    CL_LOG_DEBUG_TRACE(("Exit"));
    return rc;
}
/*
 * This function shall change when the CPM has a devoted queue to handle the death & leave 
 * Notifications. The pRecvParam shall be of use then for queuing.
 */
ClRcT clEoProcessIocRecvPortNotification(ClEoExecutionObjT* pThis, ClBufferHandleT eoRecvMsg, ClUint8T priority, ClUint8T protoType, ClUint32T length, ClIocPhysicalAddressT srcAddr)
{
    ClRcT rc = CL_OK;

    ClIocNotificationT notificationInfo = {0};
    ClUint32T msgLength = sizeof(ClIocNotificationT);
    ClIocNotificationIdT notificationId = 0;
    ClUint32T protoVersion = 0;

    CL_EO_LIB_VERIFY();

    rc = clBufferNBytesRead(eoRecvMsg, (ClUint8T *)&notificationInfo,
            &msgLength);
    if (rc != CL_OK)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR,
                ("EO: clBufferNBytesRead() Failed, rc=[0x%x]\n",
                 rc));
        goto out_delete;
    }
    
    protoVersion = ntohl(notificationInfo.protoVersion);
    if(protoVersion != CL_IOC_NOTIFICATION_VERSION)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR,
                       ("EO: Ioc recv notification received with version [%d]. Supported [%d]\n",
                        protoVersion, CL_IOC_NOTIFICATION_VERSION));
        goto out_delete;
    }

    notificationId = ntohl(notificationInfo.id); 

    switch(notificationId)
    {
        case CL_IOC_SENDQ_WM_NOTIFICATION:
            if(gIsNodeRepresentative == CL_FALSE)
            {
                CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Got sendq wm notification for non-node representative\n"));
                rc = CL_EO_RC(CL_ERR_BAD_OPERATION);
                goto out_delete;
            }
            /*fall through*/
        case CL_IOC_COMM_PORT_WM_NOTIFICATION:
            {
                ClIocNodeAddressT nodeId = 0;
                ClIocPortT portId = ntohl(notificationInfo.nodeAddress.iocPhyAddress.portId);

                ClIocNodeAddressT nodeAddress = ntohl(notificationInfo.nodeAddress.iocPhyAddress.nodeAddress);

                CL_CPM_IOC_ADDRESS_SLOT_GET(nodeAddress,nodeId); 

                rc = clEoIocWMNotification(CL_CID_IOC,portId,nodeId,&notificationInfo);
                if (rc != CL_OK)
                {
                    CL_DEBUG_PRINT(CL_DEBUG_ERROR,
                            ("EO: clEoIocWMNotification() Failed, rc=[0x%x]\n",
                             rc));
                    goto out_delete;
                }
            }
            break;
        case CL_IOC_NODE_ARRIVAL_NOTIFICATION:
        case CL_IOC_NODE_LINK_UP_NOTIFICATION:
        case CL_IOC_COMP_ARRIVAL_NOTIFICATION:
            /* Need to add functionality if the components wants a specific operation...*/
            clEoClientNotification(&notificationInfo);
            rc = CL_OK;
            break;
        case CL_IOC_NODE_LEAVE_NOTIFICATION:
        case CL_IOC_NODE_LINK_DOWN_NOTIFICATION:
        case CL_IOC_COMP_DEATH_NOTIFICATION:
            rc = clBufferDelete(&eoRecvMsg);
            CL_ASSERT(rc == CL_OK);
            rc = clRmdDatabaseCleanup(pThis->rmdObj, &notificationInfo);
            clEoClientNotification(&notificationInfo);
            return rc;
        default:
            CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Invalid notification id[%d]\n",
                        notificationId));
            rc = CL_EO_RC(CL_ERR_BAD_OPERATION);
            goto out_delete; 
    }

out_delete:
    clBufferDelete(&eoRecvMsg);

    return rc;
}
ClRcT
clLogSODsIdMapPack(ClUint32T  dsId,
                   ClAddrT    *pBuffer,
                   ClUint32T  *pSize,
                   ClPtrT     cookie)
{
    ClRcT                   rc     = CL_OK;
    ClLogSOEoDataT  *pSoEoEntry = NULL;
    ClBufferHandleT  msg        = 0;

    CL_LOG_DEBUG_TRACE(("Enter"));

    CL_LOG_PARAM_CHK( (CL_LOG_DSID_START != dsId),
            CL_LOG_RC(CL_ERR_INVALID_PARAMETER));
    CL_LOG_PARAM_CHK( (NULL == pBuffer), CL_LOG_RC(CL_ERR_NULL_POINTER));
    CL_LOG_PARAM_CHK( (NULL == pSize), CL_LOG_RC(CL_ERR_NULL_POINTER));
        
    rc = clLogStreamOwnerEoEntryGet(&pSoEoEntry, NULL);
    if( CL_OK != rc )
    {
        return rc;
    }
    
    rc = clBufferCreate(&msg);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clBufferCreate(): rc[0x %x]", rc));
        return rc;
    }
    rc = clXdrMarshallClUint32T(&pSoEoEntry->dsIdCnt, msg, 0);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clXdrMarshallClUint32T(): rc[0x %x]", rc));
        CL_LOG_CLEANUP(clBufferDelete(&msg), CL_OK);
        return rc;
    }
    rc = clLogBitmapPack(pSoEoEntry->hDsIdMap, msg);
    if( CL_OK != rc )
    {
        CL_LOG_CLEANUP(clBufferDelete(&msg), CL_OK);
        return rc;
    }    
    rc = clBufferLengthGet(msg, pSize);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clBufferLengthGet(): rc[0x %x]", rc));
        CL_LOG_CLEANUP(clBufferDelete(&msg), CL_OK);
        return rc;
    }
    *pBuffer = (ClAddrT)clHeapCalloc(*pSize, sizeof(ClInt8T));
    if( NULL == *pBuffer )
    {
        CL_LOG_DEBUG_ERROR(("clHeapCalloc()"));
        CL_LOG_CLEANUP(clBufferDelete(&msg), CL_OK);
        return rc;
    }    
    rc = clBufferNBytesRead(msg, (ClUint8T *) *pBuffer, pSize); 
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clBufferNBytesRead(): rc[0x %x]", rc));
        clHeapFree(*pBuffer);
        CL_LOG_CLEANUP(clBufferDelete(&msg), CL_OK);
        return rc;
    }
    CL_LOG_CLEANUP(clBufferDelete(&msg), CL_OK);

    CL_LOG_DEBUG_TRACE(("Exit"));
    return rc;
}