]> git.ipfire.org Git - thirdparty/git.git/commit
server-info.c: remove temporary info files on exit
authorTaylor Blau <me@ttaylorr.com>
Thu, 6 Jun 2024 22:19:31 +0000 (18:19 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 7 Jun 2024 15:40:50 +0000 (08:40 -0700)
commit8981dca8bc717d7656f28fc375b513b91b365360
tree1f5bb6c956d2f56fad88c02f745118055869a15b
parentc195ecda7703098f28c160cc63306ca0e1488236
server-info.c: remove temporary info files on exit

The update_info_file() function within server-info.c is responsible for
moving the info/refs and info/packs files around when updating server
info.

These updates are staged into a temporary file and then moved into place
atomically to avoid race conditions when reading those files. However,
the temporary file used to stage these changes is managed outside of the
tempfile.h API, and thus survives process death.

Manage these files instead with the tempfile.h API so that they are
automatically cleaned up upon abnormal process death.

Unfortunately, and unlike in the previous step, there isn't a
straightforward way to inject a failure into the update-server-info step
that causes us to die() rather than take the cleanup path in label
'out', hence the lack of a test here.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
server-info.c