summaryrefslogtreecommitdiff
path: root/vio
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2020-08-11 12:11:07 +0000
committerVladislav Vaintroub <wlad@mariadb.com>2020-09-01 21:30:52 +0200
commit32a29afea777d8bbfcea7a2b5e6e5ee674013cb5 (patch)
tree07bf60d71eff90b3b48c0b6e0f95cdf4e78f9e30 /vio
parent72f0f0db9caaca6da7b9b35d60faa09b132442ec (diff)
downloadmariadb-git-32a29afea777d8bbfcea7a2b5e6e5ee674013cb5.tar.gz
MDEV-23238 - remove async client from server code.
It is already in libmariadb, and server (also that client in server) does not need it. It does not work in embedded either since it relies on non-blocking sockets
Diffstat (limited to 'vio')
-rw-r--r--vio/viosocket.c105
-rw-r--r--vio/viossl.c47
2 files changed, 36 insertions, 116 deletions
diff --git a/vio/viosocket.c b/vio/viosocket.c
index 9cad035161c..f84d0e0738b 100644
--- a/vio/viosocket.c
+++ b/vio/viosocket.c
@@ -31,8 +31,6 @@
#include <mstcpip.h>
#pragma comment(lib, "ws2_32.lib")
#endif
-#include "my_context.h"
-#include <mysql_async.h>
#ifdef FIONREAD_IN_SYS_FILIO
# include <sys/filio.h>
@@ -171,34 +169,18 @@ size_t vio_read(Vio *vio, uchar *buf, size_t size)
if (vio->read_timeout >= 0)
flags= VIO_DONTWAIT;
- if (vio->async_context && vio->async_context->active)
- ret= my_recv_async(vio->async_context,
- mysql_socket_getfd(vio->mysql_socket),
- buf, size, vio->read_timeout);
- else
+ while ((ret= mysql_socket_recv(vio->mysql_socket, (SOCKBUF_T *)buf, size,
+ flags)) == -1)
{
- if (vio->async_context)
- {
- /*
- If switching from non-blocking to blocking API usage, set the socket
- back to blocking mode.
- */
- my_bool old_mode;
- vio_blocking(vio, TRUE, &old_mode);
- }
- while ((ret= mysql_socket_recv(vio->mysql_socket, (SOCKBUF_T *)buf, size,
- flags)) == -1)
- {
- int error= socket_errno;
+ int error= socket_errno;
- /* The operation would block? */
- if (error != SOCKET_EAGAIN && error != SOCKET_EWOULDBLOCK)
- break;
+ /* The operation would block? */
+ if (error != SOCKET_EAGAIN && error != SOCKET_EWOULDBLOCK)
+ break;
- /* Wait for input data to become available. */
- if ((ret= vio_socket_io_wait(vio, VIO_IO_EVENT_READ)))
- break;
- }
+ /* Wait for input data to become available. */
+ if ((ret= vio_socket_io_wait(vio, VIO_IO_EVENT_READ)))
+ break;
}
#ifndef DBUG_OFF
if (ret == -1)
@@ -282,33 +264,17 @@ size_t vio_write(Vio *vio, const uchar* buf, size_t size)
if (vio->write_timeout >= 0)
flags= VIO_DONTWAIT;
- if (vio->async_context && vio->async_context->active)
- ret= my_send_async(vio->async_context,
- mysql_socket_getfd(vio->mysql_socket), buf, size,
- vio->write_timeout);
- else
+ while ((ret= mysql_socket_send(vio->mysql_socket, (SOCKBUF_T *)buf, size,
+ flags)) == -1)
{
- if (vio->async_context)
- {
- /*
- If switching from non-blocking to blocking API usage, set the socket
- back to blocking mode.
- */
- my_bool old_mode;
- vio_blocking(vio, TRUE, &old_mode);
- }
- while ((ret= mysql_socket_send(vio->mysql_socket, (SOCKBUF_T *)buf, size,
- flags)) == -1)
- {
- int error= socket_errno;
- /* The operation would block? */
- if (error != SOCKET_EAGAIN && error != SOCKET_EWOULDBLOCK)
- break;
-
- /* Wait for the output buffer to become writable.*/
- if ((ret= vio_socket_io_wait(vio, VIO_IO_EVENT_WRITE)))
- break;
- }
+ int error= socket_errno;
+ /* The operation would block? */
+ if (error != SOCKET_EAGAIN && error != SOCKET_EWOULDBLOCK)
+ break;
+
+ /* Wait for the output buffer to become writable.*/
+ if ((ret= vio_socket_io_wait(vio, VIO_IO_EVENT_WRITE)))
+ break;
}
#ifndef DBUG_OFF
if (ret == -1)
@@ -953,24 +919,6 @@ int vio_io_wait(Vio *vio, enum enum_vio_io_event event, int timeout)
DBUG_ENTER("vio_io_wait");
DBUG_PRINT("enter", ("timeout: %d", timeout));
- /*
- Note that if zero timeout, then we will not block, so we do not need to
- yield to calling application in the async case.
- */
- if (timeout != 0 && vio->async_context && vio->async_context->active)
- {
- START_SOCKET_WAIT(locker, &state, vio->mysql_socket,
- PSI_SOCKET_SELECT, timeout);
- ret= my_io_wait_async(vio->async_context, event, timeout);
- if (ret == 0)
- {
- DBUG_PRINT("info", ("timeout"));
- errno= SOCKET_ETIMEDOUT;
- }
- END_SOCKET_WAIT(locker,timeout);
- DBUG_RETURN(ret);
- }
-
memset(&pfd, 0, sizeof(pfd));
pfd.fd= sd;
@@ -1032,21 +980,6 @@ int vio_io_wait(Vio *vio, enum enum_vio_io_event event, int timeout)
MYSQL_SOCKET_WAIT_VARIABLES(locker, state) /* no ';' */
DBUG_ENTER("vio_io_wait");
- /*
- Note that if zero timeout, then we will not block, so we do not need to
- yield to calling application in the async case.
- */
- if (timeout != 0 && vio->async_context && vio->async_context->active)
- {
- START_SOCKET_WAIT(locker, &state, vio->mysql_socket,
- PSI_SOCKET_SELECT, timeout);
- ret= my_io_wait_async(vio->async_context, event, timeout);
- if (ret == 0)
- WSASetLastError(SOCKET_ETIMEDOUT);
- END_SOCKET_WAIT(locker, timeout);
- DBUG_RETURN(ret);
- }
-
/* Convert the timeout, in milliseconds, to seconds and microseconds. */
if (timeout >= 0)
{
diff --git a/vio/viossl.c b/vio/viossl.c
index a5b3396953e..04bc0e41ae9 100644
--- a/vio/viossl.c
+++ b/vio/viossl.c
@@ -21,8 +21,6 @@
*/
#include "vio_priv.h"
-#include "my_context.h"
-#include <mysql_async.h>
#ifdef HAVE_OPENSSL
@@ -129,21 +127,17 @@ size_t vio_ssl_read(Vio *vio, uchar *buf, size_t size)
(int)mysql_socket_getfd(vio->mysql_socket), buf, size,
vio->ssl_arg));
- if (vio->async_context && vio->async_context->active)
- ret= my_ssl_read_async(vio->async_context, (SSL *)vio->ssl_arg, buf, (int)size);
- else
+
+ while ((ret= SSL_read(ssl, buf, (int)size)) < 0)
{
- while ((ret= SSL_read(ssl, buf, (int)size)) < 0)
- {
- enum enum_vio_io_event event;
+ enum enum_vio_io_event event;
- /* Process the SSL I/O error. */
- if (!ssl_should_retry(vio, ret, &event))
- break;
- /* Attempt to wait for an I/O event. */
- if (vio_socket_io_wait(vio, event))
- break;
- }
+ /* Process the SSL I/O error. */
+ if (!ssl_should_retry(vio, ret, &event))
+ break;
+ /* Attempt to wait for an I/O event. */
+ if (vio_socket_io_wait(vio, event))
+ break;
}
DBUG_PRINT("exit", ("%d", (int) ret));
@@ -160,24 +154,17 @@ size_t vio_ssl_write(Vio *vio, const uchar *buf, size_t size)
DBUG_PRINT("enter", ("sd: %d buf: %p size: %zu",
(int)mysql_socket_getfd(vio->mysql_socket),
buf, size));
-
- if (vio->async_context && vio->async_context->active)
- ret= my_ssl_write_async(vio->async_context, (SSL *)vio->ssl_arg, buf,
- (int)size);
- else
+ while ((ret= SSL_write(ssl, buf, (int)size)) < 0)
{
- while ((ret= SSL_write(ssl, buf, (int)size)) < 0)
- {
- enum enum_vio_io_event event;
+ enum enum_vio_io_event event;
- /* Process the SSL I/O error. */
- if (!ssl_should_retry(vio, ret, &event))
- break;
+ /* Process the SSL I/O error. */
+ if (!ssl_should_retry(vio, ret, &event))
+ break;
- /* Attempt to wait for an I/O event. */
- if (vio_socket_io_wait(vio, event))
- break;
- }
+ /* Attempt to wait for an I/O event. */
+ if (vio_socket_io_wait(vio, event))
+ break;
}
DBUG_RETURN(ret < 0 ? -1 : ret);