summaryrefslogtreecommitdiff
path: root/vio
diff options
context:
space:
mode:
Diffstat (limited to 'vio')
-rw-r--r--vio/viosocket.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/vio/viosocket.c b/vio/viosocket.c
index 024aacc5db2..9633a01f689 100644
--- a/vio/viosocket.c
+++ b/vio/viosocket.c
@@ -23,8 +23,15 @@
the file descriptior.
*/
+#ifdef __WIN__
+ #include <winsock2.h>
+ #include <MSWSock.h>
+ #pragma comment(lib, "ws2_32.lib")
+#endif
#include "vio_priv.h"
+
+
int vio_errno(Vio *vio __attribute__((unused)))
{
return socket_errno; /* On Win32 this mapped to WSAGetLastError() */
@@ -260,6 +267,37 @@ vio_was_interrupted(Vio *vio __attribute__((unused)))
}
+int
+mysql_socket_shutdown(my_socket mysql_socket, int how)
+{
+ int result;
+
+#ifdef __WIN__
+ static LPFN_DISCONNECTEX DisconnectEx = NULL;
+ if (DisconnectEx == NULL)
+ {
+ DWORD dwBytesReturned;
+ GUID guidDisconnectEx = WSAID_DISCONNECTEX;
+ WSAIoctl(mysql_socket, SIO_GET_EXTENSION_FUNCTION_POINTER,
+ &guidDisconnectEx, sizeof(GUID),
+ &DisconnectEx, sizeof(DisconnectEx),
+ &dwBytesReturned, NULL, NULL);
+ }
+#endif
+
+ /* Non instrumented code */
+#ifdef __WIN__
+ if (DisconnectEx)
+ result= (DisconnectEx(mysql_socket, (LPOVERLAPPED) NULL,
+ (DWORD) 0, (DWORD) 0) == TRUE) ? 0 : -1;
+ else
+#endif
+ result= shutdown(mysql_socket, how);
+
+ return result;
+}
+
+
int vio_close(Vio * vio)
{
int r=0;
@@ -272,7 +310,7 @@ int vio_close(Vio * vio)
vio->type == VIO_TYPE_SSL);
DBUG_ASSERT(vio->sd >= 0);
- if (shutdown(vio->sd, SHUT_RDWR))
+ if (mysql_socket_shutdown(vio->sd, SHUT_RDWR))
r= -1;
if (closesocket(vio->sd))
r= -1;