From: Jeff Hostetler Date: Tue, 14 Aug 2018 13:01:55 GMT Subject: Re: [PATCH] mingw: enable atomic O_APPEND Message-ID: <5a7e7ed1-da0b-20a4-147d-a24ca7da5832@jeffhostetler.com> In-Reply-To: On 8/13/2018 3:02 PM, Johannes Sixt wrote: > 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 > Helped-by: Jeff Hostetler > Signed-off-by: Johannes Sixt > --- > compat/mingw.c | 41 +++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 39 insertions(+), 2 deletions(-) > [...] This looks good. Thanks for following up on this. Jeff