Example #1
0
static
VOID
_VMCAFreeRestHandle(
    PVMREST_HANDLE    pHandle,
    PREST_API_DEF     pRestApiDef
    )
{
    PREST_API_MODULE  pModule = NULL;

    if (pHandle)
    {
        if (pRestApiDef)
        {
            pModule = pRestApiDef->pModules;
            for (; pModule; pModule = pModule->pNext)
            {
                PREST_API_ENDPOINT pEndPoint = pModule->pEndPoints;
                for (; pEndPoint; pEndPoint = pEndPoint->pNext)
                {
                    (VOID)VmRESTUnRegisterHandler(
                            pHandle, pEndPoint->pszName);
                }
            }
        }
        VmRESTShutdown(pHandle);
    }
}
Example #2
0
static
VOID
_VMCARestFreeHandle(
    PVMREST_HANDLE    pHandle
    )
{
    DWORD iter = 0;
    DWORD dwError = 0;
    DWORD endPointCnt = 0;

    if (pHandle)
    {
       /*
        * REST library have detached threads, maximum time out specified is the max time
        * allowed for the threads to  finish their execution.
        * If finished early, it will return success.
        * If not able to finish in specified time, failure will be returned
        */
       dwError = VmRESTStop(pHandle, VMCA_REST_STOP_TIMEOUT_SEC);

        if (dwError != 0)
        {
            VMCA_LOG_WARNING("%s: rest server stop error:%d", __FUNCTION__, dwError);
        }

        endPointCnt = ARRAY_SIZE(restEndPoints);
        for (iter = 0; iter < endPointCnt; iter++)
        {
            (VOID)VmRESTUnRegisterHandler(
                    pHandle,
                    restEndPoints[iter]);
        }
        VmRESTShutdown(pHandle);
    }
}