diff options
author | 2022-08-22 10:59:49 -0700 | |
---|---|---|
committer | 2022-08-22 10:59:49 -0700 | |
commit | 75a76fb8361fef540fd9025eff2251fc0fa8f4b8 (patch) | |
tree | a65d5ed1c6cb3ca4f23b77428e9a7e40484d3b41 /src/bun.js/api/server.zig | |
parent | 2a0ab2aa9b07b99ce82564a01eeca3b666e91cf2 (diff) | |
download | bun-75a76fb8361fef540fd9025eff2251fc0fa8f4b8.tar.gz bun-75a76fb8361fef540fd9025eff2251fc0fa8f4b8.tar.zst bun-75a76fb8361fef540fd9025eff2251fc0fa8f4b8.zip |
Remove response pool
Diffstat (limited to 'src/bun.js/api/server.zig')
-rw-r--r-- | src/bun.js/api/server.zig | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index 1af7a5e31..39e9a8046 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -527,6 +527,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp has_marked_complete: bool = false, response_jsvalue: JSC.JSValue = JSC.JSValue.zero, + response_protected: bool = false, response_ptr: ?*JSC.WebCore.Response = null, blob: JSC.WebCore.Blob = JSC.WebCore.Blob{}, promise: ?*JSC.JSValue = null, @@ -813,7 +814,10 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp } if (!this.response_jsvalue.isEmpty()) { - this.server.response_objects_pool.push(this.server.globalThis, this.response_jsvalue); + if (this.response_protected) { + this.response_jsvalue.unprotect(); + this.response_protected = false; + } this.response_jsvalue = JSC.JSValue.zero; } @@ -1824,7 +1828,6 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { vm: *JSC.VirtualMachine = undefined, globalThis: *JSGlobalObject, base_url_string_for_joining: string = "", - response_objects_pool: JSC.WebCore.Response.Pool = JSC.WebCore.Response.Pool{}, config: ServerConfig = ServerConfig{}, pending_requests: usize = 0, request_pool_allocator: std.mem.Allocator = undefined, @@ -1913,12 +1916,6 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { } pub fn deinit(this: *ThisServer) void { - if (this.vm.response_objects_pool) |pool| { - if (pool == &this.response_objects_pool) { - this.vm.response_objects_pool = null; - } - } - this.app.destroy(); const allocator = this.allocator; allocator.destroy(this); @@ -2025,7 +2022,6 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { this.listener = socket; const needs_post_handler = this.vm.uws_event_loop == null; this.vm.uws_event_loop = uws.Loop.get(); - this.vm.response_objects_pool = &this.response_objects_pool; this.listen_callback = JSC.AnyTask.New(ThisServer, run).init(this); this.vm.eventLoop().enqueueTask(JSC.Task.init(&this.listen_callback)); if (needs_post_handler) { @@ -2150,14 +2146,17 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { if (response_value.as(JSC.WebCore.Response)) |response| { ctx.response_jsvalue = response_value; ctx.response_jsvalue.ensureStillAlive(); + ctx.response_protected = false; switch (response.body.value) { .Blob => |*blob| { if (blob.needsToReadFile()) { response_value.protect(); + ctx.response_protected = true; } }, .Locked => { response_value.protect(); + ctx.response_protected = true; }, else => {}, } |