Re: fc-cache does not work with Cygwin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:

http://wiki.bash-hackers.org/howto/mutex

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.

(^_^)/
mike.



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

[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux