diff options
author | Sergei Golubchik <sergii@pisem.net> | 2012-05-17 12:12:33 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2012-05-17 12:12:33 +0200 |
commit | 0a8c9b98f60bb1a21c7e67a1bb47166f0acfeddb (patch) | |
tree | 7e682617fcbdab399d2eafccb6a4800dfdc71e51 /vio | |
parent | 97ae1682f185be05276b172919e47fd86e9fd953 (diff) | |
parent | df905524b218de07dddf5fa394af96edcc4ca483 (diff) | |
download | mariadb-git-0a8c9b98f60bb1a21c7e67a1bb47166f0acfeddb.tar.gz |
merge with mysql-5.1.63
Diffstat (limited to 'vio')
-rw-r--r-- | vio/viosocket.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/vio/viosocket.c b/vio/viosocket.c index f3799351de9..84f828c3d3e 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; |