Commit 5d183df7 authored by Sergey Vojtovich's avatar Sergey Vojtovich

Try accept a few times before falling back to poll

Gives ~3% throughput improvemet in sysbench connect benchmark.

Part of MDEV-19515 - Improve connect speed
parent 87775402
...@@ -6375,7 +6375,6 @@ static void set_non_blocking_if_supported(MYSQL_SOCKET sock) ...@@ -6375,7 +6375,6 @@ static void set_non_blocking_if_supported(MYSQL_SOCKET sock)
void handle_connections_sockets() void handle_connections_sockets()
{ {
MYSQL_SOCKET sock= mysql_socket_invalid(); MYSQL_SOCKET sock= mysql_socket_invalid();
MYSQL_SOCKET new_sock= mysql_socket_invalid();
uint error_count=0; uint error_count=0;
struct sockaddr_storage cAddr; struct sockaddr_storage cAddr;
int retval; int retval;
...@@ -6467,18 +6466,17 @@ void handle_connections_sockets() ...@@ -6467,18 +6466,17 @@ void handle_connections_sockets()
for (uint retry=0; retry < MAX_ACCEPT_RETRY; retry++) for (uint retry=0; retry < MAX_ACCEPT_RETRY; retry++)
{ {
size_socket length= sizeof(struct sockaddr_storage); size_socket length= sizeof(struct sockaddr_storage);
MYSQL_SOCKET new_sock;
new_sock= mysql_socket_accept(key_socket_client_connection, sock, new_sock= mysql_socket_accept(key_socket_client_connection, sock,
(struct sockaddr *)(&cAddr), (struct sockaddr *)(&cAddr),
&length); &length);
if (mysql_socket_getfd(new_sock) != INVALID_SOCKET || if (mysql_socket_getfd(new_sock) != INVALID_SOCKET)
(socket_errno != SOCKET_EINTR && socket_errno != SOCKET_EAGAIN)) handle_accepted_socket(new_sock, sock);
break; else if (socket_errno != SOCKET_EINTR && socket_errno != SOCKET_EAGAIN)
}
if (mysql_socket_getfd(new_sock) == INVALID_SOCKET)
{ {
/* /*
accept(2) failed on the listening port, after many retries. accept(2) failed on the listening port.
There is not much details to report about the client, There is not much details to report about the client,
increment the server global status variable. increment the server global status variable.
*/ */
...@@ -6487,9 +6485,9 @@ void handle_connections_sockets() ...@@ -6487,9 +6485,9 @@ void handle_connections_sockets()
sql_perror("Error in accept"); sql_perror("Error in accept");
if (socket_errno == SOCKET_ENFILE || socket_errno == SOCKET_EMFILE) if (socket_errno == SOCKET_ENFILE || socket_errno == SOCKET_EMFILE)
sleep(1); // Give other threads some time sleep(1); // Give other threads some time
continue; break;
}
} }
handle_accepted_socket(new_sock, sock);
} }
sd_notify(0, "STOPPING=1\n" sd_notify(0, "STOPPING=1\n"
"STATUS=Shutdown in progress\n"); "STATUS=Shutdown in progress\n");
......
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