diff options
author | 2023-09-12 20:47:14 -0700 | |
---|---|---|
committer | 2023-09-12 20:47:14 -0700 | |
commit | ec251863d149db3b2bf07d106c5aa7a2074e5301 (patch) | |
tree | 92baf39c3424ef4f737ea4b5ef56098cc2bd579d /src/bun.js/base.zig | |
parent | 85bf54a3ac2b737497e32219f78412ff9a02dbdb (diff) | |
download | bun-ec251863d149db3b2bf07d106c5aa7a2074e5301.tar.gz bun-ec251863d149db3b2bf07d106c5aa7a2074e5301.tar.zst bun-ec251863d149db3b2bf07d106c5aa7a2074e5301.zip |
track registered one shot fds
Diffstat (limited to 'src/bun.js/base.zig')
-rw-r--r-- | src/bun.js/base.zig | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/bun.js/base.zig b/src/bun.js/base.zig index 8f65cf42e..087010dbf 100644 --- a/src/bun.js/base.zig +++ b/src/bun.js/base.zig @@ -2168,10 +2168,19 @@ pub const FilePoll = struct { var event = linux.epoll_event{ .events = flags, .data = .{ .u64 = @intFromPtr(Pollable.init(this).ptr()) } }; + var op = if (this.isRegistered() or this.flags.contains(.needs_rearm)) linux.EPOLL.CTL_MOD else linux.EPOLL.CTL_ADD; + + if (op == linux.EPOLL.CTL_ADD and this.flags.contains(.one_shot)) { + var gpe = JSC.VirtualMachine.get().registered_one_shot_epoll_fds.getOrPut(fd); + if (gpe.found_existing) { + op = linux.EPOLL.CTL_MOD; + } + } + const ctl = linux.epoll_ctl( watcher_fd, - if (this.isRegistered() or this.flags.contains(.needs_rearm)) linux.EPOLL.CTL_MOD else linux.EPOLL.CTL_ADD, - @as(std.os.fd_t, @intCast(fd)), + op, + @intCast(fd), &event, ); this.flags.insert(.was_ever_registered); @@ -2310,24 +2319,23 @@ pub const FilePoll = struct { return JSC.Maybe(void).success; }; - if (comptime !Environment.isLinux) { - if (this.flags.contains(.needs_rearm)) { - log("unregister: {s} ({d}) skipped due to needs_rearm", .{ @tagName(flag), fd }); - this.flags.remove(.poll_process); - this.flags.remove(.poll_readable); - this.flags.remove(.poll_process); - this.flags.remove(.poll_machport); - return JSC.Maybe(void).success; - } + if (this.flags.contains(.needs_rearm)) { + log("unregister: {s} ({d}) skipped due to needs_rearm", .{ @tagName(flag), fd }); + this.flags.remove(.poll_process); + this.flags.remove(.poll_readable); + this.flags.remove(.poll_process); + this.flags.remove(.poll_machport); + return JSC.Maybe(void).success; } log("unregister: {s} ({d})", .{ @tagName(flag), fd }); if (comptime Environment.isLinux) { + _ = JSC.VirtualMachine.get().registered_one_shot_epoll_fds.remove(fd); const ctl = linux.epoll_ctl( watcher_fd, linux.EPOLL.CTL_DEL, - @as(std.os.fd_t, @intCast(fd)), + @intCast(fd), null, ); |