diff options
author | 2022-01-24 19:12:58 -0800 | |
---|---|---|
committer | 2022-01-24 19:12:58 -0800 | |
commit | ecea12d2061f3508b9e5686d605ab7e6e6ac932e (patch) | |
tree | 27484c7d7ebc060ebee1365d0eac84836d0cb616 /src/network_thread.zig | |
parent | 61d1c7b6b2efadad4e6bb27ad72b2fb45d0f5e9a (diff) | |
download | bun-ecea12d2061f3508b9e5686d605ab7e6e6ac932e.tar.gz bun-ecea12d2061f3508b9e5686d605ab7e6e6ac932e.tar.zst bun-ecea12d2061f3508b9e5686d605ab7e6e6ac932e.zip |
No io_uring for Ubuntu 20.04
Diffstat (limited to 'src/network_thread.zig')
-rw-r--r-- | src/network_thread.zig | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/src/network_thread.zig b/src/network_thread.zig index 94eb13414..be5b84acb 100644 --- a/src/network_thread.zig +++ b/src/network_thread.zig @@ -37,14 +37,16 @@ const CachedAddressList = struct { } pub fn invalidate(this: *CachedAddressList) void { - this.invalidated = true; - this.address_list.deinit(); + if (!this.invalidated) { + this.invalidated = true; + this.address_list.deinit(); + } _ = address_list_cached.remove(this.key); } }; -const AddressListCache = std.HashMap(u64, CachedAddressList, IdentityContext(u64), 80); -var address_list_cached: AddressListCache = undefined; +pub const AddressListCache = std.HashMap(u64, CachedAddressList, IdentityContext(u64), 80); +pub var address_list_cached: AddressListCache = undefined; pub fn getAddressList(allocator: std.mem.Allocator, name: []const u8, port: u16) !*CachedAddressList { const hash = CachedAddressList.hash(name, port); const now = @intCast(u64, @maximum(0, std.time.milliTimestamp())); @@ -64,24 +66,9 @@ pub fn getAddressList(allocator: std.mem.Allocator, name: []const u8, port: u16) pub fn init() !void { if ((global_loaded.swap(1, .Monotonic)) == 1) return; - AsyncIO.global = AsyncIO.init(1024, 0) catch |err| { - Output.prettyErrorln("<r><red>error<r>: Failed to initialize network thread: <red><b>{s}<r>.\nHTTP requests will not work. Please file an issue and run strace().", .{@errorName(err)}); - Output.flush(); - - global = NetworkThread{ - .pool = ThreadPool.init(.{ .max_threads = 0, .stack_size = 64 * 1024 * 1024 }), - }; - global.pool.max_threads = 0; - AsyncIO.global_loaded = true; - return; - }; - - AsyncIO.global_loaded = true; global = NetworkThread{ .pool = ThreadPool.init(.{ .max_threads = 1, .stack_size = 64 * 1024 * 1024 }), }; global.pool.on_thread_spawn = HTTP.onThreadStart; - global.pool.io = &AsyncIO.global; - address_list_cached = AddressListCache.init(@import("./global.zig").default_allocator); } |