Streamline "do_close_connection" and "do_send_quit"

Fix typo, "next_con" -> "con"
parent 397fbd02
...@@ -2983,7 +2983,22 @@ void do_diff_files(struct st_command *command) ...@@ -2983,7 +2983,22 @@ void do_diff_files(struct st_command *command)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
/*
struct st_connection * find_connection_by_name(const char *name)
{
struct st_connection *con;
for (con= connections; con < next_con; con++)
{
if (!strcmp(con->name, name))
{
return con;
}
}
return 0; /* Connection not found */
}
/*
SYNOPSIS SYNOPSIS
do_send_quit do_send_quit
command called command command called command
...@@ -2991,7 +3006,7 @@ void do_diff_files(struct st_command *command) ...@@ -2991,7 +3006,7 @@ void do_diff_files(struct st_command *command)
DESCRIPTION DESCRIPTION
Sends a simple quit command to the server for the named connection. Sends a simple quit command to the server for the named connection.
*/ */
void do_send_quit(struct st_command *command) void do_send_quit(struct st_command *command)
{ {
...@@ -3002,7 +3017,7 @@ void do_send_quit(struct st_command *command) ...@@ -3002,7 +3017,7 @@ void do_send_quit(struct st_command *command)
DBUG_PRINT("enter",("name: '%s'",p)); DBUG_PRINT("enter",("name: '%s'",p));
if (!*p) if (!*p)
die("Missing connection name in do_send_quit"); die("Missing connection name in send_quit");
name= p; name= p;
while (*p && !my_isspace(charset_info,*p)) while (*p && !my_isspace(charset_info,*p))
p++; p++;
...@@ -3011,17 +3026,12 @@ void do_send_quit(struct st_command *command) ...@@ -3011,17 +3026,12 @@ void do_send_quit(struct st_command *command)
*p++= 0; *p++= 0;
command->last_argument= p; command->last_argument= p;
/* Loop through connection pool for connection to close */ if (!(con= find_connection_by_name(name)))
for (con= connections; con < next_con; con++) die("connection '%s' not found in connection pool", name);
{
DBUG_PRINT("info", ("con->name: %s", con->name));
if (!strcmp(con->name, name))
{
simple_command(&con->mysql,COM_QUIT,NullS,0,1); simple_command(&con->mysql,COM_QUIT,NullS,0,1);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
}
}
die("connection '%s' not found in connection pool", name);
} }
...@@ -3858,20 +3868,6 @@ void set_reconnect(MYSQL* mysql, int val) ...@@ -3858,20 +3868,6 @@ void set_reconnect(MYSQL* mysql, int val)
} }
struct st_connection * find_connection_by_name(const char *name)
{
struct st_connection *con;
for (con= connections; con < next_con; con++)
{
if (!strcmp(con->name, name))
{
return con;
}
}
return 0; /* Connection not found */
}
int select_connection_name(const char *name) int select_connection_name(const char *name)
{ {
DBUG_ENTER("select_connection2"); DBUG_ENTER("select_connection2");
...@@ -3919,12 +3915,9 @@ void do_close_connection(struct st_command *command) ...@@ -3919,12 +3915,9 @@ void do_close_connection(struct st_command *command)
*p++= 0; *p++= 0;
command->last_argument= p; command->last_argument= p;
/* Loop through connection pool for connection to close */ if (!(con= find_connection_by_name(name)))
for (con= connections; con < next_con; con++) die("connection '%s' not found in connection pool", name);
{
DBUG_PRINT("info", ("con->name: %s", con->name));
if (!strcmp(con->name, name))
{
DBUG_PRINT("info", ("Closing connection %s", con->name)); DBUG_PRINT("info", ("Closing connection %s", con->name));
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
if (command->type == Q_DIRTY_CLOSE) if (command->type == Q_DIRTY_CLOSE)
...@@ -3936,14 +3929,16 @@ void do_close_connection(struct st_command *command) ...@@ -3936,14 +3929,16 @@ void do_close_connection(struct st_command *command)
} }
} }
#endif #endif
if (next_con->stmt) if (con->stmt)
mysql_stmt_close(next_con->stmt); mysql_stmt_close(con->stmt);
next_con->stmt= 0; con->stmt= 0;
mysql_close(&con->mysql); mysql_close(&con->mysql);
if (con->util_mysql) if (con->util_mysql)
mysql_close(con->util_mysql); mysql_close(con->util_mysql);
con->util_mysql= 0; con->util_mysql= 0;
my_free(con->name, MYF(0)); my_free(con->name, MYF(0));
/* /*
...@@ -3954,9 +3949,6 @@ void do_close_connection(struct st_command *command) ...@@ -3954,9 +3949,6 @@ void do_close_connection(struct st_command *command)
die("Out of memory"); die("Out of memory");
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
}
}
die("connection '%s' not found in connection pool", name);
} }
......
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