diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-08-01 14:42:51 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-08-01 14:42:51 +0300 |
commit | 50a11f396af81aac6d5f51e8278ec9a7fa17e7c8 (patch) | |
tree | 1a695f030aa737b200e9271f9403971f8a571849 /vio | |
parent | 842da858b6c5b619bb5395ef4216f7e675b0f3a0 (diff) | |
parent | 9216114ce729733e6b0c4ce952bfdf57595ff387 (diff) | |
download | mariadb-git-50a11f396af81aac6d5f51e8278ec9a7fa17e7c8.tar.gz |
Merge 10.4 into 10.5
Diffstat (limited to 'vio')
-rw-r--r-- | vio/vio_priv.h | 1 | ||||
-rw-r--r-- | vio/viopipe.c | 6 | ||||
-rw-r--r-- | vio/viosocket.c | 29 |
3 files changed, 27 insertions, 9 deletions
diff --git a/vio/vio_priv.h b/vio/vio_priv.h index 8dc38ab31e8..55c34be9dd7 100644 --- a/vio/vio_priv.h +++ b/vio/vio_priv.h @@ -37,6 +37,7 @@ my_bool vio_is_connected_pipe(Vio *vio); int vio_close_pipe(Vio * vio); int cancel_io(HANDLE handle, DWORD thread_id); int vio_shutdown_pipe(Vio *vio,int how); +uint vio_pending_pipe(Vio* vio); #endif diff --git a/vio/viopipe.c b/vio/viopipe.c index 6db0944d8df..567884807fe 100644 --- a/vio/viopipe.c +++ b/vio/viopipe.c @@ -140,5 +140,11 @@ int vio_close_pipe(Vio *vio) DBUG_RETURN(ret); } +/* return number of bytes readable from pipe.*/ +uint vio_pending_pipe(Vio *vio) +{ + DWORD bytes; + return PeekNamedPipe(vio->hPipe, NULL, 0, NULL, &bytes, NULL) ? bytes : 0; +} #endif diff --git a/vio/viosocket.c b/vio/viosocket.c index 2d240688ce0..9cad035161c 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -1252,7 +1252,6 @@ my_bool vio_is_connected(Vio *vio) DBUG_RETURN(bytes ? TRUE : FALSE); } -#ifndef DBUG_OFF /** Number of bytes in the read or socket buffer @@ -1271,22 +1270,34 @@ ssize_t vio_pending(Vio *vio) return vio->read_end - vio->read_pos; /* Skip non-socket based transport types. */ - if (vio->type == VIO_TYPE_TCPIP || vio->type == VIO_TYPE_SOCKET) + switch (vio->type) { + case VIO_TYPE_TCPIP: + /* fallthrough */ + case VIO_TYPE_SOCKET: /* Obtain number of readable bytes in the socket buffer. */ if (socket_peek_read(vio, &bytes)) return -1; - } + return bytes; - /* - SSL not checked due to a yaSSL bug in SSL_pending that - causes it to attempt to read from the socket. - */ + case VIO_TYPE_SSL: + bytes= (uint) SSL_pending(vio->ssl_arg); + if (bytes) + return bytes; + if (socket_peek_read(vio, &bytes)) + return -1; + return bytes; - return (ssize_t) bytes; +#ifdef _WIN32 + case VIO_TYPE_NAMEDPIPE: + bytes= vio_pending_pipe(vio); + return bytes; +#endif + default: + return -1; + } } -#endif /* DBUG_OFF */ /** Checks if the error code, returned by vio_getnameinfo(), means it was the |