static ClRcT
clLogMasterFileKeyUnpack(ClLogFileKeyT    *pFileKey,
                         ClBufferHandleT  hFileEntryBuf)
{
    ClRcT rc = CL_OK;
    CL_LOG_DEBUG_TRACE(("Enter"));

    rc = clXdrUnmarshallClStringT(hFileEntryBuf, &(pFileKey->fileLocation));
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clXdrUnmarshallClStringT(): rc[0x%x]", rc));
        return rc;
    }

    rc = clXdrUnmarshallClStringT(hFileEntryBuf, &(pFileKey->fileName));
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clXdrUnmarshallClStringT(): rc[0x%x]", rc));
        return rc;
    }

    CL_LOG_DEBUG_TRACE(("Exit"));
    return CL_OK;
}
ClRcT clLogMasterStreamCloseNotifyServer_4_0_0(ClEoDataT eoData, ClBufferHandleT inMsgHdl, ClBufferHandleT outMsgHdl)
{
    ClIdlContextInfoT *pIdlCtxInfo = NULL;
    ClRcT rc = CL_OK;
    ClStringT  pFileName;
    ClStringT  pFileLocation;
    SaNameT  pStreamName;
    ClLogStreamScopeT  pStreamScope;
    SaNameT  pStreamScopeNode;

    memset(&(pFileName), 0, sizeof(ClStringT));
    memset(&(pFileLocation), 0, sizeof(ClStringT));
    memset(&(pStreamName), 0, sizeof(SaNameT));
    memset(&(pStreamScope), 0, sizeof(ClLogStreamScopeT));
    memset(&(pStreamScopeNode), 0, sizeof(SaNameT));


    rc = clXdrUnmarshallClStringT( inMsgHdl,&(pFileName));
    if (CL_OK != rc)
    {
        goto LL0;
    }

    rc = clXdrUnmarshallClStringT( inMsgHdl,&(pFileLocation));
    if (CL_OK != rc)
    {
        goto LL1;
    }

    rc = clXdrUnmarshallSaNameT( inMsgHdl,&(pStreamName));
    if (CL_OK != rc)
    {
        goto LL2;
    }

    rc = clXdrUnmarshallClLogStreamScopeT_4_0_0( inMsgHdl,&(pStreamScope));
    if (CL_OK != rc)
    {
        goto LL3;
    }

    rc = clXdrUnmarshallSaNameT( inMsgHdl,&(pStreamScopeNode));
    if (CL_OK != rc)
    {
        goto LL4;
    }

    pIdlCtxInfo = (ClIdlContextInfoT *)clHeapAllocate(sizeof(ClIdlContextInfoT));
    if(pIdlCtxInfo == NULL)
    {
       return CL_IDL_RC(CL_ERR_NO_MEMORY);
    }
    memset(pIdlCtxInfo, 0, sizeof(ClIdlContextInfoT));
    pIdlCtxInfo->idlDeferMsg = outMsgHdl; 
    pIdlCtxInfo->inProgress  = CL_FALSE;
    rc = clIdlSyncPrivateInfoSet(LogidlSyncKey, (void *)pIdlCtxInfo);
    if (CL_OK != rc)
    {
        clHeapFree(pIdlCtxInfo);
        goto L0;
    }
    rc = clLogMasterStreamCloseNotify_4_0_0(&(pFileName), &(pFileLocation), &(pStreamName), pStreamScope, &(pStreamScopeNode));
    if(pIdlCtxInfo->inProgress == CL_FALSE)
    {
      clHeapFree(pIdlCtxInfo);
      pIdlCtxInfo = NULL;
    }
    if (CL_OK != rc)
    {
       goto L0;
    }
    
    rc = clXdrMarshallClStringT(&(pFileName), 0, 1);
    if (CL_OK != rc)
    {
        goto L1;
    }

    rc = clXdrMarshallClStringT(&(pFileLocation), 0, 1);
    if (CL_OK != rc)
    {
        goto L2;
    }

    rc = clXdrMarshallSaNameT(&(pStreamName), 0, 1);
    if (CL_OK != rc)
    {
        goto L3;
    }

    rc = clXdrMarshallClLogStreamScopeT_4_0_0(&(pStreamScope), 0, 1);
    if (CL_OK != rc)
    {
        goto L4;
    }

    rc = clXdrMarshallSaNameT(&(pStreamScopeNode), 0, 1);
    if (CL_OK != rc)
    {
        goto L5;
    }

    if(pIdlCtxInfo != NULL)
    {
      clHeapFree(pIdlCtxInfo);
      return rc;
    }
    
L5:    return rc;

LL4:  clXdrMarshallSaNameT(&(pStreamScopeNode), 0, 1);
LL3:  clXdrMarshallClLogStreamScopeT_4_0_0(&(pStreamScope), 0, 1);
LL2:  clXdrMarshallSaNameT(&(pStreamName), 0, 1);
LL1:  clXdrMarshallClStringT(&(pFileLocation), 0, 1);
LL0:  clXdrMarshallClStringT(&(pFileName), 0, 1);

    return rc;

L0:  clXdrMarshallClStringT(&(pFileName), 0, 1);
L1:  clXdrMarshallClStringT(&(pFileLocation), 0, 1);
L2:  clXdrMarshallSaNameT(&(pStreamName), 0, 1);
L3:  clXdrMarshallClLogStreamScopeT_4_0_0(&(pStreamScope), 0, 1);
L4:  clXdrMarshallSaNameT(&(pStreamScopeNode), 0, 1);


    return rc;
}
ClRcT clXdrUnmarshallClLogStreamAttrIDLT_4_0_0(ClBufferHandleT msg , void* pGenVar)
{
    ClLogStreamAttrIDLT_4_0_0* pVar = (ClLogStreamAttrIDLT_4_0_0*)pGenVar;
    ClRcT     rc     = CL_OK;
    ClUint32T length = 0;

    if ((void*)0 == pVar)
    {
        return CL_XDR_RC(CL_ERR_NULL_POINTER);
    }

    clXdrUnmarshallClUint32T(msg, &length);
    if( 0 == length)
    {
        pGenVar = NULL;
    }
    else
    {

    rc = clXdrUnmarshallClStringT(msg,&(pVar->fileName));
    if (CL_OK != rc)
    {
        return rc;
    }

    rc = clXdrUnmarshallClStringT(msg,&(pVar->fileLocation));
    if (CL_OK != rc)
    {
        return rc;
    }

    rc = clXdrUnmarshallClUint32T(msg,&(pVar->fileUnitSize));
    if (CL_OK != rc)
    {
        return rc;
    }

    rc = clXdrUnmarshallClUint32T(msg,&(pVar->recordSize));
    if (CL_OK != rc)
    {
        return rc;
    }

    rc = clXdrUnmarshallClUint16T(msg,&(pVar->haProperty));
    if (CL_OK != rc)
    {
        return rc;
    }

    rc = clXdrUnmarshallClLogFileFullActionT_4_0_0(msg,&(pVar->fileFullAction));
    if (CL_OK != rc)
    {
        return rc;
    }

    rc = clXdrUnmarshallClUint32T(msg,&(pVar->maxFilesRotated));
    if (CL_OK != rc)
    {
        return rc;
    }

    rc = clXdrUnmarshallClUint32T(msg,&(pVar->flushFreq));
    if (CL_OK != rc)
    {
        return rc;
    }

    rc = clXdrUnmarshallClInt64T(msg,&(pVar->flushInterval));
    if (CL_OK != rc)
    {
        return rc;
    }

    rc = clXdrUnmarshallClWaterMarkT_4_0_0(msg,&(pVar->waterMark));
    if (CL_OK != rc)
    {
        return rc;
    }

    rc = clXdrUnmarshallClUint16T(msg,&(pVar->syslog));
    if (CL_OK != rc)
    {
        return rc;
    }

    }

    return rc;
}
ClRcT
clLogClntStreamListGet(ClBufferHandleT   msg,
                       ClLogStreamInfoT  *pLogStreams)
{
    ClRcT                rc           = CL_OK;
    ClLogStreamInfoT     *pTempBuffer = pLogStreams;
    ClUint32T            count        = 0;
    ClUint32T            strmCnt      = 0;
    ClUint32T            numFiles     = 0;
    ClUint32T            numStreams   = 0;
    ClUint32T            numStreamsUnpacked = 0;
    ClLogStreamAttrIDLT  streamAttr   = {{0}};

    CL_LOG_DEBUG_TRACE(("Enter"));

    rc = clXdrUnmarshallClUint32T(msg, &numFiles);
    if( CL_OK != rc )
    {
        return rc;
    }
    for( count = 0; count < numFiles; count++)
    {
        memset(&streamAttr, '\0', sizeof(ClLogStreamAttrIDLT));
        rc = VDECL_VER(clXdrUnmarshallClLogStreamAttrIDLT, 4, 0, 0)(msg, &streamAttr);
        if( CL_OK != rc )
        {
            break;
        }

        if(streamAttr.fileName.pValue)
            clHeapFree(streamAttr.fileName.pValue);

        if(streamAttr.fileLocation.pValue)
            clHeapFree(streamAttr.fileLocation.pValue);

        rc = clXdrUnmarshallClStringT(msg, &streamAttr.fileName); 
        if( CL_OK != rc )
        {
            break;
        }
        rc = clXdrUnmarshallClStringT(msg, &streamAttr.fileLocation);
        if( CL_OK != rc )
        {
            clHeapFree(streamAttr.fileName.pValue);
            break;
        }

        rc = clXdrUnmarshallClUint32T(msg, &numStreams);
        if( CL_OK != rc )
        {
            clHeapFree(streamAttr.fileLocation.pValue);
            clHeapFree(streamAttr.fileName.pValue);
            break;
        }

        for(strmCnt = 0; strmCnt < numStreams; strmCnt++)
        {
            rc = clLogClntStreamListEntryGet(msg, &streamAttr, pTempBuffer);
            if(CL_LOG_RC(CL_ERR_INVALID_PARAMETER) == rc )
            {
                rc = CL_OK;
                continue;
            }
            if( CL_OK != rc )
            {
                clHeapFree(streamAttr.fileLocation.pValue);
                clHeapFree(streamAttr.fileName.pValue);
                return rc;
            }
            pTempBuffer += 1;
            ++numStreamsUnpacked;
        }

        clHeapFree(streamAttr.fileLocation.pValue);
        clHeapFree(streamAttr.fileName.pValue);
    }
    /* Any failure, cleanup the filled Entries */
    if( CL_OK != rc )
    {
       for( strmCnt = 0; strmCnt < numStreamsUnpacked; strmCnt++) 
       {
         pTempBuffer = pLogStreams + strmCnt; 
         clHeapFree(pTempBuffer->streamAttr.fileName);
         clHeapFree(pTempBuffer->streamAttr.fileLocation);
         pTempBuffer->streamAttr.fileName = pTempBuffer->streamAttr.fileLocation = NULL;
         
       }
    }

    CL_LOG_DEBUG_TRACE(("Exit"));
    return rc;
}
static ClRcT
clLogSvrStreamEntryUnpackNAdd(ClLogSvrEoDataT        *pSvrEoEntry,
                              ClLogSvrCommonEoDataT  *pSvrCommonEoEntry,
                              ClBufferHandleT         msg,
                              ClUint32T               dsId)
{
    ClRcT             rc              = CL_OK;
    SaNameT           streamName      = {0};
    SaNameT           streamScopeNode = {0};
    ClUint32T         compTableSize   = 0;
    ClCntNodeHandleT  hSvrStreamNode   = CL_HANDLE_INVALID_VALUE;
    ClLogStreamKeyT   *pStreamKey     = NULL;
    ClStringT shmName = {0};
    ClStringT fileName = {0};
    ClStringT fileLocation = {0};

    CL_LOG_DEBUG_TRACE(("Enter"));

    rc = clLogSvrStreamTableGet(pSvrEoEntry);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clLogSvrStreamTableCreate(): rc[0x %x]\n", rc));
        return rc;
    }
    rc = clXdrUnmarshallSaNameT(msg, &streamName);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clXdrUnmarshallSaNameT(): rc[0x %x]\n", rc));
        return rc;
    }
    CL_LOG_DEBUG_VERBOSE(("streamName: %*s", streamName.length, streamName.value));

    rc = clXdrUnmarshallSaNameT(msg, &streamScopeNode);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clXdrUnmarshallSaNameT(): rc[0x %x]\n", rc));
        return rc;
    }
    CL_LOG_DEBUG_VERBOSE(("streamScopeNode: %*s", streamScopeNode.length, streamScopeNode.value));

    rc = clXdrUnmarshallClStringT(msg, &fileName);
    if(CL_OK != rc)
    {
        CL_LOG_DEBUG_ERROR(("clXdrUnmarshallClStringT(): rc[%#x]\n", rc));
        return rc;
    }
    rc = clXdrUnmarshallClStringT(msg, &fileLocation);
    if(CL_OK != rc)
    {
        CL_LOG_DEBUG_ERROR(("clXdrUnmarshallClStringT(): rc[%#x]\n", rc));
        return rc;
    }

    rc = clXdrUnmarshallClUint32T(msg, &compTableSize);
    if( CL_OK != rc )
    {
        CL_LOG_DEBUG_ERROR(("clXdrUnmarshallClUint32T(): rc[0x %x]\n", rc));
        return rc;
    }
    CL_LOG_DEBUG_VERBOSE(("compSize : %u", compTableSize));

    rc = clLogStreamKeyCreate(&streamName, &streamScopeNode, pSvrCommonEoEntry->maxStreams, &pStreamKey);
    if( CL_OK != rc )
    {
        return rc;
    }
    rc = clLogShmNameCreate(&streamName,&streamScopeNode,&shmName);
    if( CL_OK != rc )
    {
        return rc;
    }

    clLogInfo("LOG","CRT","Recreating log stream [%*s] shared memory [%*s] located at [%*s] from persistent checkpoint",streamName.length,streamName.value,shmName.length,shmName.pValue,streamScopeNode.length, streamScopeNode.value);

    rc = clLogSvrStreamEntryAdd(pSvrEoEntry, pSvrCommonEoEntry, pStreamKey, &shmName, &hSvrStreamNode);
    clHeapFree(shmName.pValue);
    shmName.pValue=NULL;
    shmName.length=0;

    if (CL_ERR_DUPLICATE == CL_GET_ERROR_CODE(rc))    /* But if it is a duplicate stream should we do the items below? (if so we need to load hSvrStreamNode...) */
    {
        return rc;
    }

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

    rc = clLogSvrCompEntryRecreate(pSvrCommonEoEntry, pSvrEoEntry,hSvrStreamNode, msg, compTableSize);
    if(( CL_OK != rc )&&(CL_ERR_DUPLICATE != CL_GET_ERROR_CODE(rc)))
    {
        CL_LOG_CLEANUP(clCntNodeDelete(pSvrEoEntry->hSvrStreamTable, hSvrStreamNode), CL_OK);
        return rc;
    }

    rc = clLogSvrShmOpenNFlusherCreate(pSvrEoEntry, &streamName, &streamScopeNode, &fileName, &fileLocation, hSvrStreamNode, dsId);
    if (( CL_OK != rc )&&(CL_ERR_DUPLICATE != CL_GET_ERROR_CODE(rc)))
    {
        CL_LOG_DEBUG_ERROR(("clLogSvrShmOpenAndFlusherCreate(): rc[0x %x]\n", rc));
        CL_LOG_CLEANUP(clCntNodeDelete(pSvrEoEntry->hSvrStreamTable, hSvrStreamNode), CL_OK);
    }

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