summaryrefslogtreecommitdiff
path: root/sql/sql_connect.cc
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2019-05-17 00:38:35 +0400
committerSergey Vojtovich <svoj@mariadb.org>2019-05-21 17:55:09 +0400
commitce30c994781aa78a3cf3f028deefaf059f20f108 (patch)
treec5464adcd163363ee4b36eaba7fa69305020ae07 /sql/sql_connect.cc
parentefb61c12a929ae176b495e95d8995d9cac649b2d (diff)
downloadmariadb-git-ce30c994781aa78a3cf3f028deefaf059f20f108.tar.gz
Moved vio allocation to connection thread
Part of MDEV-19515 - Improve connect speed
Diffstat (limited to 'sql/sql_connect.cc')
-rw-r--r--sql/sql_connect.cc35
1 files changed, 25 insertions, 10 deletions
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc
index b88cfcc5025..25a260b2eba 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -1441,8 +1441,15 @@ void CONNECT::close_and_delete()
{
DBUG_ENTER("close_and_delete");
- if (vio)
- vio_close(vio);
+#if _WIN32
+ if (vio_type == VIO_TYPE_NAMEDPIPE)
+ CloseHandle(pipe);
+ else
+#endif
+ if (vio_type != VIO_CLOSED)
+ mysql_socket_close(sock);
+ vio_type= VIO_CLOSED;
+
if (thread_count_incremented)
dec_connection_count(scheduler);
statistic_increment(connection_errors_internal, &LOCK_status);
@@ -1473,18 +1480,12 @@ void CONNECT::close_with_error(uint sql_errno,
}
-CONNECT::~CONNECT()
-{
- if (vio)
- vio_delete(vio);
-}
-
-
/* Reuse or create a THD based on a CONNECT object */
THD *CONNECT::create_thd(THD *thd)
{
bool res, thd_reused= thd != 0;
+ Vio *vio;
DBUG_ENTER("create_thd");
DBUG_EXECUTE_IF("simulate_failed_connection_2", DBUG_RETURN(0); );
@@ -1503,9 +1504,23 @@ THD *CONNECT::create_thd(THD *thd)
else if (!(thd= new THD(thread_id)))
DBUG_RETURN(0);
+#if _WIN32
+ if (vio_type == VIO_TYPE_NAMEDPIPE)
+ vio= vio_new_win32pipe(pipe);
+ else
+#endif
+ vio= mysql_socket_vio_new(sock, vio_type, vio_type == VIO_TYPE_SOCKET ?
+ VIO_LOCALHOST : 0);
+ if (!vio)
+ {
+ if (!thd_reused)
+ delete thd;
+ DBUG_RETURN(0);
+ }
+
set_current_thd(thd);
res= my_net_init(&thd->net, vio, thd, MYF(MY_THREAD_SPECIFIC));
- vio= 0; // Vio now handled by thd
+ vio_type= VIO_CLOSED; // Vio now handled by thd
if (unlikely(res || thd->is_error()))
{