From 6411c94240b4a756c59df57d9fca87fa7e413a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Tue, 10 Apr 2018 18:06:58 +0200 Subject: [PATCH] Fix async call for SSL backend. Solves a severe performance issue --- deps/mariadb-client-library/ma_pvio.c.patch | 22 +++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/deps/mariadb-client-library/ma_pvio.c.patch b/deps/mariadb-client-library/ma_pvio.c.patch index ce5de8a91..e9c4abb31 100644 --- a/deps/mariadb-client-library/ma_pvio.c.patch +++ b/deps/mariadb-client-library/ma_pvio.c.patch @@ -9,7 +9,7 @@ /* callback functions for read/write */ LIST *pvio_callback= NULL; -@@ -215,6 +219,68 @@ +@@ -215,6 +219,78 @@ } /* }}} */ @@ -30,7 +30,7 @@ + for (;;) + { + res = ma_pvio_tls_write(pvio->ctls, buffer, length); -+ if (res > 0) { ++ if (res >= 0) { + return res; + } else { + ssl_err= SSL_get_error((SSL *)pvio->ctls->ssl, res); @@ -40,6 +40,11 @@ + b->events_to_wait_for|= MYSQL_WAIT_WRITE; + else + return 1; ++ if (b->suspend_resume_hook) ++ (*b->suspend_resume_hook)(TRUE, b->suspend_resume_hook_user_data); ++ my_context_yield(&b->async_context); ++ if (b->suspend_resume_hook) ++ (*b->suspend_resume_hook)(FALSE, b->suspend_resume_hook_user_data); + } + } +} @@ -59,7 +64,7 @@ + for (;;) + { + res = ma_pvio_tls_read(pvio->ctls, buffer, length); -+ if (res > 0) { ++ if (res >= 0) { + return res; + } else { + ssl_err= SSL_get_error((SSL *)pvio->ctls->ssl, res); @@ -69,6 +74,11 @@ + b->events_to_wait_for|= MYSQL_WAIT_WRITE; + else + return 1; ++ if (b->suspend_resume_hook) ++ (*b->suspend_resume_hook)(TRUE, b->suspend_resume_hook_user_data); ++ my_context_yield(&b->async_context); ++ if (b->suspend_resume_hook) ++ (*b->suspend_resume_hook)(FALSE, b->suspend_resume_hook_user_data); + } + } +} @@ -78,7 +88,7 @@ /* {{{ size_t ma_pvio_read */ ssize_t ma_pvio_read(MARIADB_PVIO *pvio, uchar *buffer, size_t length) { -@@ -223,6 +289,13 @@ +@@ -223,6 +299,13 @@ return -1; if (IS_PVIO_ASYNC_ACTIVE(pvio)) { @@ -92,7 +102,7 @@ r= ma_pvio_read_async(pvio, buffer, length); goto end; } -@@ -343,17 +416,15 @@ +@@ -343,17 +426,15 @@ if (!pvio) return -1; @@ -117,7 +127,7 @@ r= ma_pvio_write_async(pvio, buffer, length); goto end; } -@@ -370,6 +441,15 @@ +@@ -370,6 +451,15 @@ } }