summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorDaniel Black <daniel@linux.vnet.ibm.com>2018-03-02 12:45:36 +1100
committerDaniel Black <daniel@linux.vnet.ibm.com>2018-03-02 12:46:02 +1100
commitbbee025370d885103cba55716c9c2ab44e533283 (patch)
treec4a84b5f99a43ce7ba9f8319ddb7a027af14b7fd /storage
parent88fb8b2e367158dce7a4c3e14f2517c5deb9b51d (diff)
downloadmariadb-git-bbee025370d885103cba55716c9c2ab44e533283.tar.gz
MDEV-8743: O_CLOEXEC on innodb/xtradb temp files
Thread 1 "mysqld" hit Breakpoint 1, innobase_mysql_tmpfile () at /home/dan/repos/mariadb-server-5.5/storage/xtradb/handler/ha_innodb.cc:1639 1639 os_event_wait(srv_allow_writes_event); (gdb) p fd $2 = 7 (gdb) n 1682 fd2 = fcntl(fd, F_DUPFD_CLOEXEC, 0); (gdb) 1687 if (fd2 < 0) { (gdb) p fd2 $3 = 8 cat /proc/20448/fdinfo/{7,8} 2051972 0 -r-------- 1 dan dan 0 Mar 2 12:04 fdinfo/7 pos: 0 flags: 0100002 mnt_id: 82 2051973 0 -r-------- 1 dan dan 0 Mar 2 12:04 fdinfo/8 pos: 0 flags: 02100002 mnt_id: 82 So fd 8 has 02000000 hence CLOEXEC
Diffstat (limited to 'storage')
-rw-r--r--storage/innobase/handler/ha_innodb.cc4
-rw-r--r--storage/xtradb/handler/ha_innodb.cc4
2 files changed, 8 insertions, 0 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 3a96763d6c2..c9eee5b4dcd 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -1411,8 +1411,12 @@ innobase_mysql_tmpfile(void)
}
}
#else
+#ifdef F_DUPFD_CLOEXEC
+ fd2 = fcntl(fd, F_DUPFD_CLOEXEC, 0);
+#else
fd2 = dup(fd);
#endif
+#endif
if (fd2 < 0) {
DBUG_PRINT("error",("Got error %d on dup",fd2));
my_errno=errno;
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index f99ae7c7de9..04fbcd1a9fd 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -1678,8 +1678,12 @@ innobase_mysql_tmpfile(void)
}
}
#else
+#ifdef F_DUPFD_CLOEXEC
+ fd2 = fcntl(fd, F_DUPFD_CLOEXEC, 0);
+#else
fd2 = dup(fd);
#endif
+#endif
if (fd2 < 0) {
DBUG_PRINT("error",("Got error %d on dup",fd2));
my_errno=errno;