Skip to content

Commit

Permalink
MDEV-18353 - minor cleanup
Browse files Browse the repository at this point in the history
Do not repeat yourself.

Instead of having the same DBUG_EXECUTE_IF code in threadpool and
thread-per-connection, add this code to setup_connection_thread_globals()
which is executed in all scheduling modes.
  • Loading branch information
vaintroub committed Sep 7, 2022
1 parent c7ba237 commit 9a8faee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
16 changes: 8 additions & 8 deletions sql/sql_connect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,14 @@ static int check_connection(THD *thd)

bool setup_connection_thread_globals(THD *thd)
{

DBUG_EXECUTE_IF("CONNECT_wait", {
extern MYSQL_SOCKET unix_sock;
DBUG_ASSERT(unix_sock.fd >= 0);
while (unix_sock.fd >= 0)
my_sleep(1000);
});

if (thd->store_globals())
{
close_connection(thd, ER_OUT_OF_RESOURCES);
Expand Down Expand Up @@ -1360,14 +1368,6 @@ void do_handle_one_connection(CONNECT *connect)
return;
}

DBUG_EXECUTE_IF("CONNECT_wait",
{
extern MYSQL_SOCKET unix_sock;
DBUG_ASSERT(unix_sock.fd >= 0);
while (unix_sock.fd >= 0)
my_sleep(1000);
});

/*
If a thread was created to handle this connection:
increment slow_launch_threads counter if it took more than
Expand Down
8 changes: 0 additions & 8 deletions sql/threadpool_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,6 @@ static THD* threadpool_add_connection(CONNECT *connect, void *scheduler_data)
{
THD *thd= NULL;

DBUG_EXECUTE_IF("CONNECT_wait",
{
extern MYSQL_SOCKET unix_sock;
DBUG_ASSERT(unix_sock.fd >= 0);
while (unix_sock.fd >= 0)
my_sleep(1000);
});

/*
Create a new connection context: mysys_thread_var and PSI thread
Store them in THD.
Expand Down

0 comments on commit 9a8faee

Please sign in to comment.