Workaround another race condition issue
See https://bugzilla.redhat.com/show_bug.cgi?id=921706
This commit is contained in:
parent
58acd993cb
commit
f44bfad235
|
@ -545,6 +545,26 @@ FcCacheTimeValid (FcCache *cache, struct stat *dir_stat)
|
||||||
return cache->checksum == (int) dir_stat->st_mtime;
|
return cache->checksum == (int) dir_stat->st_mtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FcBool
|
||||||
|
FcCacheDirsValid (FcCache *cache)
|
||||||
|
{
|
||||||
|
FcStrSet *dirs = FcStrSetCreate ();
|
||||||
|
FcBool ret = FcFalse;
|
||||||
|
|
||||||
|
if (!dirs)
|
||||||
|
goto bail;
|
||||||
|
if (!FcDirScanOnly (dirs, FcCacheDir (cache)))
|
||||||
|
goto bail1;
|
||||||
|
ret = cache->dirs_count == dirs->num;
|
||||||
|
if (FcDebug () & FC_DBG_CACHE)
|
||||||
|
printf ("%s: cache: %d, fs: %d\n", FcCacheDir (cache), cache->dirs_count, dirs->num);
|
||||||
|
|
||||||
|
bail1:
|
||||||
|
FcStrSetDestroy (dirs);
|
||||||
|
bail:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Map a cache file into memory
|
* Map a cache file into memory
|
||||||
*/
|
*/
|
||||||
|
@ -559,7 +579,8 @@ FcDirCacheMapFd (int fd, struct stat *fd_stat, struct stat *dir_stat)
|
||||||
cache = FcCacheFindByStat (fd_stat);
|
cache = FcCacheFindByStat (fd_stat);
|
||||||
if (cache)
|
if (cache)
|
||||||
{
|
{
|
||||||
if (FcCacheTimeValid (cache, dir_stat))
|
if (FcCacheTimeValid (cache, dir_stat) &&
|
||||||
|
FcCacheDirsValid (cache))
|
||||||
return cache;
|
return cache;
|
||||||
FcDirCacheUnload (cache);
|
FcDirCacheUnload (cache);
|
||||||
cache = NULL;
|
cache = NULL;
|
||||||
|
@ -611,6 +632,7 @@ FcDirCacheMapFd (int fd, struct stat *fd_stat, struct stat *dir_stat)
|
||||||
cache->version < FC_CACHE_CONTENT_VERSION ||
|
cache->version < FC_CACHE_CONTENT_VERSION ||
|
||||||
cache->size != (intptr_t) fd_stat->st_size ||
|
cache->size != (intptr_t) fd_stat->st_size ||
|
||||||
!FcCacheTimeValid (cache, dir_stat) ||
|
!FcCacheTimeValid (cache, dir_stat) ||
|
||||||
|
!FcCacheDirsValid (cache) ||
|
||||||
!FcCacheInsert (cache, fd_stat))
|
!FcCacheInsert (cache, fd_stat))
|
||||||
{
|
{
|
||||||
if (allocated)
|
if (allocated)
|
||||||
|
|
30
src/fcdir.c
30
src/fcdir.c
|
@ -164,7 +164,8 @@ FcDirScanConfig (FcFontSet *set,
|
||||||
FcBlanks *blanks,
|
FcBlanks *blanks,
|
||||||
const FcChar8 *dir,
|
const FcChar8 *dir,
|
||||||
FcBool force, /* XXX unused */
|
FcBool force, /* XXX unused */
|
||||||
FcConfig *config)
|
FcConfig *config,
|
||||||
|
FcBool scanOnly)
|
||||||
{
|
{
|
||||||
DIR *d;
|
DIR *d;
|
||||||
struct dirent *e;
|
struct dirent *e;
|
||||||
|
@ -180,7 +181,7 @@ FcDirScanConfig (FcFontSet *set,
|
||||||
if (!set && !dirs)
|
if (!set && !dirs)
|
||||||
return FcTrue;
|
return FcTrue;
|
||||||
|
|
||||||
if (!blanks)
|
if (!blanks && !scanOnly)
|
||||||
blanks = FcConfigGetBlanks (config);
|
blanks = FcConfigGetBlanks (config);
|
||||||
|
|
||||||
/* freed below */
|
/* freed below */
|
||||||
|
@ -233,7 +234,17 @@ FcDirScanConfig (FcFontSet *set,
|
||||||
* Scan file files to build font patterns
|
* Scan file files to build font patterns
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < files->num; i++)
|
for (i = 0; i < files->num; i++)
|
||||||
FcFileScanConfig (set, dirs, blanks, files->strs[i], config);
|
{
|
||||||
|
if (scanOnly)
|
||||||
|
{
|
||||||
|
if (FcFileIsDir (files->strs[i]))
|
||||||
|
FcStrSetAdd (dirs, files->strs[i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FcFileScanConfig (set, dirs, blanks, files->strs[i], config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bail2:
|
bail2:
|
||||||
FcStrSetDestroy (files);
|
FcStrSetDestroy (files);
|
||||||
|
@ -257,7 +268,14 @@ FcDirScan (FcFontSet *set,
|
||||||
if (cache || !force)
|
if (cache || !force)
|
||||||
return FcFalse;
|
return FcFalse;
|
||||||
|
|
||||||
return FcDirScanConfig (set, dirs, blanks, dir, force, FcConfigGetCurrent ());
|
return FcDirScanConfig (set, dirs, blanks, dir, force, FcConfigGetCurrent (), FcFalse);
|
||||||
|
}
|
||||||
|
|
||||||
|
FcBool
|
||||||
|
FcDirScanOnly (FcStrSet *dirs,
|
||||||
|
const FcChar8 *dir)
|
||||||
|
{
|
||||||
|
return FcDirScanConfig (NULL, dirs, NULL, dir, FcTrue, NULL, FcTrue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -288,7 +306,7 @@ FcDirCacheScan (const FcChar8 *dir, FcConfig *config)
|
||||||
/*
|
/*
|
||||||
* Scan the dir
|
* Scan the dir
|
||||||
*/
|
*/
|
||||||
if (!FcDirScanConfig (set, dirs, NULL, dir, FcTrue, config))
|
if (!FcDirScanConfig (set, dirs, NULL, dir, FcTrue, config, FcFalse))
|
||||||
goto bail2;
|
goto bail2;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -330,7 +348,7 @@ FcDirCacheRescan (const FcChar8 *dir, FcConfig *config)
|
||||||
/*
|
/*
|
||||||
* Scan the dir
|
* Scan the dir
|
||||||
*/
|
*/
|
||||||
if (!FcDirScanConfig (NULL, dirs, NULL, dir, FcTrue, config))
|
if (!FcDirScanConfig (NULL, dirs, NULL, dir, FcTrue, config, FcFalse))
|
||||||
goto bail1;
|
goto bail1;
|
||||||
/*
|
/*
|
||||||
* Rebuild the cache object
|
* Rebuild the cache object
|
||||||
|
|
|
@ -849,7 +849,12 @@ FcDirScanConfig (FcFontSet *set,
|
||||||
FcBlanks *blanks,
|
FcBlanks *blanks,
|
||||||
const FcChar8 *dir,
|
const FcChar8 *dir,
|
||||||
FcBool force,
|
FcBool force,
|
||||||
FcConfig *config);
|
FcConfig *config,
|
||||||
|
FcBool scanOnly);
|
||||||
|
|
||||||
|
FcPrivate FcBool
|
||||||
|
FcDirScanOnly (FcStrSet *dirs,
|
||||||
|
const FcChar8 *dir);
|
||||||
|
|
||||||
/* fcfont.c */
|
/* fcfont.c */
|
||||||
FcPrivate int
|
FcPrivate int
|
||||||
|
|
Loading…
Reference in New Issue