ClRcT clMsgQueueUnlinkToServer(ClNameT *pQName)
{
    ClRcT rc;
    /* Look up msg queue in the cached checkpoint */
    ClMsgQueueCkptDataT queueData;
    if(clMsgQCkptExists((ClNameT *)pQName, &queueData) == CL_FALSE)
    {
        rc = CL_MSG_RC(CL_ERR_DOESNT_EXIST);
        clLogError("MSG", "UNL", "Failed to get the message queue information.");
        goto error_out;
    }

    /* Get Ioc address of the given MSG queue */
    ClIdlHandleObjT idlObj = {0};
    ClIdlHandleT idlHandle = 0;

    memcpy(&idlObj, &gIdlUcastObj, sizeof(idlObj));
    if ((queueData.creationFlags == SA_MSG_QUEUE_PERSISTENT) &&
            (queueData.qServerAddress.nodeAddress != 0))
    {
        idlObj.address.address.iocAddress.iocPhyAddress = queueData.qServerAddress;
    }

    rc = clIdlHandleInitialize(&idlObj, &idlHandle);
    if(rc != CL_OK)
    {
        clLogError("MSG", "UNL", "Failed to initialize the IDL handle. error code [0x%x].", rc);
        goto error_out;
    }

    rc = VDECL_VER(clMsgQueueUnlinkClientSync, 4, 0, 0)(idlHandle, (ClNameT *)pQName);
    if(rc != CL_OK)
    {
        clLogError("MSG", "UNL", "Failed to close the message queue at message server. error code [0x%x].", rc);
    }

    clIdlHandleFinalize(idlHandle);

error_out:
    return rc;
}
#include <clMsgCkptServer.h>
#include <clMsgDebugInternal.h>
#include <clMsgFailover.h>
#include <clOsalApi.h>
#include <clMsgReceiver.h>
#include <clTaskPool.h>
#include <msgIdlClientCallsFromClientServer.h>
#include <msgIdlClientCallsFromServerServer.h>
#include <msgIdlClientQueueCallsFromClientServer.h>
#include <msgCltSrvClientCallsFromClientToClientServerServer.h>

ClRcT VDECL_VER(clMsgQueueUnlink, 4, 0, 0)(SaNameT *pQName)
{
    ClRcT rc=CL_OK;  /* Return OK even if the message queue does not exist, because the end state is the same */
    ClMsgQueueCkptDataT queueData;
    ClBoolT isExist = clMsgQCkptExists((SaNameT *)pQName, &queueData);

    CL_MSG_INIT_CHECK(rc);
    if( rc != CL_OK)
    {
        goto error_out;
    }
    if(queueData.creationFlags == SA_MSG_QUEUE_PERSISTENT)
    {
        rc = clMsgQueueDestroy((SaNameT *)pQName);
        if(rc != CL_OK)
        {
            clLogError("MSG", "QUL", "Failed to destroy msg queue [%.*s]. error code [0x%x].", pQName->length, pQName->value, rc);
            goto error_out;
        }
    }