summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Ronström <mikael@dator9>2011-02-10 18:41:02 +0100
committerMikael Ronström <mikael@dator9>2011-02-10 18:41:02 +0100
commit6d45d27cbc9c343736a97cafa504eb1998d8bd70 (patch)
tree3d00c93eab570455ce9d604cf9147e7425ceac47
parente3f89e5dbac66b34db735ae44a21e6d489a7f28e (diff)
downloadmariadb-git-6d45d27cbc9c343736a97cafa504eb1998d8bd70.tar.gz
Simplify interface to connect methods in server
-rw-r--r--include/mysql/thread_pool_priv.h6
-rw-r--r--sql/sql_connect.cc39
-rw-r--r--sql/sql_connect.h2
3 files changed, 33 insertions, 14 deletions
diff --git a/include/mysql/thread_pool_priv.h b/include/mysql/thread_pool_priv.h
index 73e48cc33e7..555d5fb0e7b 100644
--- a/include/mysql/thread_pool_priv.h
+++ b/include/mysql/thread_pool_priv.h
@@ -34,7 +34,6 @@
*/
#define MYSQL_SERVER 1
#include <sql_class.h>
-#include <probes_mysql.h>
#include <scheduler.h>
#include <debug_sync.h>
#include <sql_profile.h>
@@ -55,9 +54,10 @@ bool do_command(THD *thd);
ensure that the proper MySQL Server logic attached to these events is
executed.
*/
-bool login_connection(THD *thd);
-void prepare_new_connection_state(THD* thd);
+bool thd_prepare_connection(THD *thd);
+bool thd_is_connection_alive(THD *thd);
void end_connection(THD *thd);
+void mysql_audit_release(THD *thd);
bool setup_connection_thread_globals(THD *thd);
bool init_new_connection_handler_thread();
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc
index ad6fe492056..2333c691240 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -685,6 +685,32 @@ pthread_handler_t handle_one_connection(void *arg)
return 0;
}
+bool thd_prepare_connection(THD *thd)
+{
+ bool rc;
+ lex_start(thd);
+ rc= login_connection(thd);
+ MYSQL_AUDIT_NOTIFY_CONNECTION_CONNECT(thd);
+ if (rc)
+ return rc;
+
+ MYSQL_CONNECTION_START(thd->thread_id, &thd->security_ctx->priv_user[0],
+ (char *) thd->security_ctx->host_or_ip);
+
+ prepare_new_connection_state(thd);
+ return FALSE;
+}
+
+bool thd_is_connection_alive(THD *thd)
+{
+ NET *net= &thd->net;
+ if (!net->error &&
+ net->vio != 0 &&
+ !(thd->killed == THD::KILL_CONNECTION))
+ return TRUE;
+ return FALSE;
+}
+
void do_handle_one_connection(THD *thd_arg)
{
THD *thd= thd_arg;
@@ -727,22 +753,13 @@ void do_handle_one_connection(THD *thd_arg)
for (;;)
{
- NET *net= &thd->net;
bool rc;
- lex_start(thd);
- rc= login_connection(thd);
- MYSQL_AUDIT_NOTIFY_CONNECTION_CONNECT(thd);
+ rc= thd_prepare_connection(thd);
if (rc)
goto end_thread;
- MYSQL_CONNECTION_START(thd->thread_id, &thd->security_ctx->priv_user[0],
- (char *) thd->security_ctx->host_or_ip);
-
- prepare_new_connection_state(thd);
-
- while (!net->error && net->vio != 0 &&
- !(thd->killed == THD::KILL_CONNECTION))
+ while (thd_is_connection_alive(thd))
{
mysql_audit_release(thd);
if (do_command(thd))
diff --git a/sql/sql_connect.h b/sql/sql_connect.h
index 666db4c6462..c0cb100c779 100644
--- a/sql/sql_connect.h
+++ b/sql/sql_connect.h
@@ -35,6 +35,8 @@ void time_out_user_resource_limits(THD *thd, USER_CONN *uc);
void decrease_user_connections(USER_CONN *uc);
void thd_init_client_charset(THD *thd, uint cs_number);
bool setup_connection_thread_globals(THD *thd);
+bool thd_prepare_connection(THD *thd);
+bool thd_is_connection_alive(THD *thd);
int check_user(THD *thd, enum enum_server_command command,
const char *passwd, uint passwd_len, const char *db,