summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@torproject.org>2018-12-20 13:11:24 +0100
committerAlexander Færøy <ahf@torproject.org>2018-12-20 13:11:24 +0100
commit412fbe9f177f742e0e56df612f44261f6771973a (patch)
tree0827269dc66b765e56f658e0bea44358c98b3dd2 /src
parentf58e597d42c204e25101143f9618d55aef666edc (diff)
downloadtor-412fbe9f177f742e0e56df612f44261f6771973a.tar.gz
tor-412fbe9f177f742e0e56df612f44261f6771973a.zip
Make example CancelIoEx() code use CancelIo().
This patch changes the CancelIoEx() example code to use CancelIo(), which is available for older versions of Windows too. I still think the kernel handles this nicely by sending broken pipes if either side closes the pipe while I/O operations are pending. See: https://bugs.torproject.org/28179
Diffstat (limited to 'src')
-rw-r--r--src/lib/process/process_win32.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/src/lib/process/process_win32.c b/src/lib/process/process_win32.c
index 3b4373f425..641af2bb0f 100644
--- a/src/lib/process/process_win32.c
+++ b/src/lib/process/process_win32.c
@@ -720,31 +720,24 @@ process_win32_cleanup_handle(process_win32_handle_t *handle)
tor_assert(handle);
#if 0
- /* FIXME(ahf): My compiler does not set _WIN32_WINNT to a high enough value
- * for this code to be available. Should we force it? CancelIoEx() is
- * available from Windows 7 and above. If we decide to require this, we need
- * to update the checks in all the three I/O completion callbacks to handle
- * the ERROR_OPERATION_ABORTED as well as ERROR_BROKEN_PIPE. */
-
-#if _WIN32_WINNT >= 0x0600
- /* This code is only supported from Windows 7 and onwards. */
BOOL ret;
DWORD error_code;
- /* Cancel any pending I/O requests. */
- ret = CancelIoEx(handle->pipe, &handle->overlapped);
+ /* Cancel any pending I/O requests: This means that instead of getting
+ * ERROR_BROKEN_PIPE we get ERROR_OPERATION_ABORTED, but it doesn't seem
+ * like this is needed. */
+ ret = CancelIo(handle->pipe);
if (! ret) {
error_code = GetLastError();
/* There was no pending I/O requests for our handle. */
if (error_code != ERROR_NOT_FOUND) {
- log_warn(LD_PROCESS, "CancelIoEx() failed: %s",
+ log_warn(LD_PROCESS, "CancelIo() failed: %s",
format_win32_error(error_code));
}
}
#endif
-#endif
/* Close our handle. */
if (handle->pipe != INVALID_HANDLE_VALUE) {