Ignore:
Timestamp:
Sep 6, 2016, 4:31:46 PM (9 years ago)
Author:
bird
Message:

kmk: Added $(dircache-ctl cmd,...) function for controlling the directory content cache on windows. Some other optimizations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/dir-nt-bird.c

    r2879 r2886  
    7575/** Number of times dir_cache_invalid_missing was called. */
    7676static KU32 g_cInvalidates = 0;
     77/** Set by dir_cache_volatile_dir to indicate that the user has marked the
     78 * volatile parts of the file system with custom revisioning and we only need to
     79 * flush these.  This is very handy when using a separate output directory
     80 * from the sources.  */
     81static KBOOL g_fFsCacheIsUsingCustomRevision = K_FALSE;
    7782
    7883
     
    505510}
    506511
    507 
    508 /**
    509  * Invalidate missing bits of the directory cache.
    510  *
    511  * This is called each time a make job completes.
    512  */
    513 void dir_cache_invalid_missing(void)
     512/**
     513 * Do cache invalidation after a job completes.
     514 */
     515void dir_cache_invalid_after_job(void)
     516{
     517    g_cInvalidates++;
     518    if (g_fFsCacheIsUsingCustomRevision)
     519        kFsCacheInvalidateCustomBoth(g_pFsCache);
     520    else
     521        kFsCacheInvalidateAll(g_pFsCache);
     522}
     523
     524/**
     525 * Invalidate the whole directory cache
     526 *
     527 * Used by $(dircache-ctl invalidate)
     528 */
     529void dir_cache_invalid_all(void)
    514530{
    515531    g_cInvalidates++;
     
    517533}
    518534
     535/**
     536 * Invalidate missing bits of the directory cache.
     537 *
     538 * Used by $(dircache-ctl invalidate-missing)
     539 */
     540void dir_cache_invalid_missing(void)
     541{
     542    g_cInvalidates++;
     543    kFsCacheInvalidateAll(g_pFsCache);
     544}
     545
     546/**
     547 * Invalidate the volatile bits of the directory cache.
     548 *
     549 * Used by $(dircache-ctl invalidate-missing)
     550 */
     551void dir_cache_invalid_volatile(void)
     552{
     553    g_cInvalidates++;
     554    if (g_fFsCacheIsUsingCustomRevision)
     555        kFsCacheInvalidateCustomBoth(g_pFsCache);
     556    else
     557        kFsCacheInvalidateAll(g_pFsCache);
     558}
     559
     560/**
     561 * Used by $(dircache-ctl ) to mark a directory subtree or file as volatile.
     562 *
     563 * The first call changes the rest of the cache to be considered non-volatile.
     564 *
     565 * @returns 0 on success, -1 on failure.
     566 * @param   pszDir      The directory (or file for what that is worth).
     567 */
     568int dir_cache_volatile_dir(const char *pszDir)
     569{
     570    KFSLOOKUPERROR enmError;
     571    PKFSOBJ pObj = kFsCacheLookupA(g_pFsCache, pszDir, &enmError);
     572    if (pObj)
     573    {
     574        KBOOL fRc = kFsCacheSetupCustomRevisionForTree(g_pFsCache, pObj);
     575        kFsCacheObjRelease(g_pFsCache, pObj);
     576        if (fRc)
     577        {
     578            g_fFsCacheIsUsingCustomRevision = K_TRUE;
     579            return 0;
     580        }
     581        error(reading_file, "failed to mark '%s' as volatile", pszDir);
     582    }
     583    else
     584        error(reading_file, "failed to mark '%s' as volatile (not found)", pszDir);
     585    return -1;
     586}
     587
Note: See TracChangeset for help on using the changeset viewer.