Re: SoC idea: desktop file cache



> > mmap MAP_SHARED also makes dealing with external updating really
> > interesting because if the file shrinks you need to handle signal
> > exceptions from touching pages that no longer exist.
> 
> Not if the cache is replaced with rename(), no?

If the sequence is

	build new cache
	rename
	unlink old cache

then the existing users will continue to see the old file which will only
vanish completely on the last close. You can use fstat and the like to
check the size for the mmap to avoid racing the rename on guessing sizes
etc.

It's only if the file is truncated the fun with SIGBUS occurs, or on an
unrecoverable read error (eg NFS timeout on soft mount, physical bad
block). In those cases unlike read() there is no other reporting
mechanism.

sigsetjmp/longjmp are normally evil but this may be one case they are
needed to build a sort of mock exception handler given C's lack of a
proper mechanism.

Alan


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