Commit 54b81cf6 authored by Sergey Vojtovich's avatar Sergey Vojtovich

mysql_socket_accept() microoptimisations

No need to initialize socket_accept, it always gets assigned a value.

Pass addr_len directly to accept().

Part of MDEV-19515 - Improve connect speed
parent a61baa7a
...@@ -1018,8 +1018,7 @@ inline_mysql_socket_accept ...@@ -1018,8 +1018,7 @@ inline_mysql_socket_accept
int flags __attribute__ ((unused)); int flags __attribute__ ((unused));
#endif #endif
MYSQL_SOCKET socket_accept= MYSQL_INVALID_SOCKET; MYSQL_SOCKET socket_accept;
socklen_t addr_length= (addr_len != NULL) ? *addr_len : 0;
#ifdef HAVE_PSI_SOCKET_INTERFACE #ifdef HAVE_PSI_SOCKET_INTERFACE
if (socket_listen.m_psi != NULL) if (socket_listen.m_psi != NULL)
...@@ -1032,10 +1031,9 @@ inline_mysql_socket_accept ...@@ -1032,10 +1031,9 @@ inline_mysql_socket_accept
/* Instrumented code */ /* Instrumented code */
#ifdef HAVE_ACCEPT4 #ifdef HAVE_ACCEPT4
socket_accept.fd= accept4(socket_listen.fd, addr, &addr_length, socket_accept.fd= accept4(socket_listen.fd, addr, addr_len, SOCK_CLOEXEC);
SOCK_CLOEXEC);
#else #else
socket_accept.fd= accept(socket_listen.fd, addr, &addr_length); socket_accept.fd= accept(socket_listen.fd, addr, addr_len);
#ifdef FD_CLOEXEC #ifdef FD_CLOEXEC
flags= fcntl(socket_accept.fd, F_GETFD); flags= fcntl(socket_accept.fd, F_GETFD);
if (flags != -1) { if (flags != -1) {
...@@ -1054,10 +1052,9 @@ inline_mysql_socket_accept ...@@ -1054,10 +1052,9 @@ inline_mysql_socket_accept
{ {
/* Non instrumented code */ /* Non instrumented code */
#ifdef HAVE_ACCEPT4 #ifdef HAVE_ACCEPT4
socket_accept.fd= accept4(socket_listen.fd, addr, &addr_length, socket_accept.fd= accept4(socket_listen.fd, addr, addr_len, SOCK_CLOEXEC);
SOCK_CLOEXEC);
#else #else
socket_accept.fd= accept(socket_listen.fd, addr, &addr_length); socket_accept.fd= accept(socket_listen.fd, addr, addr_len);
#ifdef FD_CLOEXEC #ifdef FD_CLOEXEC
flags= fcntl(socket_accept.fd, F_GETFD); flags= fcntl(socket_accept.fd, F_GETFD);
if (flags != -1) { if (flags != -1) {
...@@ -1073,7 +1070,7 @@ inline_mysql_socket_accept ...@@ -1073,7 +1070,7 @@ inline_mysql_socket_accept
{ {
/* Initialize the instrument with the new socket descriptor and address */ /* Initialize the instrument with the new socket descriptor and address */
socket_accept.m_psi= PSI_SOCKET_CALL(init_socket) socket_accept.m_psi= PSI_SOCKET_CALL(init_socket)
(key, (const my_socket*)&socket_accept.fd, addr, addr_length); (key, (const my_socket*)&socket_accept.fd, addr, *addr_len);
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment