summaryrefslogtreecommitdiff
path: root/vio
diff options
context:
space:
mode:
Diffstat (limited to 'vio')
-rwxr-xr-xvio/CMakeLists.txt2
-rw-r--r--vio/Makefile.am9
-rw-r--r--vio/viosocket.c45
-rw-r--r--vio/viossl.c26
-rw-r--r--vio/viosslfactories.c6
5 files changed, 68 insertions, 20 deletions
diff --git a/vio/CMakeLists.txt b/vio/CMakeLists.txt
index 164bcde7c4b..e1bd57d150f 100755
--- a/vio/CMakeLists.txt
+++ b/vio/CMakeLists.txt
@@ -13,8 +13,6 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -DSAFEMALLOC -DSAFE_MUTEX")
-SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG -DSAFEMALLOC -DSAFE_MUTEX")
ADD_DEFINITIONS(-DUSE_SYMDIR)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/extra/yassl/include)
diff --git a/vio/Makefile.am b/vio/Makefile.am
index 27596bb2fa4..588cd3ea0c4 100644
--- a/vio/Makefile.am
+++ b/vio/Makefile.am
@@ -17,12 +17,15 @@ INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
$(openssl_includes)
LDADD = @CLIENT_EXTRA_LDFLAGS@ $(openssl_libs) $(yassl_libs)
pkglib_LIBRARIES = libvio.a
+noinst_LTLIBRARIES = libvio.la
noinst_HEADERS = vio_priv.h
-libvio_a_SOURCES = vio.c viosocket.c viossl.c viosslfactories.c
+libvio_la_SOURCES = vio.c viosocket.c viossl.c viosslfactories.c
EXTRA_DIST= CMakeLists.txt
-# Don't update the files from bitkeeper
-%::SCCS/s.%
+libvio_a_SOURCES=
+libvio.a: libvio.la
+ $(CP) .libs/libvio.a $@
+
diff --git a/vio/viosocket.c b/vio/viosocket.c
index 9633a01f689..84f828c3d3e 100644
--- a/vio/viosocket.c
+++ b/vio/viosocket.c
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2001, 2011, Oracle and/or its affiliates
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -396,7 +396,20 @@ void vio_in_addr(Vio *vio, struct in_addr *in)
my_bool vio_poll_read(Vio *vio,uint timeout)
{
#ifndef HAVE_POLL
+#if __WIN__
+ int res;
+ struct fd_set fds;
+ struct timeval tv;
+ DBUG_ENTER("vio_poll");
+ fds.fd_count= 1;
+ fds.fd_array[0]= vio->sd;
+ tv.tv_sec= timeout;
+ tv.tv_usec= 0;
+ res= select(1, &fds, NULL, NULL, &tv) ? 0 : 1;
+ DBUG_RETURN(res);
+#else
return 0;
+#endif
#else
struct pollfd fds;
int res;
@@ -416,7 +429,9 @@ my_bool vio_poll_read(Vio *vio,uint timeout)
void vio_timeout(Vio *vio, uint which, uint timeout)
{
#if defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO)
+#ifndef DBUG_OFF
int r;
+#endif
DBUG_ENTER("vio_timeout");
{
@@ -430,10 +445,12 @@ void vio_timeout(Vio *vio, uint which, uint timeout)
wait_timeout.tv_usec= 0;
#endif
- r= setsockopt(vio->sd, SOL_SOCKET, which ? SO_SNDTIMEO : SO_RCVTIMEO,
- IF_WIN(const char*, const void*)&wait_timeout,
- sizeof(wait_timeout));
-
+#ifndef DBUG_OFF
+ r=
+#endif
+ setsockopt(vio->sd, SOL_SOCKET, which ? SO_SNDTIMEO : SO_RCVTIMEO,
+ IF_WIN(const char*, const void*)&wait_timeout,
+ sizeof(wait_timeout));
}
#ifndef DBUG_OFF
@@ -755,3 +772,21 @@ 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)
+{
+ if (vio->read_pos < vio->read_end)
+ return vio->read_end - vio->read_pos;
+#ifdef HAVE_OPENSSL
+ if (vio->ssl_arg)
+ return SSL_pending((SSL*) vio->ssl_arg);
+#endif
+ return 0;
+}
diff --git a/vio/viossl.c b/vio/viossl.c
index 0651fd8b7a3..61e4d9406a7 100644
--- a/vio/viossl.c
+++ b/vio/viossl.c
@@ -74,8 +74,13 @@ report_errors(SSL* ssl)
}
if (ssl)
- DBUG_PRINT("error", ("error: %s",
- ERR_error_string(SSL_get_error(ssl, l), buf)));
+ {
+#ifndef DBUG_OFF
+ int error= SSL_get_error(ssl, l);
+ DBUG_PRINT("error", ("error: %s (%d)",
+ ERR_error_string(error, buf), error));
+#endif
+ }
DBUG_PRINT("info", ("socket_errno: %d", socket_errno));
DBUG_VOID_RETURN;
@@ -174,16 +179,17 @@ void vio_ssl_delete(Vio *vio)
static int ssl_do(struct st_VioSSLFd *ptr, Vio *vio, long timeout,
- int (*connect_accept_func)(SSL*))
+ int (*connect_accept_func)(SSL*), char *error_string)
{
SSL *ssl;
my_bool unused;
my_bool was_blocking;
-
DBUG_ENTER("ssl_do");
DBUG_PRINT("enter", ("ptr: 0x%lx, sd: %d ctx: 0x%lx",
(long) ptr, vio->sd, (long) ptr->ssl_context));
+ error_string[0]= 0;
+
/* Set socket to blocking if not already set */
vio_blocking(vio, 1, &was_blocking);
@@ -191,6 +197,7 @@ static int ssl_do(struct st_VioSSLFd *ptr, Vio *vio, long timeout,
{
DBUG_PRINT("error", ("SSL_new failure"));
report_errors(ssl);
+ strmov(error_string, "SSL_new failed");
vio_blocking(vio, was_blocking, &unused);
DBUG_RETURN(1);
}
@@ -203,6 +210,7 @@ static int ssl_do(struct st_VioSSLFd *ptr, Vio *vio, long timeout,
{
DBUG_PRINT("error", ("SSL_connect/accept failure"));
report_errors(ssl);
+ ERR_error_string(SSL_get_error(ssl, 0), error_string);
SSL_free(ssl);
vio_blocking(vio, was_blocking, &unused);
DBUG_RETURN(1);
@@ -250,17 +258,19 @@ static int ssl_do(struct st_VioSSLFd *ptr, Vio *vio, long timeout,
}
-int sslaccept(struct st_VioSSLFd *ptr, Vio *vio, long timeout)
+int sslaccept(struct st_VioSSLFd *ptr, Vio *vio, long timeout,
+ char *error_string)
{
DBUG_ENTER("sslaccept");
- DBUG_RETURN(ssl_do(ptr, vio, timeout, SSL_accept));
+ DBUG_RETURN(ssl_do(ptr, vio, timeout, SSL_accept, error_string));
}
-int sslconnect(struct st_VioSSLFd *ptr, Vio *vio, long timeout)
+int sslconnect(struct st_VioSSLFd *ptr, Vio *vio, long timeout,
+ char *error_string)
{
DBUG_ENTER("sslconnect");
- DBUG_RETURN(ssl_do(ptr, vio, timeout, SSL_connect));
+ DBUG_RETURN(ssl_do(ptr, vio, timeout, SSL_connect, error_string));
}
diff --git a/vio/viosslfactories.c b/vio/viosslfactories.c
index 3c0c2f3a7ec..31863a0830f 100644
--- a/vio/viosslfactories.c
+++ b/vio/viosslfactories.c
@@ -300,7 +300,8 @@ new_VioSSLConnectorFd(const char *key_file, const char *cert_file,
verify= SSL_VERIFY_NONE;
if (!(ssl_fd= new_VioSSLFd(key_file, cert_file, ca_file,
- ca_path, cipher, TLSv1_client_method(), &dummy)))
+ ca_path, cipher,
+ (SSL_METHOD*) TLSv1_client_method(), &dummy)))
{
return 0;
}
@@ -322,7 +323,8 @@ new_VioSSLAcceptorFd(const char *key_file, const char *cert_file,
struct st_VioSSLFd *ssl_fd;
int verify= SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE;
if (!(ssl_fd= new_VioSSLFd(key_file, cert_file, ca_file,
- ca_path, cipher, TLSv1_server_method(), error)))
+ ca_path, cipher,
+ (SSL_METHOD*) TLSv1_server_method(), error)))
{
return 0;
}