Skip to content

Commit bbee025

Browse files
committed
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
1 parent 88fb8b2 commit bbee025

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

storage/innobase/handler/ha_innodb.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,8 +1410,12 @@ innobase_mysql_tmpfile(void)
14101410
fd2 = -1;
14111411
}
14121412
}
1413+
#else
1414+
#ifdef F_DUPFD_CLOEXEC
1415+
fd2 = fcntl(fd, F_DUPFD_CLOEXEC, 0);
14131416
#else
14141417
fd2 = dup(fd);
1418+
#endif
14151419
#endif
14161420
if (fd2 < 0) {
14171421
DBUG_PRINT("error",("Got error %d on dup",fd2));

storage/xtradb/handler/ha_innodb.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,8 +1677,12 @@ innobase_mysql_tmpfile(void)
16771677
fd2 = -1;
16781678
}
16791679
}
1680+
#else
1681+
#ifdef F_DUPFD_CLOEXEC
1682+
fd2 = fcntl(fd, F_DUPFD_CLOEXEC, 0);
16801683
#else
16811684
fd2 = dup(fd);
1685+
#endif
16821686
#endif
16831687
if (fd2 < 0) {
16841688
DBUG_PRINT("error",("Got error %d on dup",fd2));

0 commit comments

Comments
 (0)