summaryrefslogtreecommitdiff
path: root/vio/viosocket.c
diff options
context:
space:
mode:
Diffstat (limited to 'vio/viosocket.c')
-rw-r--r--vio/viosocket.c49
1 files changed, 1 insertions, 48 deletions
diff --git a/vio/viosocket.c b/vio/viosocket.c
index e724165612c..a33de48c020 100644
--- a/vio/viosocket.c
+++ b/vio/viosocket.c
@@ -299,59 +299,12 @@ size_t vio_write(Vio *vio, const uchar* buf, size_t size)
DBUG_RETURN(ret);
}
-#ifdef _WIN32
-static void CALLBACK cancel_io_apc(ULONG_PTR data)
-{
- CancelIo((HANDLE)data);
-}
-
-/*
- Cancel IO on Windows.
-
- On XP, issue CancelIo as asynchronous procedure call to the thread
- that started IO. On Vista+, simpler cancelation is done with
- CancelIoEx.
-*/
-
-int cancel_io(HANDLE handle, DWORD thread_id)
-{
- static BOOL (WINAPI *fp_CancelIoEx) (HANDLE, OVERLAPPED *);
- static volatile int first_time= 1;
- int rc;
- HANDLE thread_handle;
-
- if (first_time)
- {
- /* Try to load CancelIoEx using GetProcAddress */
- InterlockedCompareExchangePointer((volatile void *)&fp_CancelIoEx,
- GetProcAddress(GetModuleHandle("kernel32"), "CancelIoEx"), NULL);
- first_time =0;
- }
-
- if (fp_CancelIoEx)
- {
- return fp_CancelIoEx(handle, NULL)? 0 :-1;
- }
-
- thread_handle= OpenThread(THREAD_SET_CONTEXT, FALSE, thread_id);
- if (thread_handle)
- {
- rc= QueueUserAPC(cancel_io_apc, thread_handle, (ULONG_PTR)handle);
- CloseHandle(thread_handle);
- }
- return rc;
-
-}
-#endif
-
-
int vio_socket_shutdown(Vio *vio, int how)
{
int ret= shutdown(mysql_socket_getfd(vio->mysql_socket), how);
#ifdef _WIN32
/* Cancel possible IO in progress (shutdown does not do that on Windows). */
- (void) cancel_io((HANDLE) mysql_socket_getfd(vio->mysql_socket),
- vio->thread_id);
+ (void) CancelIoEx((HANDLE)mysql_socket_getfd(vio->mysql_socket), NULL);
#endif
return ret;
}