authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-08-07 22:23:26-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-08-07 22:23:26-04:00
logac12f0df7160ab19290b975aa3e2eb38ae83cc31
tree858821be09f38e49ab89e8e6373b2e1a569752f4
parent60955feab82ef256a8983517f7435cde797c4e84

fix linux regressions


2 files changed, 25 insertions(+), 14 deletions(-)

std/event/fs.zig+16-7
...@@ -170,7 +170,10 @@ pub async fn preadv(loop: *event.Loop, fd: os.FileHandle, data: []const []u8, of...@@ -170,7 +170,10 @@ pub async fn preadv(loop: *event.Loop, fd: os.FileHandle, data: []const []u8, of
170}170}
171171
172pub async fn open(172pub async fn open(
173 loop: *event.Loop, path: []const u8, flags: u32, mode: os.File.Mode,173 loop: *event.Loop,
174 path: []const u8,
175 flags: u32,
176 mode: os.File.Mode,
174) os.File.OpenError!os.FileHandle {177) os.File.OpenError!os.FileHandle {
175 // workaround for https://github.com/ziglang/zig/issues/1194178 // workaround for https://github.com/ziglang/zig/issues/1194
176 suspend {179 suspend {
...@@ -375,7 +378,7 @@ pub fn Watch(comptime V: type) type {...@@ -375,7 +378,7 @@ pub fn Watch(comptime V: type) type {
375 os_data: OsData,378 os_data: OsData,
376379
377 const OsData = switch (builtin.os) {380 const OsData = switch (builtin.os) {
378 builtin.Os.macosx => struct{381 builtin.Os.macosx => struct {
379 file_table: FileTable,382 file_table: FileTable,
380 table_lock: event.Lock,383 table_lock: event.Lock,
381384
...@@ -477,11 +480,11 @@ pub fn Watch(comptime V: type) type {...@@ -477,11 +480,11 @@ pub fn Watch(comptime V: type) type {
477 var close_op_consumed = false;480 var close_op_consumed = false;
478 defer if (!close_op_consumed) close_op.finish();481 defer if (!close_op_consumed) close_op.finish();
479482
480 const flags = posix.O_SYMLINK|posix.O_EVTONLY;483 const flags = posix.O_SYMLINK | posix.O_EVTONLY;
481 const mode = 0;484 const mode = 0;
482 const fd = try await (async open(self.channel.loop, resolved_path, flags, mode) catch unreachable);485 const fd = try await (async open(self.channel.loop, resolved_path, flags, mode) catch unreachable);
483 close_op.setHandle(fd);486 close_op.setHandle(fd);
484 487
485 var put_data: *OsData.Put = undefined;488 var put_data: *OsData.Put = undefined;
486 const putter = try async self.kqPutEvents(close_op, value, &put_data);489 const putter = try async self.kqPutEvents(close_op, value, &put_data);
487 close_op_consumed = true;490 close_op_consumed = true;
...@@ -549,7 +552,10 @@ pub fn Watch(comptime V: type) type {...@@ -549,7 +552,10 @@ pub fn Watch(comptime V: type) type {
549 error.ProcessNotFound => unreachable,552 error.ProcessNotFound => unreachable,
550 error.AccessDenied, error.SystemResources => {553 error.AccessDenied, error.SystemResources => {
551 // TODO https://github.com/ziglang/zig/issues/769554 // TODO https://github.com/ziglang/zig/issues/769
552 const casted_err = @errSetCast(error{AccessDenied,SystemResources}, err);555 const casted_err = @errSetCast(error{
556 AccessDenied,
557 SystemResources,
558 }, err);
553 await (async self.channel.put(casted_err) catch unreachable);559 await (async self.channel.put(casted_err) catch unreachable);
554 },560 },
555 }561 }
...@@ -667,7 +673,10 @@ pub fn Watch(comptime V: type) type {...@@ -667,7 +673,10 @@ pub fn Watch(comptime V: type) type {
667 }673 }
668 };674 };
669 if (user_value) |v| {675 if (user_value) |v| {
670 await (async channel.put(Self.Event{ .CloseWrite = v }) catch unreachable);676 await (async channel.put(Event{
677 .id = WatchEventId.CloseWrite,
678 .data = v,
679 }) catch unreachable);
671 }680 }
672 }681 }
673 }682 }
...@@ -691,7 +700,7 @@ pub fn Watch(comptime V: type) type {...@@ -691,7 +700,7 @@ pub fn Watch(comptime V: type) type {
691 error.FileDescriptorIncompatibleWithEpoll => unreachable,700 error.FileDescriptorIncompatibleWithEpoll => unreachable,
692 error.Unexpected => unreachable,701 error.Unexpected => unreachable,
693 };702 };
694 await (async channel.put(Self.Event{ .Err = transformed_err }) catch unreachable);703 await (async channel.put(transformed_err) catch unreachable);
695 };704 };
696 },705 },
697 else => unreachable,706 else => unreachable,
std/event/loop.zig+9-7
...@@ -54,10 +54,7 @@ pub const Loop = struct {...@@ -54,10 +54,7 @@ pub const Loop = struct {
54 };54 };
5555
56 pub const Basic = switch (builtin.os) {56 pub const Basic = switch (builtin.os) {
57 builtin.Os.macosx => struct {57 builtin.Os.macosx => MacOsBasic,
58 base: ResumeNode,
59 kev: posix.Kevent,
60 },
61 builtin.Os.linux => struct {58 builtin.Os.linux => struct {
62 base: ResumeNode,59 base: ResumeNode,
63 },60 },
...@@ -66,6 +63,11 @@ pub const Loop = struct {...@@ -66,6 +63,11 @@ pub const Loop = struct {
66 },63 },
67 else => @compileError("unsupported OS"),64 else => @compileError("unsupported OS"),
68 };65 };
66
67 const MacOsBasic = struct {
68 base: ResumeNode,
69 kev: posix.Kevent,
70 };
69 };71 };
7072
71 /// After initialization, call run().73 /// After initialization, call run().
...@@ -261,7 +263,7 @@ pub const Loop = struct {...@@ -261,7 +263,7 @@ pub const Loop = struct {
261 self.os_data.fs_kevent_wake = posix.Kevent{263 self.os_data.fs_kevent_wake = posix.Kevent{
262 .ident = 0,264 .ident = 0,
263 .filter = posix.EVFILT_USER,265 .filter = posix.EVFILT_USER,
264 .flags = posix.EV_ADD|posix.EV_ENABLE,266 .flags = posix.EV_ADD | posix.EV_ENABLE,
265 .fflags = posix.NOTE_TRIGGER,267 .fflags = posix.NOTE_TRIGGER,
266 .data = 0,268 .data = 0,
267 .udata = undefined,269 .udata = undefined,
...@@ -270,7 +272,7 @@ pub const Loop = struct {...@@ -270,7 +272,7 @@ pub const Loop = struct {
270 self.os_data.fs_kevent_wait = posix.Kevent{272 self.os_data.fs_kevent_wait = posix.Kevent{
271 .ident = 0,273 .ident = 0,
272 .filter = posix.EVFILT_USER,274 .filter = posix.EVFILT_USER,
273 .flags = posix.EV_ADD|posix.EV_CLEAR,275 .flags = posix.EV_ADD | posix.EV_CLEAR,
274 .fflags = 0,276 .fflags = 0,
275 .data = 0,277 .data = 0,
276 .udata = undefined,278 .udata = undefined,
...@@ -429,7 +431,7 @@ pub const Loop = struct {...@@ -429,7 +431,7 @@ pub const Loop = struct {
429 var kev = posix.Kevent{431 var kev = posix.Kevent{
430 .ident = ident,432 .ident = ident,
431 .filter = filter,433 .filter = filter,
432 .flags = posix.EV_ADD|posix.EV_ENABLE|posix.EV_CLEAR,434 .flags = posix.EV_ADD | posix.EV_ENABLE | posix.EV_CLEAR,
433 .fflags = fflags,435 .fflags = fflags,
434 .data = 0,436 .data = 0,
435 .udata = @ptrToInt(&resume_node.base),437 .udata = @ptrToInt(&resume_node.base),