Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
0f447810
Commit
0f447810
authored
Jun 24, 2015
by
Nirbhay Choubey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add close-on-exec flag to open(), socket(), accept() & fopen().
parent
70714d35
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
7 deletions
+38
-7
configure.cmake
configure.cmake
+1
-0
include/my_global.h
include/my_global.h
+6
-0
include/mysql/psi/mysql_socket.h
include/mysql/psi/mysql_socket.h
+23
-1
mysys/my_create.c
mysys/my_create.c
+1
-1
mysys/my_fopen.c
mysys/my_fopen.c
+5
-3
mysys/my_open.c
mysys/my_open.c
+2
-2
No files found.
configure.cmake
View file @
0f447810
...
...
@@ -315,6 +315,7 @@ ENDIF()
#
# Tests for functions
#
CHECK_FUNCTION_EXISTS
(
accept4 HAVE_ACCEPT4
)
CHECK_FUNCTION_EXISTS
(
access HAVE_ACCESS
)
#CHECK_FUNCTION_EXISTS (aiowait HAVE_AIOWAIT)
CHECK_FUNCTION_EXISTS
(
aio_read HAVE_AIO_READ
)
...
...
include/my_global.h
View file @
0f447810
...
...
@@ -609,6 +609,12 @@ typedef SOCKET_SIZE_TYPE size_socket;
#ifndef O_NOFOLLOW
#define O_NOFOLLOW 0
#endif
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
#ifndef SOCK_CLOEXEC
#define SOCK_CLOEXEC 0
#endif
/* additional file share flags for win32 */
#ifdef __WIN__
...
...
include/mysql/psi/mysql_socket.h
View file @
0f447810
...
...
@@ -553,7 +553,7 @@ inline_mysql_socket_socket
int
domain
,
int
type
,
int
protocol
)
{
MYSQL_SOCKET
mysql_socket
=
MYSQL_INVALID_SOCKET
;
mysql_socket
.
fd
=
socket
(
domain
,
type
,
protocol
);
mysql_socket
.
fd
=
socket
(
domain
,
type
|
SOCK_CLOEXEC
,
protocol
);
#ifdef HAVE_PSI_SOCKET_INTERFACE
if
(
likely
(
mysql_socket
.
fd
!=
INVALID_SOCKET
))
...
...
@@ -1013,6 +1013,8 @@ inline_mysql_socket_accept
#endif
MYSQL_SOCKET
socket_listen
,
struct
sockaddr
*
addr
,
socklen_t
*
addr_len
)
{
int
flags
;
MYSQL_SOCKET
socket_accept
=
MYSQL_INVALID_SOCKET
;
socklen_t
addr_length
=
(
addr_len
!=
NULL
)
?
*
addr_len
:
0
;
...
...
@@ -1026,7 +1028,17 @@ inline_mysql_socket_accept
(
&
state
,
socket_listen
.
m_psi
,
PSI_SOCKET_CONNECT
,
(
size_t
)
0
,
src_file
,
src_line
);
/* Instrumented code */
#ifdef HAVE_ACCEPT4
socket_accept
.
fd
=
accept4
(
socket_listen
.
fd
,
addr
,
&
addr_length
,
SOCK_CLOEXEC
);
#else
socket_accept
.
fd
=
accept
(
socket_listen
.
fd
,
addr
,
&
addr_length
);
flags
=
fcntl
(
socket_accept
.
fd
,
F_GETFD
);
if
(
flags
!=
-
1
)
{
flags
|=
FD_CLOEXEC
;
fcntl
(
socket_accept
.
fd
,
F_SETFD
,
flags
);
}
#endif
/* Instrumentation end */
if
(
locker
!=
NULL
)
...
...
@@ -1036,7 +1048,17 @@ inline_mysql_socket_accept
#endif
{
/* Non instrumented code */
#ifdef HAVE_ACCEPT4
socket_accept
.
fd
=
accept4
(
socket_listen
.
fd
,
addr
,
&
addr_length
,
SOCK_CLOEXEC
);
#else
socket_accept
.
fd
=
accept
(
socket_listen
.
fd
,
addr
,
&
addr_length
);
flags
=
fcntl
(
socket_accept
.
fd
,
F_GETFD
);
if
(
flags
!=
-
1
)
{
flags
|=
FD_CLOEXEC
;
fcntl
(
socket_accept
.
fd
,
F_SETFD
,
flags
);
}
#endif
}
#ifdef HAVE_PSI_SOCKET_INTERFACE
...
...
mysys/my_create.c
View file @
0f447810
...
...
@@ -43,7 +43,7 @@ File my_create(const char *FileName, int CreateFlags, int access_flags,
#if defined(_WIN32)
fd
=
my_win_open
(
FileName
,
access_flags
|
O_CREAT
);
#else
fd
=
open
((
char
*
)
FileName
,
access_flags
|
O_CREAT
,
fd
=
open
((
char
*
)
FileName
,
access_flags
|
O_CREAT
|
O_CLOEXEC
,
CreateFlags
?
CreateFlags
:
my_umask
);
#endif
...
...
mysys/my_fopen.c
View file @
0f447810
...
...
@@ -42,7 +42,7 @@ static void make_ftype(char * to,int flag);
FILE
*
my_fopen
(
const
char
*
filename
,
int
flags
,
myf
MyFlags
)
{
FILE
*
fd
;
char
type
[
5
];
char
type
[
10
];
DBUG_ENTER
(
"my_fopen"
);
DBUG_PRINT
(
"my"
,(
"Name: '%s' flags: %d MyFlags: %lu"
,
filename
,
flags
,
MyFlags
));
...
...
@@ -351,9 +351,11 @@ static void make_ftype(register char * to, register int flag)
else
*
to
++=
'r'
;
#if FILE_BINARY
/* If we have binary-files */
if
(
flag
&
FILE_BINARY
)
*
to
++=
'b'
;
#endif
if
(
O_CLOEXEC
)
*
to
++=
'e'
;
*
to
=
'\0'
;
}
/* make_ftype */
mysys/my_open.c
View file @
0f447810
...
...
@@ -46,9 +46,9 @@ File my_open(const char *FileName, int Flags, myf MyFlags)
#if defined(_WIN32)
fd
=
my_win_open
(
FileName
,
Flags
);
#elif !defined(NO_OPEN_3)
fd
=
open
(
FileName
,
Flags
,
my_umask
);
/* Normal unix */
fd
=
open
(
FileName
,
Flags
|
O_CLOEXEC
,
my_umask
);
/* Normal unix */
#else
fd
=
open
((
char
*
)
FileName
,
Flags
);
fd
=
open
((
char
*
)
FileName
,
Flags
|
O_CLOEXEC
);
#endif
fd
=
my_register_filename
(
fd
,
FileName
,
FILE_BY_OPEN
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment