Web lists-archives.com

Re: [PATCH 2/2] mingw: fix mingw_open_append to work with named pipes

Am 07.09.2018 um 20:19 schrieb Jeff Hostetler via GitGitGadget:
From: Jeff Hostetler <jeffhost@xxxxxxxxxxxxx>

Signed-off-by: Jeff Hostetler <jeffhost@xxxxxxxxxxxxx>
  compat/mingw.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compat/mingw.c b/compat/mingw.c
index 858ca14a57..ef03bbe5d2 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -355,7 +355,7 @@ static int mingw_open_append(wchar_t const *wfilename, int oflags, ...)
  	 * FILE_SHARE_WRITE is required to permit child processes
  	 * to append to the file.
-	handle = CreateFileW(wfilename, FILE_APPEND_DATA,
+	handle = CreateFileW(wfilename, FILE_WRITE_DATA | FILE_APPEND_DATA,
  	if (handle == INVALID_HANDLE_VALUE)

I did not go with this version because the documentation https://docs.microsoft.com/en-us/windows/desktop/fileio/file-access-rights-constants says:

FILE_APPEND_DATA: For a file object, the right to append data to the file. (For local files, write operations will not overwrite existing data if this flag is specified without FILE_WRITE_DATA.) [...]

which could be interpreted as: Only if FILE_WRITE_DATA is not set, we have the guarantee that existing data in local files is not overwritten, i.e., new data is appended atomically.

Is this interpretation too narrow and we do get atomicity even when FILE_WRITE_DATA is set?

-- Hannes