Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/backend/iocp.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 = .{};

Expand Down Expand Up @@ -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;
Expand Down
17 changes: 14 additions & 3 deletions src/watcher/udp.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down