summaryrefslogtreecommitdiff
path: root/vio
diff options
context:
space:
mode:
authorKonstantin Osipov <kostja@sun.com>2009-11-21 02:12:23 +0300
committerKonstantin Osipov <kostja@sun.com>2009-11-21 02:12:23 +0300
commita2a437b7cae6e5d78296a936738a07f2d9ef88f9 (patch)
tree5dce889282a827cf14833d620768175a0d2da231 /vio
parent9a1043417d99769026277ed34b629c7bf9eae494 (diff)
downloadmariadb-git-a2a437b7cae6e5d78296a936738a07f2d9ef88f9.tar.gz
Backport the implementation of vio_pending from 6.0-codebase.
Original changeset: ------------------------------------------------------------ revno: 2626 committer: davi@mysql.com/endora.local timestamp: Wed 2008-04-23 09:33:25 -0300 message: Fix for main.ssl and main.ssl_compress test case failures under pool-of-threads. The problem is that the SSL layer has a read buffer and might read more data than requested by the VIO layer. The SSL layer empties the socket buffer which causes the socket to not be signaled for IO if the client is waiting for a command which is sitting in the read buffer. The solution is to retrieve from the transport layer the number of bytes waiting in the read buffer. The data in the read buffer needs to be processed before waiting for more data.
Diffstat (limited to 'vio')
-rw-r--r--vio/viosocket.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/vio/viosocket.c b/vio/viosocket.c
index 30187cbed56..51345d072b2 100644
--- a/vio/viosocket.c
+++ b/vio/viosocket.c
@@ -855,3 +855,27 @@ int vio_close_shared_memory(Vio * vio)
}
#endif /* HAVE_SMEM */
#endif /* __WIN__ */
+
+
+/**
+ Number of bytes in the read buffer.
+
+ @return number of bytes in the read buffer or < 0 if error.
+*/
+
+ssize_t vio_pending(Vio *vio)
+{
+#ifdef HAVE_OPENSSL
+ SSL *ssl= (SSL*) vio->ssl_arg;
+#endif
+
+ if (vio->read_pos < vio->read_end)
+ return vio->read_end - vio->read_pos;
+
+#ifdef HAVE_OPENSSL
+ if (ssl)
+ return SSL_pending(ssl);
+#endif
+
+ return 0;
+}