Re: [PATCH] tmp-objdir: do not opendir() when handling a signal
- From
Jeff King <peff@peff.net>
- Date
- Sep 27, 2022, 11:48 UTC
- Message-ID
- <YzLjKbLI13GN52R/@coredump.intra.peff.net>
- In-Reply-To
- <YzJBZ9QJWIv0hpXb@nand.local>
On Mon, Sep 26, 2022 at 08:18:47PM -0400, Taylor Blau wrote:
Show 5 quoted lines
> It does make me a little uneasy leaving the quarantine directory around > via this path. So I wonder if we should be optimistically opening up the > DIR handle? Calling unlink() in a signal is perfectly fine, so I'd think > as long as we have an open DIR handle we could call readdir_r(), but I > don't think we've discussed it before.
You'd need to hold multiple such DIRs, since the removal is recursive. It's easy-ish for the "pack" directory, but the sub-process index-pack may have created 00-ff directories, too. You'd have to pre-create and opendir() all of them.
I'm also not sure what timing guarantees we have. If I opendir() a directory, then wait a long time while somebody else creates entries, is a readdir() guaranteed to see those new entries?
-Peff