diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-08-10 13:19:07 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-08-10 13:19:07 -0400 |
| commit | 598e80957e6eccc13ade72ce2693dcd60934763d (patch) | |
| tree | 7a98fc680877bbdf00c9431fd3f2cd922a1ce8b0 /std/os | |
| parent | 0df485d4dc764afc582b8ab684106b71d765d74f (diff) | |
| download | zig-598e80957e6eccc13ade72ce2693dcd60934763d.tar.gz zig-598e80957e6eccc13ade72ce2693dcd60934763d.zip | |
windows: call CancelIo when canceling an fs watch
Diffstat (limited to 'std/os')
| -rw-r--r-- | std/os/windows/util.zig | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/std/os/windows/util.zig b/std/os/windows/util.zig index 9e13655f7f..2f9f4f2c72 100644 --- a/std/os/windows/util.zig +++ b/std/os/windows/util.zig @@ -238,21 +238,24 @@ pub fn windowsPostQueuedCompletionStatus(completion_port: windows.HANDLE, bytes_ } } -pub const WindowsWaitResult = error{ +pub const WindowsWaitResult = enum{ Normal, Aborted, + Cancelled, }; pub fn windowsGetQueuedCompletionStatus(completion_port: windows.HANDLE, bytes_transferred_count: *windows.DWORD, lpCompletionKey: *usize, lpOverlapped: *?*windows.OVERLAPPED, dwMilliseconds: windows.DWORD) WindowsWaitResult { if (windows.GetQueuedCompletionStatus(completion_port, bytes_transferred_count, lpCompletionKey, lpOverlapped, dwMilliseconds) == windows.FALSE) { - if (std.debug.runtime_safety) { - const err = windows.GetLastError(); - if (err != windows.ERROR.ABANDONED_WAIT_0) { - std.debug.warn("err: {}\n", err); + const err = windows.GetLastError(); + switch (err) { + windows.ERROR.ABANDONED_WAIT_0 => return WindowsWaitResult.Aborted, + windows.ERROR.OPERATION_ABORTED => return WindowsWaitResult.Cancelled, + else => { + if (std.debug.runtime_safety) { + std.debug.panic("unexpected error: {}\n", err); + } } - assert(err == windows.ERROR.ABANDONED_WAIT_0); } - return WindowsWaitResult.Aborted; } return WindowsWaitResult.Normal; } |
