]> git.ipfire.org Git - thirdparty/git.git/commit - compat/mingw.c
mingw: enable atomic O_APPEND
authorJohannes Sixt <j6t@kdbg.org>
Mon, 13 Aug 2018 19:02:50 +0000 (21:02 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 13 Aug 2018 22:22:19 +0000 (15:22 -0700)
commitd641097589160eb795127d8dbcb14c877c217b60
treeaccb48f745a2dbb95d8c6cb79fb2856c6b624bc7
parent53f9a3e157dbbc901a02ac2c73346d375e24978c
mingw: enable atomic O_APPEND

The Windows CRT implements O_APPEND "manually": on write() calls, the
file pointer is set to EOF before the data is written. Clearly, this is
not atomic. And in fact, this is the root cause of failures observed in
t5552-skipping-fetch-negotiator.sh and t5503-tagfollow.sh, where
different processes write to the same trace file simultanously; it also
occurred in t5400-send-pack.sh, but there it was worked around in
71406ed4d6 ("t5400: avoid concurrent writes into a trace file",
2017-05-18).

Fortunately, Windows does support atomic O_APPEND semantics using the
file access mode FILE_APPEND_DATA. Provide an implementation that does.

This implementation is minimal in such a way that it only implements
the open modes that are actually used in the Git code base. Emulation
for other modes can be added as necessary later. To become aware of
the necessity early, the unusal error ENOSYS is reported if an
unsupported mode is encountered.

Diagnosed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Helped-by: Jeff Hostetler <git@jeffhostetler.com>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/mingw.c