From 1b34365ca1f7222a82054ece1901ffb87ffc8b21 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Tue, 27 Oct 2020 21:28:31 +0100 Subject: [PATCH 1/2] std/event: fix poll error set handling This has been broken since 127fa80 --- lib/std/event/loop.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/std/event/loop.zig b/lib/std/event/loop.zig index 80dc94d184..0c4895b895 100644 --- a/lib/std/event/loop.zig +++ b/lib/std/event/loop.zig @@ -467,6 +467,7 @@ pub const Loop = struct { }}; _ = os.poll(&pfd, -1) catch |poll_err| switch (poll_err) { error.SystemResources, + error.NetworkSubsystemFailed, error.Unexpected, => { // Even poll() didn't work. The best we can do now is sleep for a From 504f259c24f202d9160da3f13d7091086162d2d3 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Tue, 27 Oct 2020 21:40:22 +0100 Subject: [PATCH 2/2] std/event: fix zig fmt regression --- lib/std/event/loop.zig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/std/event/loop.zig b/lib/std/event/loop.zig index 0c4895b895..8fd7df0d6f 100644 --- a/lib/std/event/loop.zig +++ b/lib/std/event/loop.zig @@ -773,7 +773,7 @@ pub const Loop = struct { self.delay_queue.waiters.insert(&entry); // Speculatively wake up the timer thread when we add a new entry. - // If the timer thread is sleeping on a longer entry, we need to + // If the timer thread is sleeping on a longer entry, we need to // interrupt it so that our entry can be expired in time. self.delay_queue.event.set(); } @@ -785,7 +785,7 @@ pub const Loop = struct { thread: *std.Thread, event: std.AutoResetEvent, is_running: bool, - + /// Initialize the delay queue by spawning the timer thread /// and starting any timer resources. fn init(self: *DelayQueue) !void { @@ -800,7 +800,7 @@ pub const Loop = struct { }; } - /// Entry point for the timer thread + /// Entry point for the timer thread /// which waits for timer entries to expire and reschedules them. fn run(self: *DelayQueue) void { const loop = @fieldParentPtr(Loop, "delay_queue", self); @@ -848,12 +848,12 @@ pub const Loop = struct { const entry = self.peekExpiringEntry() orelse return null; if (entry.expires > now) return null; - + assert(self.entries.remove(&entry.node)); return entry; } - - /// Returns an estimate for the amount of time + + /// Returns an estimate for the amount of time /// to wait until the next waiting entry expires. fn nextExpire(self: *Waiters) ?u64 { const entry = self.peekExpiringEntry() orelse return null;