diff --git a/deps/Makefile b/deps/Makefile index cae3170ad..87d19d87a 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -95,6 +95,7 @@ mariadb-client-library/mariadb_client/libmariadb/libmariadbclient.a: cd mariadb-client-library/mariadb_client && patch include/mysql.h < ../mysql.h.patch cd mariadb-client-library/mariadb_client && patch libmariadb/ma_alloc.c < ../ma_alloc.c.patch cd mariadb-client-library/mariadb_client && patch libmariadb/ma_charset.c < ../ma_charset.c.patch + cd mariadb-client-library/mariadb_client && patch libmariadb/ma_pvio.c < ../ma_pvio.c.patch cd mariadb-client-library/mariadb_client && patch unittest/libmariadb/basic-t.c < ../unittest_basic-t.c.patch cd mariadb-client-library/mariadb_client && patch unittest/libmariadb/charset.c < ../unittest_charset.c.patch cd mariadb-client-library/mariadb_client && CC=${CC} CXX=${CXX} ${MAKE} diff --git a/deps/mariadb-client-library/ma_pvio.c.patch b/deps/mariadb-client-library/ma_pvio.c.patch new file mode 100644 index 000000000..ce5de8a91 --- /dev/null +++ b/deps/mariadb-client-library/ma_pvio.c.patch @@ -0,0 +1,135 @@ +@@ -53,6 +53,10 @@ + #include + #include + #include ++#include /* SSL and SSL_CTX */ ++#include /* error reporting */ ++#include ++#include + + /* callback functions for read/write */ + LIST *pvio_callback= NULL; +@@ -215,6 +219,68 @@ + } + /* }}} */ + ++#ifdef HAVE_TLS ++/* {{{ size_t ma_pvio_tls_write_async */ ++static size_t ma_pvio_tls_write_async(MARIADB_PVIO *pvio, const uchar *buffer, size_t length) ++{ ++ ssize_t res= 0; ++ struct mysql_async_context *b= pvio->mysql->options.extension->async_context; ++ int ssl_err; ++ ++ if (!pvio->methods->async_read) ++ { ++ PVIO_SET_ERROR(pvio->mysql, CR_ASYNC_NOT_SUPPORTED, unknown_sqlstate, 0); ++ return -1; ++ } ++ ++ for (;;) ++ { ++ res = ma_pvio_tls_write(pvio->ctls, buffer, length); ++ if (res > 0) { ++ return res; ++ } else { ++ ssl_err= SSL_get_error((SSL *)pvio->ctls->ssl, res); ++ if (ssl_err == SSL_ERROR_WANT_READ) ++ b->events_to_wait_for|= MYSQL_WAIT_READ; ++ else if (ssl_err == SSL_ERROR_WANT_WRITE) ++ b->events_to_wait_for|= MYSQL_WAIT_WRITE; ++ else ++ return 1; ++ } ++ } ++} ++/* {{{ size_t ma_pvio_tls_read_async */ ++static size_t ma_pvio_tls_read_async(MARIADB_PVIO *pvio, uchar *buffer, size_t length) ++{ ++ ssize_t res= 0; ++ struct mysql_async_context *b= pvio->mysql->options.extension->async_context; ++ int ssl_err; ++ ++ if (!pvio->methods->async_read) ++ { ++ PVIO_SET_ERROR(pvio->mysql, CR_ASYNC_NOT_SUPPORTED, unknown_sqlstate, 0); ++ return -1; ++ } ++ ++ for (;;) ++ { ++ res = ma_pvio_tls_read(pvio->ctls, buffer, length); ++ if (res > 0) { ++ return res; ++ } else { ++ ssl_err= SSL_get_error((SSL *)pvio->ctls->ssl, res); ++ if (ssl_err == SSL_ERROR_WANT_READ) ++ b->events_to_wait_for|= MYSQL_WAIT_READ; ++ else if (ssl_err == SSL_ERROR_WANT_WRITE) ++ b->events_to_wait_for|= MYSQL_WAIT_WRITE; ++ else ++ return 1; ++ } ++ } ++} ++/* }}} */ ++#endif ++ + /* {{{ size_t ma_pvio_read */ + ssize_t ma_pvio_read(MARIADB_PVIO *pvio, uchar *buffer, size_t length) + { +@@ -223,6 +289,13 @@ + return -1; + if (IS_PVIO_ASYNC_ACTIVE(pvio)) + { ++#ifdef HAVE_TLS ++ if (pvio->ctls) ++ { ++ r= ma_pvio_tls_read_async(pvio, buffer, length); ++ goto end; ++ } ++#endif + r= ma_pvio_read_async(pvio, buffer, length); + goto end; + } +@@ -343,17 +416,15 @@ + if (!pvio) + return -1; + +- /* secure connection */ +-#ifdef HAVE_TLS +- if (pvio->ctls) +- { +- r= ma_pvio_tls_write(pvio->ctls, buffer, length); +- goto end; +- } +- else +-#endif + if (IS_PVIO_ASYNC_ACTIVE(pvio)) + { ++#ifdef HAVE_TLS ++ if (pvio->ctls) ++ { ++ r= ma_pvio_tls_write_async(pvio, buffer, length); ++ goto end; ++ } ++#endif + r= ma_pvio_write_async(pvio, buffer, length); + goto end; + } +@@ -370,6 +441,15 @@ + } + } + ++ /* secure connection */ ++#ifdef HAVE_TLS ++ if (pvio->ctls) ++ { ++ r= ma_pvio_tls_write(pvio->ctls, buffer, length); ++ goto end; ++ } ++#endif ++ + if (pvio->methods->write) + r= pvio->methods->write(pvio, buffer, length); + end: