Example #1
0
static
VOID
LwSmTableWatchdog(
    PVOID pContext
    )
{
    DWORD error = 0;
    PSM_TABLE_ENTRY pEntry = pContext;
    PSM_TABLE_ENTRY pOtherEntry = NULL;
    LW_SERVICE_STATUS status = {0};
    PWSTR* ppServices = NULL;
    DWORD index = 0;

    error = LwSmTableStartRecursive(pEntry);
    BAIL_ON_ERROR(error);

    /* See if any reverse dependencies changed state without announcing it */
    error = LwSmTableGetEntryReverseDependencyClosure(pEntry, &ppServices);
    BAIL_ON_ERROR(error);

    for (index = 0; ppServices[index]; index++)
    {
        error = LwSmTableGetEntry(ppServices[index], &pOtherEntry);
        BAIL_ON_ERROR(error);

        error = LwSmTableGetEntryStatus(pOtherEntry, &status);
        BAIL_ON_ERROR(error);

        if (status.state == LW_SERVICE_STATE_DEAD)
        {
            (void) LwSmTableStartRecursive(pOtherEntry);
        }

        LwSmTableReleaseEntry(pOtherEntry);
        pOtherEntry = NULL;
    }

error:

    if (ppServices)
    {
        LwSmFreeStringList(ppServices);
    }

    if (pOtherEntry)
    {
        LwSmTableReleaseEntry(pOtherEntry);
    }

    LwSmTableReleaseEntry(pEntry);

    return;
}
Example #2
0
static
DWORD
LwSmShutdownService(
    PSM_TABLE_ENTRY pEntry
    )
{
    DWORD dwError = 0;
    PSM_TABLE_ENTRY pDep = NULL;
    PWSTR* ppwszDeps = NULL;
    size_t i = 0;

    dwError = LwSmTableGetEntryReverseDependencyClosure(pEntry, &ppwszDeps);
    BAIL_ON_ERROR(dwError);

    for (i = 0; ppwszDeps[i]; i++)
    {
        dwError = LwSmTableGetEntry(ppwszDeps[i], &pDep);
        BAIL_ON_ERROR(dwError);

        dwError = LwSmTableStopEntry(pDep);
        BAIL_ON_ERROR(dwError);

        LwSmTableReleaseEntry(pDep);
        pDep = NULL;
    }

    dwError = LwSmTableStopEntry(pEntry);
    BAIL_ON_ERROR(dwError);

cleanup:

    if (pDep)
    {
        LwSmTableReleaseEntry(pDep);
    }

    if (ppwszDeps)
    {
        LwSmFreeStringList(ppwszDeps);
    }

    return dwError;

error:

    goto cleanup;
}