MDEV-8743: where O_CLOEXEC is available, use for innodb buf_dump
As this is the only moderately critical fopened for writing file, create an alternate path to use open and fdopen for non-glibc platforms that support O_CLOEXEC (BSDs). Tested on Linux (by modifing the GLIBC defination) to take this alternate path: $ cd /proc/23874 $ more fdinfo/71 pos: 0 flags: 02100001 mnt_id: 24 $ ls -la fd/71 l-wx------. 1 dan dan 64 Mar 14 13:30 fd/71 -> /dev/shm/var_auto_i7rl/mysqld.1/data/ib_buffer_pool.incomplete
This commit is contained in:
parent
930682c487
commit
8b54c31486
@ -601,6 +601,11 @@ typedef SOCKET_SIZE_TYPE size_socket;
|
||||
#ifndef O_CLOEXEC
|
||||
#define O_CLOEXEC 0
|
||||
#endif
|
||||
#ifdef __GLIBC__
|
||||
#define STR_O_CLOEXEC "e"
|
||||
#else
|
||||
#define STR_O_CLOEXEC ""
|
||||
#endif
|
||||
#ifndef SOCK_CLOEXEC
|
||||
#define SOCK_CLOEXEC 0
|
||||
#endif
|
||||
|
@ -220,7 +220,20 @@ buf_dump(
|
||||
buf_dump_status(STATUS_NOTICE, "Dumping buffer pool(s) to %s",
|
||||
full_filename);
|
||||
|
||||
f = fopen(tmp_filename, "w");
|
||||
#if defined(__GLIBC__) || defined(__WIN__) || O_CLOEXEC == 0
|
||||
f = fopen(tmp_filename, "w" STR_O_CLOEXEC);
|
||||
#else
|
||||
{
|
||||
int fd;
|
||||
fd = open(tmp_filename, O_CREAT | O_TRUNC | O_CLOEXEC | O_WRONLY, 0640);
|
||||
if (fd >= 0) {
|
||||
f = fdopen(fd, "w");
|
||||
}
|
||||
else {
|
||||
f = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (f == NULL) {
|
||||
buf_dump_status(STATUS_ERR,
|
||||
"Cannot open '%s' for writing: %s",
|
||||
|
@ -220,7 +220,20 @@ buf_dump(
|
||||
buf_dump_status(STATUS_NOTICE, "Dumping buffer pool(s) to %s",
|
||||
full_filename);
|
||||
|
||||
f = fopen(tmp_filename, "w");
|
||||
#if defined(__GLIBC__) || defined(__WIN__) || O_CLOEXEC == 0
|
||||
f = fopen(tmp_filename, "w" STR_O_CLOEXEC);
|
||||
#else
|
||||
{
|
||||
int fd;
|
||||
fd = open(tmp_filename, O_CREAT | O_TRUNC | O_CLOEXEC | O_WRONLY, 0640);
|
||||
if (fd >= 0) {
|
||||
f = fdopen(fd, "w");
|
||||
}
|
||||
else {
|
||||
f = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (f == NULL) {
|
||||
buf_dump_status(STATUS_ERR,
|
||||
"Cannot open '%s' for writing: %s",
|
||||
|
Loading…
x
Reference in New Issue
Block a user