* Florian Weimer: > So I will look into implementing (c) and (d).
Here's the patch. The results aren't that great, unfortunately. Installing ttf-liberation still takes more than five seconds, and deinstallation is at about three seconds. There has to be a better way to implement this cache. diff -u fontconfig-2.6.0/debian/changelog fontconfig-2.6.0/debian/changelog --- fontconfig-2.6.0/debian/changelog +++ fontconfig-2.6.0/debian/changelog @@ -1,3 +1,9 @@ +fontconfig (2.6.0-4+cache) unstable; urgency=low + + * fc-cache: sleep only if update occured + + -- Florian Weimer <[email protected]> Sun, 13 Sep 2009 07:41:37 +0000 + fontconfig (2.6.0-4) unstable; urgency=low * fontconfig.{triggers,postinst}: register a trigger to automatically only in patch2: unchanged: --- fontconfig-2.6.0.orig/fc-cache/fc-cache.c +++ fontconfig-2.6.0/fc-cache/fc-cache.c @@ -116,7 +116,7 @@ static FcStrSet *processed_dirs; static int -scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, FcBool verbose) +scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, FcBool verbose, FcBool *dirtied) { int ret = 0; const FcChar8 *dir; @@ -209,6 +209,7 @@ if (verbose) printf ("caching, new cache contents: %d fonts, %d dirs\n", FcCacheNumFont (cache), FcCacheNumSubdir (cache)); + *dirtied = FcTrue; if (!FcDirCacheValid (dir)) { @@ -240,7 +241,7 @@ continue; } FcStrSetAdd (processed_dirs, dir); - ret += scanDirs (sublist, config, force, really_force, verbose); + ret += scanDirs (sublist, config, force, really_force, verbose, dirtied); } FcStrListDone (list); return ret; @@ -369,6 +370,7 @@ FcConfig *config; int i; int ret; + FcBool dirtied = FcFalse; #if HAVE_GETOPT_LONG || HAVE_GETOPT int c; @@ -443,22 +445,27 @@ return 1; } - ret = scanDirs (list, config, force, really_force, verbose); + ret = scanDirs (list, config, force, really_force, verbose, &dirtied); FcStrSetDestroy (processed_dirs); cleanCacheDirectories (config, verbose); /* - * Now we need to sleep a second (or two, to be extra sure), to make - * sure that timestamps for changes after this run of fc-cache are later - * then any timestamps we wrote. We don't use gettimeofday() because - * sleep(3) can't be interrupted by a signal here -- this isn't in the - * library, and there aren't any signals flying around here. + * Now we need until the nextsecond, to make sure that timestamps + * for changes after this run of fc-cache are later then any + * timestamps we wrote. */ FcConfigDestroy (config); FcFini (); - sleep (2); + if (dirtied) { + struct timeval tv; + struct timespec ts; + gettimeofday (&tv, 0); + ts.tv_sec = 0; + ts.tv_nsec = (1000000 - tv.tv_usec) * 1000; + nanosleep (&ts); + } if (verbose) printf ("%s: %s\n", argv[0], ret ? "failed" : "succeeded"); return ret; -- To UNSUBSCRIBE, email to [email protected] with a subject of "unsubscribe". Trouble? Contact [email protected]

