diff options
author | Craig Tiller <ctiller@google.com> | 2015-09-04 07:45:24 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-09-04 07:45:24 -0700 |
commit | a73cae94a69d6bf42f4f0407588c0f711289e049 (patch) | |
tree | 7be3d236170ed3604857068009fb8c63fdefdaca /src/core/iomgr | |
parent | 2b7b235549819d2b766b7b2dc61bccad5db5a410 (diff) | |
parent | 77ccdb99f8b9f06e606082d7a44f35e7e3faf38d (diff) |
Merge pull request #3249 from nicolasnoble/windows-fixes
Fixing lingering bytes clipping issue on socket shutdown.
Diffstat (limited to 'src/core/iomgr')
-rw-r--r-- | src/core/iomgr/socket_windows.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/core/iomgr/socket_windows.c b/src/core/iomgr/socket_windows.c index 2cbe945ca3..557ca82226 100644 --- a/src/core/iomgr/socket_windows.c +++ b/src/core/iomgr/socket_windows.c @@ -35,8 +35,12 @@ #ifdef GPR_WINSOCK_SOCKET +#include <winsock2.h> +#include <mswsock.h> + #include <grpc/support/alloc.h> #include <grpc/support/log.h> +#include <grpc/support/log_win32.h> #include <grpc/support/string_util.h> #include "src/core/iomgr/iocp_windows.h" @@ -63,6 +67,24 @@ grpc_winsocket *grpc_winsocket_create(SOCKET socket, const char *name) { various callsites of that function, which happens to be in various mutex hold states, and that'd be unsafe to call them directly. */ void grpc_winsocket_shutdown(grpc_winsocket *winsocket) { + /* Grab the function pointer for DisconnectEx for that specific socket. + It may change depending on the interface. */ + int status; + GUID guid = WSAID_DISCONNECTEX; + LPFN_DISCONNECTEX DisconnectEx; + DWORD ioctl_num_bytes; + + status = WSAIoctl(winsocket->socket, SIO_GET_EXTENSION_FUNCTION_POINTER, + &guid, sizeof(guid), &DisconnectEx, sizeof(DisconnectEx), + &ioctl_num_bytes, NULL, NULL); + + if (status == 0) { + DisconnectEx(winsocket->socket, NULL, 0, 0); + } else { + char *utf8_message = gpr_format_message(WSAGetLastError()); + gpr_log(GPR_ERROR, "Unable to retrieve DisconnectEx pointer : %s", utf8_message); + gpr_free(utf8_message); + } closesocket(winsocket->socket); } |