summaryrefslogtreecommitdiff
path: root/vio/viosocket.c
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2012-05-21 15:30:25 +0200
committerSergei Golubchik <sergii@pisem.net>2012-05-21 15:30:25 +0200
commit431e042b5d76ed5fd219c39db798c9e7478731c8 (patch)
treea5556e1a39e43ca6a9549ef949541efcd9725f40 /vio/viosocket.c
parent3f4ef5928e72faf2b7fd0c98c8705ac649d2faf9 (diff)
parent83d455be90a06e8fc1293a611061bd9529ed8536 (diff)
downloadmariadb-git-431e042b5d76ed5fd219c39db798c9e7478731c8.tar.gz
c
Diffstat (limited to 'vio/viosocket.c')
-rw-r--r--vio/viosocket.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/vio/viosocket.c b/vio/viosocket.c
index 406073a5fc5..8e28e7661a9 100644
--- a/vio/viosocket.c
+++ b/vio/viosocket.c
@@ -24,6 +24,11 @@
the file descriptior.
*/
+#ifdef __WIN__
+ #include <winsock2.h>
+ #include <MSWSock.h>
+ #pragma comment(lib, "ws2_32.lib")
+#endif
#include "vio_priv.h"
#include "my_context.h"
#include <mysql_async.h>
@@ -369,6 +374,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;
@@ -381,7 +417,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;