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
170170}
171171
172172pub 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,
174177) os.File.OpenError!os.FileHandle {
175178 // workaround for https://github.com/ziglang/zig/issues/1194
176179 suspend {
......@@ -375,7 +378,7 @@ pub fn Watch(comptime V: type) type {
375378 os_data: OsData,
376379
377380 const OsData = switch (builtin.os) {
378 builtin.Os.macosx => struct{
381 builtin.Os.macosx => struct {
379382 file_table: FileTable,
380383 table_lock: event.Lock,
381384
......@@ -477,11 +480,11 @@ pub fn Watch(comptime V: type) type {
477480 var close_op_consumed = false;
478481 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;
481484 const mode = 0;
482485 const fd = try await (async open(self.channel.loop, resolved_path, flags, mode) catch unreachable);
483486 close_op.setHandle(fd);
484
487
485488 var put_data: *OsData.Put = undefined;
486489 const putter = try async self.kqPutEvents(close_op, value, &put_data);
487490 close_op_consumed = true;
......@@ -549,7 +552,10 @@ pub fn Watch(comptime V: type) type {
549552 error.ProcessNotFound => unreachable,
550553 error.AccessDenied, error.SystemResources => {
551554 // 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);
553559 await (async self.channel.put(casted_err) catch unreachable);
554560 },
555561 }
......@@ -667,7 +673,10 @@ pub fn Watch(comptime V: type) type {
667673 }
668674 };
669675 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);
671680 }
672681 }
673682 }
......@@ -691,7 +700,7 @@ pub fn Watch(comptime V: type) type {
691700 error.FileDescriptorIncompatibleWithEpoll => unreachable,
692701 error.Unexpected => unreachable,
693702 };
694 await (async channel.put(Self.Event{ .Err = transformed_err }) catch unreachable);
703 await (async channel.put(transformed_err) catch unreachable);
695704 };
696705 },
697706 else => unreachable,
std/event/loop.zig+9-7
......@@ -54,10 +54,7 @@ pub const Loop = struct {
5454 };
5555
5656 pub const Basic = switch (builtin.os) {
57 builtin.Os.macosx => struct {
58 base: ResumeNode,
59 kev: posix.Kevent,
60 },
57 builtin.Os.macosx => MacOsBasic,
6158 builtin.Os.linux => struct {
6259 base: ResumeNode,
6360 },
......@@ -66,6 +63,11 @@ pub const Loop = struct {
6663 },
6764 else => @compileError("unsupported OS"),
6865 };
66
67 const MacOsBasic = struct {
68 base: ResumeNode,
69 kev: posix.Kevent,
70 };
6971 };
7072
7173 /// After initialization, call run().
......@@ -261,7 +263,7 @@ pub const Loop = struct {
261263 self.os_data.fs_kevent_wake = posix.Kevent{
262264 .ident = 0,
263265 .filter = posix.EVFILT_USER,
264 .flags = posix.EV_ADD|posix.EV_ENABLE,
266 .flags = posix.EV_ADD | posix.EV_ENABLE,
265267 .fflags = posix.NOTE_TRIGGER,
266268 .data = 0,
267269 .udata = undefined,
......@@ -270,7 +272,7 @@ pub const Loop = struct {
270272 self.os_data.fs_kevent_wait = posix.Kevent{
271273 .ident = 0,
272274 .filter = posix.EVFILT_USER,
273 .flags = posix.EV_ADD|posix.EV_CLEAR,
275 .flags = posix.EV_ADD | posix.EV_CLEAR,
274276 .fflags = 0,
275277 .data = 0,
276278 .udata = undefined,
......@@ -429,7 +431,7 @@ pub const Loop = struct {
429431 var kev = posix.Kevent{
430432 .ident = ident,
431433 .filter = filter,
432 .flags = posix.EV_ADD|posix.EV_ENABLE|posix.EV_CLEAR,
434 .flags = posix.EV_ADD | posix.EV_ENABLE | posix.EV_CLEAR,
433435 .fflags = fflags,
434436 .data = 0,
435437 .udata = @ptrToInt(&resume_node.base),