On Wed, Aug 09, 2017 at 02:25:11PM -0400, Roland C. Dowdeswell wrote:
> On Wed, Aug 09, 2017 at 01:11:07PM -0500, Nico Williams wrote:
> > Actually, no, the FILE ccache does support deletion, certainly in
> > Heimdal 7.x.
> Well, we can invalidate entries but I don't think that we can re-use
> the slots because of locking issues.
We do not try to re-use them.
We could try to, but it'd be tricky and I'd rather not.
First, if a new entry is shorter than a candidate deleted entry then
we'd have to pad it. That's easy enough, and if we couldn't do it we
wouldn't do it and that's that.
Second, if a write is interrupted (e.g., by SIGKILL) and we get a
partial write, then we'd have a corrupted entry. Because we no longer
lock around reading, that would be bad. We can recover from truncated
tail entries, but not from garbage entries in the middle.
The ccache entry deletion code might seem similarly unsafe, but it turns
out to be safe anyways if any part of it completes because of what it
does and the order in which things are written.