Exemple #1
0
static
DWORD
CdcPurgeCache(
    VOID
    )
{
    DWORD dwError = 0;
    PCDC_DB_ENTRY_W pEntries = NULL;
    DWORD dwDCCount = 0;
    DWORD dwIndex = 0;
    UINT64 iStart = 0;
    UINT64 iEnd = 0;
    iStart = VmAfdGetTimeInMilliSec();

    dwError = CdcDbEnumDCEntries(
                        &pEntries,
                        &dwDCCount
                        );
    BAIL_ON_VMAFD_ERROR(dwError);

    if (dwDCCount)
    {
        for (; dwIndex<dwDCCount; ++dwIndex)
        {
            dwError = CdcDbDeleteDCEntry(pEntries[dwIndex].pszDCName);
            BAIL_ON_VMAFD_ERROR(dwError);
        }
    }

    iEnd = VmAfdGetTimeInMilliSec();

cleanup:

    if (pEntries)
    {
        VmAfdFreeCdcDbEntriesW(pEntries, dwDCCount);
    }
    return dwError;
error:

    (DWORD)VmAfdAddDBSuperLogEntry(
                                gVmafdGlobals.pLogger,
                                iStart,
                                iEnd,
                                pEntries,
                                dwError);

    goto cleanup;
}
Exemple #2
0
static
DWORD
CdcPurgeCache(
    VOID
    )
{
    DWORD dwError = 0;
    PWSTR *ppszEntryNames = NULL;
    DWORD dwDCCount = 0;
    DWORD dwIndex = 0;

    dwError = CdcDbEnumDCEntries(
                        &ppszEntryNames,
                        &dwDCCount
                        );
    BAIL_ON_VMAFD_ERROR(dwError);

    if (dwDCCount)
    {
        for (; dwIndex<dwDCCount; ++dwIndex)
        {
            dwError = CdcDbDeleteDCEntry(ppszEntryNames[dwIndex]);
            BAIL_ON_VMAFD_ERROR(dwError);
        }
    }

cleanup:

    if (ppszEntryNames)
    {
        VmAfdFreeStringArrayW(ppszEntryNames, dwDCCount);
    }
    return dwError;
error:

    goto cleanup;
}
Exemple #3
0
static
DWORD
CdcRefreshCache(
    BOOL bPurgeRefresh,
    PCDC_DB_ENTRY_W pCdcEntry,
    DWORD dwCount
    )
{
    //TODO: Or simply always purge and repopulate?
    DWORD dwError = 0;
    PWSTR *ppszDomainControllers = NULL;
    DWORD dwDBDCCount = 0;
    DWORD dwDbIndex = 0;
    DWORD dwIndex = 0;
    PWSTR pwszDomainName = NULL;

    if (!pCdcEntry)
    {
        dwError = ERROR_INVALID_PARAMETER;
        BAIL_ON_VMAFD_ERROR(dwError);
    }

    dwError = VmAfSrvGetDomainName(&pwszDomainName);
    BAIL_ON_VMAFD_ERROR(dwError);

    if (bPurgeRefresh)
    {
        dwError = CdcDbEnumDCEntries(&ppszDomainControllers, &dwDBDCCount);
        BAIL_ON_VMAFD_ERROR(dwError);

        for (; dwDbIndex<dwDBDCCount; ++dwDbIndex)
        {
            BOOL bFoundDC = FALSE;
            for (dwIndex = 0;dwIndex < dwCount; ++dwIndex)
            {
               if (VmAfdStringIsEqualW(
                            ppszDomainControllers[dwDbIndex],
                            pCdcEntry[dwIndex].pszDCName,
                            FALSE
                     )
                  )
               {
                    pCdcEntry[dwIndex].cdcEntryStatus =
                                          CDC_DB_ENTRY_STATUS_UPDATE;
                    bFoundDC = TRUE;
                    break;
               }
            }

            if (!bFoundDC)
            {
               CdcDbDeleteDCEntry(ppszDomainControllers[dwDbIndex]);
            }
        }
    }

    for (dwIndex = 0; dwIndex < dwCount; ++dwIndex)
    {

        dwError = VmAfdAllocateStringW(
                                pwszDomainName,
                                &pCdcEntry[dwIndex].pszDomainName
                                );
        BAIL_ON_VMAFD_ERROR(dwError);

        switch (pCdcEntry[dwIndex].cdcEntryStatus)
        {
            case CDC_DB_ENTRY_STATUS_NEW:
                dwError = CdcDbAddDCEntry(&pCdcEntry[dwIndex]);
                break;

            case CDC_DB_ENTRY_STATUS_UPDATE:
                dwError = CdcDbUpdateDCEntry(&pCdcEntry[dwIndex]);
                break;

            default:
                dwError = ERROR_INVALID_PARAMETER;
                break;
        }
        BAIL_ON_VMAFD_ERROR(dwError);
    }

cleanup:

    if (ppszDomainControllers)
    {
        VmAfdFreeStringArrayW(ppszDomainControllers, dwDBDCCount);
    }
    VMAFD_SAFE_FREE_MEMORY(pwszDomainName);
    return dwError;
error:

    goto cleanup;
}