diff --git a/src/backend/iocp.zig b/src/backend/iocp.zig index 671d08c..c2d3bbb 100644 --- a/src/backend/iocp.zig +++ b/src/backend/iocp.zig @@ -259,6 +259,7 @@ pub const Loop = struct { // Process the completions we already have completed. while (self.completions.pop()) |c| { + std.debug.print("whu\n", .{}); // We store whether this completion was active so we can decrement the active count // later. const c_active = c.flags.state == .active; @@ -282,6 +283,7 @@ pub const Loop = struct { // Process asyncs if (!self.asyncs.empty()) { + std.debug.print("whu\n", .{}); var asyncs = self.asyncs; self.asyncs = .{}; @@ -310,10 +312,15 @@ pub const Loop = struct { } // If we have processed enough event, we break out of the loop. - if (wait_rem == 0) break; + // + // We continue with timeout 0 if this ins nonblocking otherwise + // nothing gets done if user only does .no_wait. + if (wait_rem == 0 and wait != 0) break; // Determine our next timeout based on the timers. const timeout: ?windows.DWORD = timeout: { + if (wait == 0) break :timeout 0; + // If we have a timer, we want to set the timeout to our next timer value. If we // have no timer, we wait forever. const t = self.timers.peek() orelse break :timeout null; diff --git a/src/watcher/udp.zig b/src/watcher/udp.zig index 7df3ab1..fa1d25c 100644 --- a/src/watcher/udp.zig +++ b/src/watcher/udp.zig @@ -130,7 +130,10 @@ fn UDPSendto(comptime xev: type) type { l_inner, c_inner, s_inner, - std.net.Address.initPosix(@alignCast(&c_inner.op.recvfrom.addr)), + // cancelation can cause this to be uninitialized + if (r.recvfrom) |_| std.net.Address.initPosix( + @alignCast(&c_inner.op.recvfrom.addr), + ) else |_| undefined, initFd(c_inner.op.recvfrom.fd), c_inner.op.recvfrom.buffer, r.recvfrom, @@ -308,7 +311,10 @@ fn UDPSendtoIOCP(comptime xev: type) type { l_inner, c_inner, s_inner, - std.net.Address.initPosix(@alignCast(&c_inner.op.recvfrom.addr)), + // cancelation can cause this to be uninitialized + if (r.recvfrom) |_| std.net.Address.initPosix( + @alignCast(&c_inner.op.recvfrom.addr), + ) else |_| undefined, initFd(c_inner.op.recvfrom.fd), c_inner.op.recvfrom.buffer, r.recvfrom, @@ -540,7 +546,12 @@ fn UDPSendMsg(comptime xev: type) type { l_inner, c_inner, s_inner, - std.net.Address.initPosix(@ptrCast(&s_inner.op.recv.addr_buffer)), + // cancelation can cause this to be uninitialized + if (r.recvmsg) |_| if (s_inner.op.recv.addr_buffer.family == 0xaaaa) b: { + break :b undefined; + } else std.net.Address.initPosix( + @ptrCast(&s_inner.op.recv.addr_buffer), + ) else |_| undefined, initFd(c_inner.op.recvmsg.fd), s_inner.op.recv.buf, if (r.recvmsg) |v| v else |err| err,