<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
If mkdir is used, it would mean you can't store the PID...I guess you could encode it in the directory name though. A quick google didn't turn up anything comparing mkdir vs link in this context. Although there is this:<br><br>http://wiki.bash-hackers.org/howto/mutex<br><br>They preference there seems to be for mkdir, as its just a single step (less complicated). In theory I guess when link() is called it will fail if the link is already there, so that should eliminate the chance of a race condition. But still its a more complicated approach I think.<br><br>(^_^)/<br>mike.<br><br><br><br>> Date: Mon, 29 Nov 2010 16:25:49 -0500<br>> From: behdad@behdad.org<br>> To: mike@littlemdesign.com<br>> CC: fontconfig@lists.freedesktop.org<br>> Subject: Re: [Fontconfig] fc-cache does not work with Cygwin<br>> <br>> Thanks Michael for debugging this.<br>> <br>> Anyone on the list has any idea why using link() instead of mkdir() may be<br>> safer? How do the two compare on NFS systems?<br>> <br>> If mkdir() is just as good, I think we should simply switch to that.<br>> Otherwise, maybe try the mkdir() if link() fails.<br>> <br>> behdad<br>> <br>> On 11/29/10 03:41, Michael Garvin wrote:<br>> > Hi again, ok the is resolved for me; I’m on Windows XP (FAT32 files<br>> > sytem), so hard linking is not supported. For now, I’ve updated the<br>> > file lock code like this:<br>> > <br>> > <br>> > <br>> > #undef HAVE_LINK<br>> > <br>> > <br>> > <br>> > I wasn’t sure if using symlink would be valid in the context of lock<br>> > files so I just switched it to using a directory. It works fine now J<br>> > <br>> > <br>> > <br>> > Not sure how many people out there are going to use this stuff on an XP<br>> > machine with FAT32 file systems, under cygwin, but if you could add more<br>> > verbose error messages around the failure conditions it would help debug<br>> > things a lot quicker. It took me all night to bottom this out L I think<br>> > a lot of people would have just disabled freetype. L<br>> > <br>> > <br>> > <br>> > (^_^)/<br>> > <br>> > Mike.<br>> > <br>> > <br>> > <br>> > <br>> > <br>> > *From:* fontconfig-bounces+mgarvin=bell.net@lists.freedesktop.org<br>> > [mailto:fontconfig-bounces+mgarvin=bell.net@lists.freedesktop.org] *On<br>> > Behalf Of *Michael Garvin<br>> > *Sent:* November 29, 2010 3:30 AM<br>> > *To:* fontconfig@lists.freedesktop.org<br>> > *Subject:* Re: [Fontconfig] fc-cache does not work with Cygwin<br>> > <br>> > <br>> > <br>> > Hi, ok so I dug in deeper and it seems that fontconfig’s method of file<br>> > locking isn’t really compatibile with cygwin (or cygwin doesn’t fully<br>> > emulate Linux). <br>> > <br>> > <br>> > <br>> > When font config tries to “hard link” tempory lock file, cygwin gives a<br>> > permission denied error. I can replicate it by commenting out the<br>> > unlink() calls and then from the command line trying a ‘link’ from the<br>> > mkstemp file to some name.<br>> > <br>> > <br>> > <br>> > From my printf’ized fc-cache:<br>> > <br>> > <br>> > <br>> > bash-3.2$ ./fc-cache.exe --force --really-force /usr/share/fonts/Type1<br>> > <br>> > FC_DEBUG=<br>> > <br>> > X: FcDirCacheWrite writing out cache...<br>> > <br>> > X: FcDirCacheWrite found dir to use for caching: /home/Mike/.fonts.cache-2<br>> > <br>> > X: FcDirCacheWrite doing FcAtomicCreate<br>> > <br>> > X: FcAtomicCreate will use lock file:<br>> > /home/Mike/.fonts.cache-2/d62e99ef547d1d24cdb1bd22ec1a2976-le32d8.cache-3.LCK<br>> > <br>> > X: FcDirCacheWrite doing FcAtomicLock<br>> > <br>> > X: .. using mkstemp on:<br>> > /home/Mike/.fonts.cache-2/d62e99ef547d1d24cdb1bd22ec1a2976-le32d8.cache-3.TMP-XXXXXX<br>> > <br>> > X: .. fd=3<br>> > <br>> > X: ..linking<br>> > /home/Mike/.fonts.cache-2/d62e99ef547d1d24cdb1bd22ec1a2976-le32d8.cache-3.TMP-T7WqPU<br>> > -><br>> > /home/Mike/.fonts.cache-2/d62e99ef547d1d24cdb1bd22ec1a2976-le32d8.cache-3.LCK<br>> > <br>> > X: ret=-1 errno=1<br>> > <br>> > X: ..calling FcStat on<br>> > /home/Mike/.fonts.cache-2/d62e99ef547d1d24cdb1bd22ec1a2976-le32d8.cache-3.LCK<br>> > <br>> > X: could not created lock.<br>> > <br>> > X: FcDirCacheValid /usr/share/fonts/Type1<br>> > <br>> > X: FcDirCacheValidConfig calling through to FcDirCacheProcess<br>> > <br>> > X: FcDirCacheProcess<br>> > cache_base=/d62e99ef547d1d24cdb1bd22ec1a2976-le32d8.cache-3<br>> > <br>> > X: FcDirCacheProcess<br>> > cache_hashed=/home/Mike/.fonts.cache-2/d62e99ef547d1d24cdb1bd22ec1a2976-le32d8.cache-3<br>> > <br>> > X: opening<br>> > /home/Mike/.fonts.cache-2/d62e99ef547d1d24cdb1bd22ec1a2976-le32d8.cache-3 O_RDONLY<br>> > | O_BINARY<br>> > <br>> > X: FcDirCacheProcess fd=-1<br>> > <br>> > /usr/share/fonts/Type1: failed to write cache<br>> > <br>> > bash-3.2$<br>> > <br>> > <br>> > <br>> > Now if I try to do the hard link manually:<br>> > <br>> > <br>> > <br>> > link <br>> > ~/.fonts.cache-2/d62e99ef547d1d24cdb1bd22ec1a2976-le32d8.cache-3.TMP-Wl6CrD<br>> > ~/.fonts.cache-2/mike<br>> > <br>> > link: cannot create link `/home/Mike/.fonts.cache-2/mike' to<br>> > `/home/Mike/.fonts.cache-2/d62e99ef547d1d24cdb1bd22ec1a2976-le32d8.cache-3.TMP-Wl6CrD':<br>> > Operation not permitted<br>> > <br>> > bash-3.2$ echo $?<br>> > <br>> > 1<br>> > <br>> > <br>> > <br>> > <br>> > <br>> > I checked my umask and stuff and that looks fine; also nothing in<br>> > FcAtomicLock changes the umask, so if it can create the temp file (and<br>> > it can) it should be able to create a link to it in the same directory.<br>> > <br>> > <br>> > <br>> > Maybe this is a Cygwin limitation, hard links are not allowed? I think<br>> > this may have to be done with directories on Cygwin.<br>> > <br>> > <br>> > <br>> > (^_^)/<br>> > <br>> > Mike.<br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > *From:* fontconfig-bounces+mgarvin=bell.net@lists.freedesktop.org<br>> > [mailto:fontconfig-bounces+mgarvin=bell.net@lists.freedesktop.org] *On<br>> > Behalf Of *Michael Garvin<br>> > *Sent:* November 29, 2010 2:39 AM<br>> > *To:* fontconfig@lists.freedesktop.org<br>> > *Subject:* Re: [Fontconfig] fc-cache does not work with Cygwin<br>> > <br>> > <br>> > <br>> > Looks like I can replicate the problem now; its trying to write the<br>> > cache but the call to get a lock is failing, this code:<br>> > <br>> > <br>> > <br>> > FcDirCacheWrite (FcCache *cache, FcConfig *config)<br>> > <br>> > …<br>> > <br>> > if (!FcAtomicLock (atomic))<br>> > <br>> > goto bail3;<br>> > <br>> > <br>> > <br>> > Is leading to a silent failure (just returns false), i.e. bail3 gets<br>> > executed. I’ll try to dig a little deeper, maybe my Cygwin is not doing<br>> > locks right or something. Would have been nice if there was some kind<br>> > of visible error message about this.<br>> > <br>> > <br>> > <br>> > (^_^)/<br>> > <br>> > Mike.<br>> > <br>> > <br>> > <br>> > *From:* fontconfig-bounces+mgarvin=bell.net@lists.freedesktop.org<br>> > [mailto:fontconfig-bounces+mgarvin=bell.net@lists.freedesktop.org] *On<br>> > Behalf Of *Michael Garvin<br>> > *Sent:* November 29, 2010 2:24 AM<br>> > *To:* fontconfig@lists.freedesktop.org<br>> > *Subject:* Re: [Fontconfig] fc-cache does not work with Cygwin<br>> > <br>> > <br>> > <br>> > Some additional detail; I set FC_DEBUG=8063 and ran an unmodified<br>> > version of fc-cache:<br>> > <br>> > <br>> > <br>> > FC_DEBUG=8063<br>> > <br>> > Loading config file /etc/fonts/fonts.conf<br>> > <br>> > …<br>> > <br>> > <br>> > <br>> > cache scan dir /usr/share/fonts/Type1<br>> > <br>> > <br>> > <br>> > using FreeType family "Utopia"<br>> > <br>> > using FreeType style "Bold Italic"<br>> > <br>> > Type1 weight Bold maps to 200<br>> > <br>> > Style Bold Italic maps to width -1<br>> > <br>> > Style Bold Italic maps to slant 100<br>> > <br>> > Style Bold Italic maps to decorative 0<br>> > <br>> > font charset<br>> > <br>> > 0000: 00000000 ffffffff ffffffff 7fffffff 00000000 ffffffff<br>> > ffffffff ffffffff<br>> > <br>> > 0001: 00000000 00020000 000c0006 61000003 00040000 00000000<br>> > 00000000 00000000<br>> > <br>> > …<br>> > <br>> > <br>> > <br>> > <does the build up of the font cache for that directory in memory><br>> > <br>> > ….<br>> > <br>> > charsets 29 -> 4 leaves 251 -> 24<br>> > <br>> > FcDirCacheWriteDir dir "/usr/share/fonts/Type1" file<br>> > "/home/Mike/.fonts.cache-2/d62e99ef547d1d24cdb1bd22ec1a2976-x86.cache-3"<br>> > <br>> > /usr/share/fonts/Type1: failed to write cache<br>> > <br>> > Fc Memory Usage:<br>> > <br>> > Which Alloc Free Active<br>> > <br>> > count bytes count bytes count bytes<br>> > <br>> > charset 3970 74626 3970 32362 0 42264<br>> > <br>> > <br>> > <br>> > Some how (not sure how), it is managing to get through to the section of<br>> > code where it actually tries to write out to disk. But…that is failing<br>> > as well. I’ll dig deeper to see if I can identify why the default<br>> > Cygwin binary is getting to that stage and the one compiled from source<br>> > is not. I think the Cygwin one might be patched somehow. Still fails<br>> > though L<br>> > <br>> > <br>> > <br>> > (^_^)/<br>> > <br>> > Mike.<br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > *From:* fontconfig-bounces+mgarvin=bell.net@lists.freedesktop.org<br>> > [mailto:fontconfig-bounces+mgarvin=bell.net@lists.freedesktop.org] *On<br>> > Behalf Of *Michael Garvin<br>> > *Sent:* November 29, 2010 2:05 AM<br>> > *To:* fontconfig@lists.freedesktop.org<br>> > *Subject:* [Fontconfig] fc-cache does not work with Cygwin<br>> > <br>> > <br>> > <br>> > Hi, I’ve been trying to fix the problem with all of my Cygwin (Widnows<br>> > XP) Gtk and Qt applications being slow (taking about 5minutes to<br>> > startup). I’ve been able to verify that the issue is due to Freetype<br>> > being used, and in turn; font-config being used to list off the<br>> > available fonts on startup. The problem is that font-config never<br>> > actually caches anything, so any font-config using application, has the<br>> > same (realliy bad) start up time…every time.<br>> > <br>> > <br>> > <br>> > I tried running fc-cache manually but to no avail; I double checked time<br>> > stamps, having write permission any problems with the configuration<br>> > file, bad install of the Cygwin packages etc, but no matter what,<br>> > fc-cache always fails on all possible font directories with:<br>> > <br>> > <br>> > <br>> > failed to write cache<br>> > <br>> > <br>> > <br>> > After googling around trying all the suggested solutions, nothing was<br>> > helping, and I ran strace and looked through the detailed system calls.<br>> > It turns out fc-cache tries to open cache files in read only mode.<br>> > Which means there is no way it can create cache files L<br>> > <br>> > <br>> > <br>> > So, I downloaded the source, compiled it up and added printf statements<br>> > throughout the call chain from scanDirs() downwards, and picked a single<br>> > directory to try and cache (the Type1 fonts directory for Cygwin). This<br>> > is what I see:<br>> > <br>> > <br>> > <br>> > bash-3.2$ ./fc-cache.exe --force --really-force /usr/share/fonts/Type1/<br>> > <br>> > X: FcDirCacheValid /usr/share/fonts/Type1<br>> > <br>> > X: FcDirCacheValidConfig calling through to FcDirCacheProcess<br>> > <br>> > X: FcDirCacheProcess<br>> > cache_base=/d62e99ef547d1d24cdb1bd22ec1a2976-le32d8.cache-3<br>> > <br>> > X: FcDirCacheProcess<br>> > cache_hashed=/home/Mike/.fonts.cache-2/d62e99ef547d1d24cdb1bd22ec1a2976-le32d8.cache-3<br>> > <br>> > X: opening<br>> > /home/Mike/.fonts.cache-2/d62e99ef547d1d24cdb1bd22ec1a2976-le32d8.cache-3 O_RDONLY<br>> > | O_BINARY<br>> > <br>> > X: FcDirCacheProcess fd=-1<br>> > <br>> > /usr/share/fonts/Type1: failed to write cache<br>> > <br>> > bash-3.2$<br>> > <br>> > <br>> > <br>> > The X: … lines are my printf statements I added to the code.<br>> > <br>> > <br>> > <br>> > I looked through the code by hand, from main(), to scanDirs() and<br>> > downwards, there is no possible way that I can see for fc-cache to<br>> > actually create caches on disk. The code that prints out the failed to<br>> > write cache message is just calling FcDirCacheValid(), but this function<br>> > is not used to create cache files (the error message of “write failed is<br>> > meaningless), only to open then and check that they are valid (hence<br>> > strace shows opening of cache files in read only mode with no creat<br>> > flag..consistent at least).<br>> > <br>> > <br>> > <br>> > So from what I can tell, fc-cache is not the program to use to populate<br>> > the font caches the very first time. <br>> > <br>> > <br>> > <br>> > My question is, what program do I use? Can you update your<br>> > documentation to correctly point to the right program to use? <br>> > <br>> > <br>> > <br>> > This has been very frustrating to try and track down. I guess when I<br>> > have time next, I’ll try to understand the “init” call tree that<br>> > actually does call the functions which build cache files<br>> > (FcDirCacheScan), and maybe write a little program that specificalliy<br>> > calls those functions so I can get my caches populated, but I really<br>> > don’t think I should have to do that. fc-cache should work as its<br>> > manpage says L<br>> > <br>> > <br>> > <br>> > (^_^)/<br>> > <br>> > Mike.<br>> > <br>> > <br>> > <br>> > Michael Garvin<br>> > <br>> > mgarvin@bell.net <mailto:mgarvin@bell.net><br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > <br>> > _______________________________________________<br>> > Fontconfig mailing list<br>> > Fontconfig@lists.freedesktop.org<br>> > http://lists.freedesktop.org/mailman/listinfo/fontconfig<br>> _______________________________________________<br>> Fontconfig mailing list<br>> Fontconfig@lists.freedesktop.org<br>> http://lists.freedesktop.org/mailman/listinfo/fontconfig<br>                                            </body>
</html>