summaryrefslogtreecommitdiff
path: root/vio
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2018-08-20 13:06:33 +0100
committerVladislav Vaintroub <wlad@mariadb.com>2018-08-20 14:11:36 +0100
commitee98e95e25bc8abe2be61d3449974d8ba078b351 (patch)
tree6c021088a795b0730ff4741ae30675401382bc4f /vio
parent4299b82ad813a1ad5dfc84f02415eedfcf731bbc (diff)
downloadmariadb-git-ee98e95e25bc8abe2be61d3449974d8ba078b351.tar.gz
MDEV-16536 Remove shared memory transport
Diffstat (limited to 'vio')
-rw-r--r--vio/CMakeLists.txt2
-rw-r--r--vio/vio.c61
-rw-r--r--vio/vio_priv.h8
-rw-r--r--vio/vioshm.c217
-rw-r--r--vio/viosocket.c14
5 files changed, 9 insertions, 293 deletions
diff --git a/vio/CMakeLists.txt b/vio/CMakeLists.txt
index cdb28799ada..95748224f97 100644
--- a/vio/CMakeLists.txt
+++ b/vio/CMakeLists.txt
@@ -17,6 +17,6 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
${SSL_INCLUDE_DIRS})
ADD_DEFINITIONS(${SSL_DEFINES})
-SET(VIO_SOURCES vio.c viosocket.c viossl.c viopipe.c vioshm.c viosslfactories.c)
+SET(VIO_SOURCES vio.c viosocket.c viossl.c viopipe.c viosslfactories.c)
ADD_CONVENIENCE_LIBRARY(vio ${VIO_SOURCES})
TARGET_LINK_LIBRARIES(vio ${LIBSOCKET})
diff --git a/vio/vio.c b/vio/vio.c
index 34ca9ed872d..985a6568e3c 100644
--- a/vio/vio.c
+++ b/vio/vio.c
@@ -54,18 +54,6 @@ static my_bool has_no_data(Vio *vio __attribute__((unused)))
}
#ifdef _WIN32
-my_bool vio_shared_memory_has_data(Vio *vio)
-{
- return (vio->shared_memory_remain > 0);
-}
-
-int vio_shared_memory_shutdown(Vio *vio, int how)
-{
- SetEvent(vio->event_conn_closed);
- SetEvent(vio->event_server_wrote);
- return 0;
-}
-
int vio_pipe_shutdown(Vio *vio, int how)
{
return CancelIoEx(vio->hPipe, NULL);
@@ -116,28 +104,7 @@ static void vio_init(Vio *vio, enum enum_vio_type type,
DBUG_VOID_RETURN;
}
#endif
-#ifdef HAVE_SMEM
- if (type == VIO_TYPE_SHARED_MEMORY)
- {
- vio->viodelete =vio_delete;
- vio->vioerrno =vio_errno;
- vio->read =vio_read_shared_memory;
- vio->write =vio_write_shared_memory;
- vio->fastsend =vio_fastsend;
- vio->viokeepalive =vio_keepalive;
- vio->should_retry =vio_should_retry;
- vio->was_timeout =vio_was_timeout;
- vio->vioclose =vio_close_shared_memory;
- vio->peer_addr =vio_peer_addr;
- vio->vioblocking =vio_blocking;
- vio->is_blocking =vio_is_blocking;
- vio->io_wait =no_io_wait;
- vio->is_connected =vio_is_connected_shared_memory;
- vio->has_data =vio_shared_memory_has_data;
- vio->shutdown =vio_shared_memory_shutdown;
- DBUG_VOID_RETURN;
- }
-#endif
+
#ifdef HAVE_OPENSSL
if (type == VIO_TYPE_SSL)
{
@@ -296,31 +263,7 @@ Vio *vio_new_win32pipe(HANDLE hPipe)
DBUG_RETURN(vio);
}
-#ifdef HAVE_SMEM
-Vio *vio_new_win32shared_memory(HANDLE handle_file_map, HANDLE handle_map,
- HANDLE event_server_wrote, HANDLE event_server_read,
- HANDLE event_client_wrote, HANDLE event_client_read,
- HANDLE event_conn_closed)
-{
- Vio *vio;
- DBUG_ENTER("vio_new_win32shared_memory");
- if ((vio = (Vio*) my_malloc(sizeof(Vio),MYF(MY_WME))))
- {
- vio_init(vio, VIO_TYPE_SHARED_MEMORY, 0, VIO_LOCALHOST);
- vio->desc= "shared memory";
- vio->handle_file_map= handle_file_map;
- vio->handle_map= handle_map;
- vio->event_server_wrote= event_server_wrote;
- vio->event_server_read= event_server_read;
- vio->event_client_wrote= event_client_wrote;
- vio->event_client_read= event_client_read;
- vio->event_conn_closed= event_conn_closed;
- vio->shared_memory_remain= 0;
- vio->shared_memory_pos= handle_map;
- }
- DBUG_RETURN(vio);
-}
-#endif
+
#endif
diff --git a/vio/vio_priv.h b/vio/vio_priv.h
index 248e1a59b23..6f5364417ac 100644
--- a/vio/vio_priv.h
+++ b/vio/vio_priv.h
@@ -35,14 +35,6 @@ int cancel_io(HANDLE handle, DWORD thread_id);
int vio_shutdown_pipe(Vio *vio,int how);
#endif
-#ifdef HAVE_SMEM
-size_t vio_read_shared_memory(Vio *vio, uchar * buf, size_t size);
-size_t vio_write_shared_memory(Vio *vio, const uchar * buf, size_t size);
-my_bool vio_is_connected_shared_memory(Vio *vio);
-int vio_close_shared_memory(Vio * vio);
-my_bool vio_shared_memory_has_data(Vio *vio);
-int vio_shutdown_shared_memory(Vio *vio, int how);
-#endif
int vio_socket_shutdown(Vio *vio, int how);
my_bool vio_buff_has_data(Vio *vio);
diff --git a/vio/vioshm.c b/vio/vioshm.c
deleted file mode 100644
index acc7d2402c5..00000000000
--- a/vio/vioshm.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
-
-#include "vio_priv.h"
-
-#if defined(_WIN32) && defined(HAVE_SMEM)
-
-size_t vio_read_shared_memory(Vio *vio, uchar *buf, size_t size)
-{
- size_t length;
- size_t remain_local;
- char *current_position;
- HANDLE events[2];
- DWORD timeout;
- DBUG_ENTER("vio_read_shared_memory");
-
- remain_local= size;
- current_position= buf;
- timeout= vio->read_timeout >= 0 ? vio->read_timeout : INFINITE;
-
- events[0]= vio->event_server_wrote;
- events[1]= vio->event_conn_closed;
-
- do
- {
- if (vio->shared_memory_remain == 0)
- {
- DWORD wait_status;
-
- wait_status= WaitForMultipleObjects(array_elements(events), events,
- FALSE, timeout);
-
- /*
- WaitForMultipleObjects can return next values:
- WAIT_OBJECT_0+0 - event from vio->event_server_wrote
- WAIT_OBJECT_0+1 - event from vio->event_conn_closed.
- We can't read anything
- WAIT_ABANDONED_0 and WAIT_TIMEOUT - fail. We can't read anything
- */
- if (wait_status != WAIT_OBJECT_0)
- {
- /*
- If wait_status is WAIT_TIMEOUT, set error code to indicate a
- timeout error. If vio->event_conn_closed was set, use an EOF
- condition (return value of zero) to indicate that the operation
- has been aborted.
- */
- if (wait_status == WAIT_TIMEOUT)
- SetLastError(SOCKET_ETIMEDOUT);
- else if (wait_status == (WAIT_OBJECT_0 + 1))
- DBUG_RETURN(0);
-
- DBUG_RETURN(-1);
- }
-
- vio->shared_memory_pos= vio->handle_map;
- vio->shared_memory_remain= uint4korr((ulong*)vio->shared_memory_pos);
- vio->shared_memory_pos+= 4;
- }
-
- length= size;
-
- if (vio->shared_memory_remain < length)
- length= vio->shared_memory_remain;
- if (length > remain_local)
- length= remain_local;
-
- memcpy(current_position, vio->shared_memory_pos, length);
-
- vio->shared_memory_remain-= length;
- vio->shared_memory_pos+= length;
- current_position+= length;
- remain_local-= length;
-
- if (!vio->shared_memory_remain)
- {
- if (!SetEvent(vio->event_client_read))
- DBUG_RETURN(-1);
- }
- } while (remain_local);
- length= size;
-
- DBUG_RETURN(length);
-}
-
-
-size_t vio_write_shared_memory(Vio *vio, const uchar *buf, size_t size)
-{
- size_t length, remain, sz;
- HANDLE pos;
- const uchar *current_position;
- HANDLE events[2];
- DWORD timeout;
- DBUG_ENTER("vio_write_shared_memory");
-
- remain= size;
- current_position= buf;
- timeout= vio->write_timeout >= 0 ? vio->write_timeout : INFINITE;
-
- events[0]= vio->event_server_read;
- events[1]= vio->event_conn_closed;
-
- while (remain != 0)
- {
- DWORD wait_status;
-
- wait_status= WaitForMultipleObjects(array_elements(events), events,
- FALSE, timeout);
-
- if (wait_status != WAIT_OBJECT_0)
- {
- /* Set error code to indicate a timeout error or disconnect. */
- if (wait_status == WAIT_TIMEOUT)
- SetLastError(SOCKET_ETIMEDOUT);
- else
- SetLastError(ERROR_GRACEFUL_DISCONNECT);
-
- DBUG_RETURN((size_t) -1);
- }
-
- sz= (remain > shared_memory_buffer_length ? shared_memory_buffer_length :
- remain);
-
- int4store(vio->handle_map, sz);
- pos= vio->handle_map + 4;
- memcpy(pos, current_position, sz);
- remain-= sz;
- current_position+= sz;
- if (!SetEvent(vio->event_client_wrote))
- DBUG_RETURN((size_t) -1);
- }
- length= size;
-
- DBUG_RETURN(length);
-}
-
-
-my_bool vio_is_connected_shared_memory(Vio *vio)
-{
- return (WaitForSingleObject(vio->event_conn_closed, 0) != WAIT_OBJECT_0);
-}
-
-
-/**
- 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 error_count= 0;
- DBUG_ENTER("vio_close_shared_memory");
- if (vio->type != VIO_CLOSED)
- {
- /*
- Set event_conn_closed for notification of both client and server that
- connection is closed
- */
- SetEvent(vio->event_conn_closed);
- /*
- Close all handlers. UnmapViewOfFile and CloseHandle return non-zero
- 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->mysql_socket= MYSQL_INVALID_SOCKET;
- DBUG_RETURN(error_count);
-}
-
-#endif /* #if defined(_WIN32) && defined(HAVE_SMEM) */
-
diff --git a/vio/viosocket.c b/vio/viosocket.c
index dbc66e288b6..8fc58ef8f43 100644
--- a/vio/viosocket.c
+++ b/vio/viosocket.c
@@ -74,8 +74,7 @@ int vio_errno(Vio *vio __attribute__((unused)))
{
/* These transport types are not Winsock based. */
#ifdef _WIN32
- if (vio->type == VIO_TYPE_NAMEDPIPE ||
- vio->type == VIO_TYPE_SHARED_MEMORY)
+ if (vio->type == VIO_TYPE_NAMEDPIPE)
return GetLastError();
#endif
@@ -363,7 +362,7 @@ int vio_blocking(Vio *vio, my_bool set_blocking_mode, my_bool *old_mode)
r= set_blocking_mode ? 0 : 1;
#endif /* !defined(NO_FCNTL_NONBLOCK) */
#else /* !defined(__WIN__) */
- if (vio->type != VIO_TYPE_NAMEDPIPE && vio->type != VIO_TYPE_SHARED_MEMORY)
+ if (vio->type != VIO_TYPE_NAMEDPIPE)
{
ulong arg;
int old_fcntl=vio->fcntl_mode;
@@ -442,8 +441,7 @@ int vio_nodelay(Vio *vio, my_bool on)
int no_delay= MY_TEST(on);
DBUG_ENTER("vio_nodelay");
- if (vio->type == VIO_TYPE_NAMEDPIPE || vio->type == VIO_TYPE_SHARED_MEMORY
- || vio->type == VIO_TYPE_SOCKET)
+ if (vio->type == VIO_TYPE_NAMEDPIPE || vio->type == VIO_TYPE_SOCKET)
{
DBUG_RETURN(0);
}
@@ -468,7 +466,7 @@ int vio_fastsend(Vio * vio)
int r=0;
DBUG_ENTER("vio_fastsend");
- if (vio->type == VIO_TYPE_NAMEDPIPE ||vio->type == VIO_TYPE_SHARED_MEMORY)
+ if (vio->type == VIO_TYPE_NAMEDPIPE)
{
DBUG_RETURN(0);
}
@@ -502,7 +500,7 @@ int vio_keepalive(Vio* vio, my_bool set_keep_alive)
(int)mysql_socket_getfd(vio->mysql_socket),
(int)set_keep_alive));
- if (vio->type != VIO_TYPE_NAMEDPIPE && vio->type != VIO_TYPE_SHARED_MEMORY)
+ if (vio->type != VIO_TYPE_NAMEDPIPE)
{
if (set_keep_alive)
opt = 1;
@@ -521,7 +519,7 @@ int vio_set_keepalive_options(Vio* vio, const struct vio_keepalive_opts *opts)
struct tcp_keepalive s;
DWORD nbytes;
- if (vio->type == VIO_TYPE_NAMEDPIPE || vio->type == VIO_TYPE_SHARED_MEMORY)
+ if (vio->type == VIO_TYPE_NAMEDPIPE)
return 0;
if (!opts->idle && !opts->interval)