summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2019-05-19 20:18:16 +0400
committerSergey Vojtovich <svoj@mariadb.org>2019-05-21 00:42:34 +0400
commit84494dfeecf3b31731f665a063e5448b6442d45f (patch)
tree806174243c7be0310e0be8156403ca8b66c5076d
parent46a203d9c2b8c8888eb3b1d1bce32337ed92529e (diff)
downloadmariadb-git-bb-10.5-svoj-MDEV-19515.tar.gz
mysql_socket_accept() microoptimisationsbb-10.5-svoj-MDEV-19515
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
-rw-r--r--include/mysql/psi/mysql_socket.h15
1 files changed, 6 insertions, 9 deletions
diff --git a/include/mysql/psi/mysql_socket.h b/include/mysql/psi/mysql_socket.h
index 2076f8cc999..64c2548bddf 100644
--- a/include/mysql/psi/mysql_socket.h
+++ b/include/mysql/psi/mysql_socket.h
@@ -1018,8 +1018,7 @@ inline_mysql_socket_accept
int flags __attribute__ ((unused));
#endif
- MYSQL_SOCKET socket_accept= MYSQL_INVALID_SOCKET;
- socklen_t addr_length= (addr_len != NULL) ? *addr_len : 0;
+ MYSQL_SOCKET socket_accept;
#ifdef HAVE_PSI_SOCKET_INTERFACE
if (socket_listen.m_psi != NULL)
@@ -1032,10 +1031,9 @@ inline_mysql_socket_accept
/* Instrumented code */
#ifdef HAVE_ACCEPT4
- socket_accept.fd= accept4(socket_listen.fd, addr, &addr_length,
- SOCK_CLOEXEC);
+ socket_accept.fd= accept4(socket_listen.fd, addr, addr_len, SOCK_CLOEXEC);
#else
- socket_accept.fd= accept(socket_listen.fd, addr, &addr_length);
+ socket_accept.fd= accept(socket_listen.fd, addr, addr_len);
#ifdef FD_CLOEXEC
flags= fcntl(socket_accept.fd, F_GETFD);
if (flags != -1) {
@@ -1054,10 +1052,9 @@ inline_mysql_socket_accept
{
/* Non instrumented code */
#ifdef HAVE_ACCEPT4
- socket_accept.fd= accept4(socket_listen.fd, addr, &addr_length,
- SOCK_CLOEXEC);
+ socket_accept.fd= accept4(socket_listen.fd, addr, addr_len, SOCK_CLOEXEC);
#else
- socket_accept.fd= accept(socket_listen.fd, addr, &addr_length);
+ socket_accept.fd= accept(socket_listen.fd, addr, addr_len);
#ifdef FD_CLOEXEC
flags= fcntl(socket_accept.fd, F_GETFD);
if (flags != -1) {
@@ -1073,7 +1070,7 @@ inline_mysql_socket_accept
{
/* Initialize the instrument with the new socket descriptor and address */
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