summaryrefslogtreecommitdiff
path: root/vio
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2012-05-18 14:23:05 +0200
committerSergei Golubchik <sergii@pisem.net>2012-05-18 14:23:05 +0200
commit280fcf08085e43b5359ec79c0e34166e51b3ebd8 (patch)
tree0180226f5648752d1d5bc2b7dd23e7cecf3253b1 /vio
parent5a47413934a0ba0aeb91224f1010bb70bd9b1e8a (diff)
parent57f824b0990b0a8708665a4a9ede245ce6064539 (diff)
downloadmariadb-git-280fcf08085e43b5359ec79c0e34166e51b3ebd8.tar.gz
5.1 merge
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 478b5dc03bd..b3b55c09c18 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() */
@@ -265,6 +272,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;
@@ -277,7 +315,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;