Re: [Maria-developers] [Commits] aff5606: Add close-on-exec flag to open(), socket(), accept() & fopen().
Hi, Nirbhay! On Jun 24, Nirbhay Choubey wrote:
revision-id: aff560696cac5e081d19f4460ccd9c906ddc9d84 parent(s): 70714d3597ec9ffa742cc9e173d4ad32f294cc51 committer: Nirbhay Choubey branch nick: 10.0-galera.b7631 timestamp: 2015-06-24 11:58:11 -0400 message:
Add close-on-exec flag to open(), socket(), accept() & fopen().
@@ -1026,7 +1026,8 @@ static inline void inline_mysql_socket_register( (&state, socket_listen.m_psi, PSI_SOCKET_CONNECT, (size_t)0, src_file, src_line);
/* Instrumented code */ - socket_accept.fd= accept(socket_listen.fd, addr, &addr_length); + socket_accept.fd= accept4(socket_listen.fd, addr, &addr_length, + SOCK_CLOEXEC);
Note that, according to the manpage, "accept4() is a nonstandard Linux extension". It needs a configure-time check and ifdef. Alternatively, don't use it at all, do fcntl(FD_CLOEXEC) instead.
/* Instrumentation end */ if (locker != NULL) @@ -1036,7 +1037,8 @@ static inline void inline_mysql_socket_register( #endif { /* Non instrumented code */ - socket_accept.fd= accept(socket_listen.fd, addr, &addr_length); + socket_accept.fd= accept4(socket_listen.fd, addr, &addr_length, + SOCK_CLOEXEC); }
Regards, Sergei
Hi Serg, On Wed, Jun 24, 2015 at 2:59 PM, Sergei Golubchik <serg@mariadb.org> wrote:
Hi, Nirbhay!
On Jun 24, Nirbhay Choubey wrote:
revision-id: aff560696cac5e081d19f4460ccd9c906ddc9d84 parent(s): 70714d3597ec9ffa742cc9e173d4ad32f294cc51 committer: Nirbhay Choubey branch nick: 10.0-galera.b7631 timestamp: 2015-06-24 11:58:11 -0400 message:
Add close-on-exec flag to open(), socket(), accept() & fopen().
@@ -1026,7 +1026,8 @@ static inline void inline_mysql_socket_register( (&state, socket_listen.m_psi, PSI_SOCKET_CONNECT, (size_t)0, src_file, src_line);
/* Instrumented code */ - socket_accept.fd= accept(socket_listen.fd, addr, &addr_length); + socket_accept.fd= accept4(socket_listen.fd, addr, &addr_length, + SOCK_CLOEXEC);
Note that, according to the manpage, "accept4() is a nonstandard Linux extension".
It needs a configure-time check and ifdef. Alternatively, don't use it at all, do fcntl(FD_CLOEXEC) instead.
Right. I have added a compile-time check for accept4() so that it can be used if available, accept()/fcntl() will be used otherwise. Thanks! -- Nirbhay
/* Instrumentation end */ if (locker != NULL) @@ -1036,7 +1037,8 @@ static inline void inline_mysql_socket_register( #endif { /* Non instrumented code */ - socket_accept.fd= accept(socket_listen.fd, addr, &addr_length); + socket_accept.fd= accept4(socket_listen.fd, addr, &addr_length, + SOCK_CLOEXEC); }
Regards, Sergei
participants (2)
-
Nirbhay Choubey
-
Sergei Golubchik