Skip to content

Commit 2d4a77b

Browse files
committed
Networking (Windows): waits for completion of CancelIO
1 parent 9027f72 commit 2d4a77b

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/common/impl/networking_windows.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf
258258
} else {
259259
FF_DEBUG("WSAWaitForMultipleEvents failed: %s", ffDebugWin32Error((DWORD) WSAGetLastError()));
260260
}
261-
CancelIo((HANDLE) state->sockfd);
261+
if (CancelIoEx((HANDLE) state->sockfd, &state->overlapped))
262+
WSAWaitForMultipleEvents(1, &state->overlapped.hEvent, TRUE, 10, TRUE);
262263
WSACloseEvent(state->overlapped.hEvent);
263264
closesocket(state->sockfd);
264265
ffStrbufDestroy(&state->command);
@@ -286,6 +287,12 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf
286287
// Not a critical error, continue anyway
287288
}
288289

290+
if (shutdown(state->sockfd, SD_SEND) == SOCKET_ERROR)
291+
{
292+
FF_DEBUG("Failed to shutdown socket send: %s", ffDebugWin32Error((DWORD) WSAGetLastError()));
293+
// Not a critical error, continue anyway
294+
}
295+
289296
if(timeout > 0)
290297
{
291298
FF_DEBUG("Setting receive timeout: %u ms", timeout);

0 commit comments

Comments
 (0)