| author | |
| committer | |
| log | 598e80957e6eccc13ade72ce2693dcd60934763d |
| tree | 7a98fc680877bbdf00c9431fd3f2cd922a1ce8b0 |
| parent | 0df485d4dc764afc582b8ab684106b71d765d74f |
5 files changed, 18 insertions(+), 10 deletions(-)
src-self-hosted/compilation.zig+3-2| ... | @@ -545,14 +545,15 @@ pub const Compilation = struct { | ... | @@ -545,14 +545,15 @@ pub const Compilation = struct { |
| 545 | try comp.initTypes(); | 545 | try comp.initTypes(); |
| 546 | defer comp.primitive_type_table.deinit(); | 546 | defer comp.primitive_type_table.deinit(); |
| 547 | 547 | ||
| 548 | comp.main_loop_handle = async comp.mainLoop() catch unreachable; | ||
| 548 | // Set this to indicate that initialization completed successfully. | 549 | // Set this to indicate that initialization completed successfully. |
| 549 | // from here on out we must not return an error. | 550 | // from here on out we must not return an error. |
| 550 | // This must occur before the first suspend/await. | 551 | // This must occur before the first suspend/await. |
| 551 | comp.main_loop_handle = async comp.mainLoop() catch unreachable; | ||
| 552 | out_comp.* = ∁ | 552 | out_comp.* = ∁ |
| 553 | // This suspend is resumed by destroy() | ||
| 553 | suspend; | 554 | suspend; |
| 554 | |||
| 555 | // From here on is cleanup. | 555 | // From here on is cleanup. |
| 556 | |||
| 556 | await (async comp.deinit_group.wait() catch unreachable); | 557 | await (async comp.deinit_group.wait() catch unreachable); |
| 557 | 558 | ||
| 558 | if (comp.tmp_dir.getOrNull()) |tmp_dir_result| if (tmp_dir_result.*) |tmp_dir| { | 559 | if (comp.tmp_dir.getOrNull()) |tmp_dir_result| if (tmp_dir_result.*) |tmp_dir| { |
src-self-hosted/test.zig+1-1| ... | @@ -43,7 +43,7 @@ pub const TestContext = struct { | ... | @@ -43,7 +43,7 @@ pub const TestContext = struct { |
| 43 | .file_index = std.atomic.Int(usize).init(0), | 43 | .file_index = std.atomic.Int(usize).init(0), |
| 44 | }; | 44 | }; |
| 45 | 45 | ||
| 46 | try self.loop.initMultiThreaded(allocator); | 46 | try self.loop.initSingleThreaded(allocator); |
| 47 | errdefer self.loop.deinit(); | 47 | errdefer self.loop.deinit(); |
| 48 | 48 | ||
| 49 | self.zig_compiler = try ZigCompiler.init(&self.loop); | 49 | self.zig_compiler = try ZigCompiler.init(&self.loop); |
std/event/fs.zig+3| ... | @@ -1117,6 +1117,9 @@ pub fn Watch(comptime V: type) type { | ... | @@ -1117,6 +1117,9 @@ pub fn Watch(comptime V: type) type { |
| 1117 | // TODO only 1 beginOneEvent for the whole coroutine | 1117 | // TODO only 1 beginOneEvent for the whole coroutine |
| 1118 | self.channel.loop.beginOneEvent(); | 1118 | self.channel.loop.beginOneEvent(); |
| 1119 | errdefer self.channel.loop.finishOneEvent(); | 1119 | errdefer self.channel.loop.finishOneEvent(); |
| 1120 | errdefer { | ||
| 1121 | _ = windows.CancelIoEx(dir_handle, &overlapped); | ||
| 1122 | } | ||
| 1120 | suspend { | 1123 | suspend { |
| 1121 | _ = windows.ReadDirectoryChangesW( | 1124 | _ = windows.ReadDirectoryChangesW( |
| 1122 | dir_handle, | 1125 | dir_handle, |
std/event/loop.zig+1| ... | @@ -686,6 +686,7 @@ pub const Loop = struct { | ... | @@ -686,6 +686,7 @@ pub const Loop = struct { |
| 686 | switch (os.windowsGetQueuedCompletionStatus(self.os_data.io_port, &nbytes, &completion_key, &overlapped, windows.INFINITE)) { | 686 | switch (os.windowsGetQueuedCompletionStatus(self.os_data.io_port, &nbytes, &completion_key, &overlapped, windows.INFINITE)) { |
| 687 | os.WindowsWaitResult.Aborted => return, | 687 | os.WindowsWaitResult.Aborted => return, |
| 688 | os.WindowsWaitResult.Normal => {}, | 688 | os.WindowsWaitResult.Normal => {}, |
| 689 | os.WindowsWaitResult.Cancelled => continue, | ||
| 689 | } | 690 | } |
| 690 | if (overlapped != null) break; | 691 | if (overlapped != null) break; |
| 691 | } | 692 | } |
std/os/windows/util.zig+10-7| ... | @@ -238,21 +238,24 @@ pub fn windowsPostQueuedCompletionStatus(completion_port: windows.HANDLE, bytes_ | ... | @@ -238,21 +238,24 @@ pub fn windowsPostQueuedCompletionStatus(completion_port: windows.HANDLE, bytes_ |
| 238 | } | 238 | } |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | pub const WindowsWaitResult = error{ | 241 | pub const WindowsWaitResult = enum{ |
| 242 | Normal, | 242 | Normal, |
| 243 | Aborted, | 243 | Aborted, |
| 244 | Cancelled, | ||
| 244 | }; | 245 | }; |
| 245 | 246 | ||
| 246 | pub fn windowsGetQueuedCompletionStatus(completion_port: windows.HANDLE, bytes_transferred_count: *windows.DWORD, lpCompletionKey: *usize, lpOverlapped: *?*windows.OVERLAPPED, dwMilliseconds: windows.DWORD) WindowsWaitResult { | 247 | pub fn windowsGetQueuedCompletionStatus(completion_port: windows.HANDLE, bytes_transferred_count: *windows.DWORD, lpCompletionKey: *usize, lpOverlapped: *?*windows.OVERLAPPED, dwMilliseconds: windows.DWORD) WindowsWaitResult { |
| 247 | if (windows.GetQueuedCompletionStatus(completion_port, bytes_transferred_count, lpCompletionKey, lpOverlapped, dwMilliseconds) == windows.FALSE) { | 248 | if (windows.GetQueuedCompletionStatus(completion_port, bytes_transferred_count, lpCompletionKey, lpOverlapped, dwMilliseconds) == windows.FALSE) { |
| 248 | if (std.debug.runtime_safety) { | 249 | const err = windows.GetLastError(); |
| 249 | const err = windows.GetLastError(); | 250 | switch (err) { |
| 250 | if (err != windows.ERROR.ABANDONED_WAIT_0) { | 251 | windows.ERROR.ABANDONED_WAIT_0 => return WindowsWaitResult.Aborted, |
| 251 | std.debug.warn("err: {}\n", err); | 252 | windows.ERROR.OPERATION_ABORTED => return WindowsWaitResult.Cancelled, |
| 253 | else => { | ||
| 254 | if (std.debug.runtime_safety) { | ||
| 255 | std.debug.panic("unexpected error: {}\n", err); | ||
| 256 | } | ||
| 252 | } | 257 | } |
| 253 | assert(err == windows.ERROR.ABANDONED_WAIT_0); | ||
| 254 | } | 258 | } |
| 255 | return WindowsWaitResult.Aborted; | ||
| 256 | } | 259 | } |
| 257 | return WindowsWaitResult.Normal; | 260 | return WindowsWaitResult.Normal; |
| 258 | } | 261 | } |