summaryrefslogtreecommitdiff
path: root/vio
diff options
context:
space:
mode:
Diffstat (limited to 'vio')
-rw-r--r--[-rwxr-xr-x]vio/CMakeLists.txt0
-rw-r--r--vio/Makefile.am3
-rw-r--r--vio/vio.c4
-rw-r--r--vio/viosocket.c66
-rw-r--r--vio/viosslfactories.c8
5 files changed, 58 insertions, 23 deletions
diff --git a/vio/CMakeLists.txt b/vio/CMakeLists.txt
index a3cbb304289..a3cbb304289 100755..100644
--- a/vio/CMakeLists.txt
+++ b/vio/CMakeLists.txt
diff --git a/vio/Makefile.am b/vio/Makefile.am
index cb70501046e..b57f2453f41 100644
--- a/vio/Makefile.am
+++ b/vio/Makefile.am
@@ -38,6 +38,7 @@ test_sslclient_LDADD= @CLIENT_EXTRA_LDFLAGS@ ../dbug/libdbug.a libvio.a \
../mysys/libmysys.a ../strings/libmystrings.a \
$(openssl_libs) $(yassl_libs)
libvio_a_SOURCES= vio.c viosocket.c viossl.c viosslfactories.c
-EXTRA_DIST= CMakeLists.txt
+EXTRA_DIST= CMakeLists.txt
+
# Don't update the files from bitkeeper
%::SCCS/s.%
diff --git a/vio/vio.c b/vio/vio.c
index 2b0a7f0d79b..f20acb249ef 100644
--- a/vio/vio.c
+++ b/vio/vio.c
@@ -147,7 +147,7 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, uint flags)
sprintf(vio->desc,
(vio->type == VIO_TYPE_SOCKET ? "socket (%d)" : "TCP/IP (%d)"),
vio->sd);
-#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
+#if !defined(__WIN__)
#if !defined(NO_FCNTL_NONBLOCK)
/*
We call fcntl() to set the flags and then immediately read them back
@@ -166,7 +166,7 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, uint flags)
(void) ioctl(sd,FIOSNBIO,0);
vio->fcntl_mode &= ~O_NONBLOCK;
#endif
-#else /* !defined(__WIN__) && !defined(__EMX__) */
+#else /* !defined(__WIN__) */
{
/* set to blocking mode by default */
ulong arg=0, r;
diff --git a/vio/viosocket.c b/vio/viosocket.c
index 1ab3ae2fba0..34ef6159a86 100644
--- a/vio/viosocket.c
+++ b/vio/viosocket.c
@@ -33,7 +33,8 @@ int vio_read(Vio * vio, gptr buf, int size)
{
int r;
DBUG_ENTER("vio_read");
- DBUG_PRINT("enter", ("sd: %d, buf: 0x%p, size: %d", vio->sd, buf, size));
+ DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %d", vio->sd, (long) buf,
+ size));
/* Ensure nobody uses vio_read_buff and vio_read simultaneously */
DBUG_ASSERT(vio->read_end == vio->read_pos);
@@ -64,7 +65,8 @@ int vio_read_buff(Vio *vio, gptr buf, int size)
int rc;
#define VIO_UNBUFFERED_READ_MIN_SIZE 2048
DBUG_ENTER("vio_read_buff");
- DBUG_PRINT("enter", ("sd: %d, buf: 0x%p, size: %d", vio->sd, buf, size));
+ DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %d", vio->sd, (long) buf,
+ size));
if (vio->read_pos < vio->read_end)
{
@@ -102,7 +104,8 @@ int vio_write(Vio * vio, const gptr buf, int size)
{
int r;
DBUG_ENTER("vio_write");
- DBUG_PRINT("enter", ("sd: %d, buf: 0x%p, size: %d", vio->sd, buf, size));
+ DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %d", vio->sd, (long) buf,
+ size));
#ifdef __WIN__
r = send(vio->sd, buf, size,0);
#else
@@ -128,7 +131,7 @@ int vio_blocking(Vio * vio __attribute__((unused)), my_bool set_blocking_mode,
DBUG_PRINT("enter", ("set_blocking_mode: %d old_mode: %d",
(int) set_blocking_mode, (int) *old_mode));
-#if !defined(__WIN__) && !defined(__EMX__)
+#if !defined(__WIN__)
#if !defined(NO_FCNTL_NONBLOCK)
if (vio->sd >= 0)
{
@@ -150,10 +153,8 @@ int vio_blocking(Vio * vio __attribute__((unused)), my_bool set_blocking_mode,
#else
r= set_blocking_mode ? 0 : 1;
#endif /* !defined(NO_FCNTL_NONBLOCK) */
-#else /* !defined(__WIN__) && !defined(__EMX__) */
-#ifndef __EMX__
+#else /* !defined(__WIN__) */
if (vio->type != VIO_TYPE_NAMEDPIPE && vio->type != VIO_TYPE_SHARED_MEMORY)
-#endif
{
ulong arg;
int old_fcntl=vio->fcntl_mode;
@@ -170,11 +171,9 @@ int vio_blocking(Vio * vio __attribute__((unused)), my_bool set_blocking_mode,
if (old_fcntl != vio->fcntl_mode)
r = ioctlsocket(vio->sd,FIONBIO,(void*) &arg);
}
-#ifndef __EMX__
else
r= test(!(vio->fcntl_mode & O_NONBLOCK)) != set_blocking_mode;
-#endif /* __EMX__ */
-#endif /* !defined(__WIN__) && !defined(__EMX__) */
+#endif /* !defined(__WIN__) */
DBUG_PRINT("exit", ("%d", r));
DBUG_RETURN(r);
}
@@ -195,12 +194,12 @@ int vio_fastsend(Vio * vio __attribute__((unused)))
int r=0;
DBUG_ENTER("vio_fastsend");
-#if defined(IPTOS_THROUGHPUT) && !defined(__EMX__)
+#if defined(IPTOS_THROUGHPUT)
{
int tos = IPTOS_THROUGHPUT;
r= setsockopt(vio->sd, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof(tos));
}
-#endif /* IPTOS_THROUGHPUT && !__EMX__ */
+#endif /* IPTOS_THROUGHPUT */
if (!r)
{
#ifdef __WIN__
@@ -227,7 +226,7 @@ int vio_keepalive(Vio* vio, my_bool set_keep_alive)
int r=0;
uint opt = 0;
DBUG_ENTER("vio_keepalive");
- DBUG_PRINT("enter", ("sd: %d, set_keep_alive: %d", vio->sd, (int)
+ DBUG_PRINT("enter", ("sd: %d set_keep_alive: %d", vio->sd, (int)
set_keep_alive));
if (vio->type != VIO_TYPE_NAMEDPIPE)
{
@@ -411,7 +410,8 @@ int vio_read_pipe(Vio * vio, gptr buf, int size)
{
DWORD length;
DBUG_ENTER("vio_read_pipe");
- DBUG_PRINT("enter", ("sd: %d, buf: 0x%p, size: %d", vio->sd, buf, size));
+ DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %d", vio->sd, (long) buf,
+ size));
if (!ReadFile(vio->hPipe, buf, size, &length, NULL))
DBUG_RETURN(-1);
@@ -425,7 +425,8 @@ int vio_write_pipe(Vio * vio, const gptr buf, int size)
{
DWORD length;
DBUG_ENTER("vio_write_pipe");
- DBUG_PRINT("enter", ("sd: %d, buf: 0x%p, size: %d", vio->sd, buf, size));
+ DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %d", vio->sd, (long) buf,
+ size));
if (!WriteFile(vio->hPipe, (char*) buf, size, &length, NULL))
DBUG_RETURN(-1);
@@ -470,7 +471,8 @@ int vio_read_shared_memory(Vio * vio, gptr buf, int size)
char *current_postion;
DBUG_ENTER("vio_read_shared_memory");
- DBUG_PRINT("enter", ("sd: %d, buf: 0x%p, size: %d", vio->sd, buf, size));
+ DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %d", vio->sd, (long) buf,
+ size));
remain_local = size;
current_postion=buf;
@@ -531,7 +533,8 @@ int vio_write_shared_memory(Vio * vio, const gptr buf, int size)
char *current_postion;
DBUG_ENTER("vio_write_shared_memory");
- DBUG_PRINT("enter", ("sd: %d, buf: 0x%p, size: %d", vio->sd, buf, size));
+ DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %d", vio->sd, (long) buf,
+ size));
remain = size;
current_postion = buf;
@@ -559,9 +562,13 @@ int vio_write_shared_memory(Vio * vio, const gptr buf, int size)
}
+/**
+ Close shared memory and DBUG_PRINT any errors that happen on closing.
+ @return Zero if all closing functions succeed, and nonzero otherwise.
+*/
int vio_close_shared_memory(Vio * vio)
{
- int r;
+ int error_count= 0;
DBUG_ENTER("vio_close_shared_memory");
if (vio->type != VIO_CLOSED)
{
@@ -575,23 +582,44 @@ int vio_close_shared_memory(Vio * vio)
result if they are success.
*/
if (UnmapViewOfFile(vio->handle_map) == 0)
+ {
+ error_count++;
DBUG_PRINT("vio_error", ("UnmapViewOfFile() failed"));
+ }
if (CloseHandle(vio->event_server_wrote) == 0)
+ {
+ error_count++;
DBUG_PRINT("vio_error", ("CloseHandle(vio->esw) failed"));
+ }
if (CloseHandle(vio->event_server_read) == 0)
+ {
+ error_count++;
DBUG_PRINT("vio_error", ("CloseHandle(vio->esr) failed"));
+ }
if (CloseHandle(vio->event_client_wrote) == 0)
+ {
+ error_count++;
DBUG_PRINT("vio_error", ("CloseHandle(vio->ecw) failed"));
+ }
if (CloseHandle(vio->event_client_read) == 0)
+ {
+ error_count++;
DBUG_PRINT("vio_error", ("CloseHandle(vio->ecr) failed"));
+ }
if (CloseHandle(vio->handle_file_map) == 0)
+ {
+ error_count++;
DBUG_PRINT("vio_error", ("CloseHandle(vio->hfm) failed"));
+ }
if (CloseHandle(vio->event_conn_closed) == 0)
+ {
+ error_count++;
DBUG_PRINT("vio_error", ("CloseHandle(vio->ecc) failed"));
+ }
}
vio->type= VIO_CLOSED;
vio->sd= -1;
- DBUG_RETURN(!r);
+ DBUG_RETURN(error_count);
}
#endif /* HAVE_SMEM */
#endif /* __WIN__ */
diff --git a/vio/viosslfactories.c b/vio/viosslfactories.c
index 2c528e9a2fc..ca7a96d5801 100644
--- a/vio/viosslfactories.c
+++ b/vio/viosslfactories.c
@@ -311,7 +311,7 @@ new_VioSSLConnectorFd(const char *key_file, const char *cert_file,
/************************ VioSSLAcceptorFd **********************************/
-struct st_VioSSLFd*
+struct st_VioSSLFd *
new_VioSSLAcceptorFd(const char *key_file, const char *cert_file,
const char *ca_file, const char *ca_path,
const char *cipher)
@@ -344,4 +344,10 @@ new_VioSSLAcceptorFd(const char *key_file, const char *cert_file,
return ssl_fd;
}
+
+void free_vio_ssl_acceptor_fd(struct st_VioSSLFd *fd)
+{
+ SSL_CTX_free(fd->ssl_context);
+ my_free((gptr) fd, MYF(0));
+}
#endif /* HAVE_OPENSSL */