summaryrefslogtreecommitdiff
path: root/mysys/my_fopen.c
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2016-09-27 12:34:15 +0000
committerVladislav Vaintroub <wlad@mariadb.com>2016-09-27 12:34:15 +0000
commitb38d3c3d8afea7183f2a595f0c8d8dd7efaa801f (patch)
treeea54078b43ef77501eb523f5fbe421ca26bc7bbd /mysys/my_fopen.c
parentd61e5260fb9983ea8dff539b23a6d0a150c2065c (diff)
downloadmariadb-git-b38d3c3d8afea7183f2a595f0c8d8dd7efaa801f.tar.gz
MDEV-10907 MTR and server writes can interleave in the error log
Ensure atomic appends to the error log by using CreateFile with FILE_APPEND_DATA flag to open error log file (both MTR and server)
Diffstat (limited to 'mysys/my_fopen.c')
-rw-r--r--mysys/my_fopen.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/mysys/my_fopen.c b/mysys/my_fopen.c
index 52f61649bb3..cc1019365ac 100644
--- a/mysys/my_fopen.c
+++ b/mysys/my_fopen.c
@@ -102,6 +102,7 @@ static FILE *my_win_freopen(const char *path, const char *mode, FILE *stream)
HANDLE osfh;
DBUG_ASSERT(path && stream);
+ DBUG_ASSERT(strchr(mode, 'a')); /* We use FILE_APPEND_DATA below */
/* Services don't have stdout/stderr on Windows, so _fileno returns -1. */
if (fd < 0)
@@ -112,15 +113,14 @@ static FILE *my_win_freopen(const char *path, const char *mode, FILE *stream)
fd= _fileno(stream);
}
- if ((osfh= CreateFile(path, GENERIC_READ | GENERIC_WRITE,
+ if ((osfh= CreateFile(path, GENERIC_READ | FILE_APPEND_DATA,
FILE_SHARE_READ | FILE_SHARE_WRITE |
FILE_SHARE_DELETE, NULL,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL,
NULL)) == INVALID_HANDLE_VALUE)
return NULL;
- if ((handle_fd= _open_osfhandle((intptr_t)osfh,
- _O_APPEND | _O_TEXT)) == -1)
+ if ((handle_fd= _open_osfhandle((intptr_t)osfh, _O_TEXT)) == -1)
{
CloseHandle(osfh);
return NULL;