aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/Io/Kqueue.zig20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/std/Io/Kqueue.zig b/lib/std/Io/Kqueue.zig
index fa5f6033ef..3507c29462 100644
--- a/lib/std/Io/Kqueue.zig
+++ b/lib/std/Io/Kqueue.zig
@@ -1456,7 +1456,25 @@ fn netRead(userdata: ?*anyopaque, fd: net.Socket.Handle, data: [][]u8) net.Strea
.SUCCESS => return @intCast(rc),
.INTR => continue,
.CANCELED => return error.Canceled,
- .AGAIN => @panic("TODO"),
+ .AGAIN => {
+ const thread: *Thread = .current();
+ const fiber = thread.currentFiber();
+ const changes = [_]posix.Kevent{
+ .{
+ .ident = @as(u32, @bitCast(fd)),
+ .filter = std.c.EVFILT.READ,
+ .flags = std.c.EV.ADD | std.c.EV.ONESHOT,
+ .fflags = 0,
+ .data = 0,
+ .udata = @intFromPtr(fiber),
+ },
+ };
+ assert(0 == (posix.kevent(thread.kq_fd, &changes, &.{}, null) catch |err| {
+ @panic(@errorName(err)); // TODO
+ }));
+ yield(k, null, .nothing);
+ continue;
+ },
.INVAL => |err| return errnoBug(err),
.FAULT => |err| return errnoBug(err),