aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Dylan Conway <dylan.conway567@gmail.com> 2022-12-06 17:09:21 -0800
committerGravatar Dylan Conway <dylan.conway567@gmail.com> 2022-12-06 17:10:14 -0800
commit5f3a6f2bf3b91c6c4fa0ad7f4197863ef6980889 (patch)
treed34b52c4620abafe6b669ce1e8c65cc147ea8741 /src
parent58185e139a9c8502e5a6afcd5ab5f9682552a731 (diff)
downloadbun-5f3a6f2bf3b91c6c4fa0ad7f4197863ef6980889.tar.gz
bun-5f3a6f2bf3b91c6c4fa0ad7f4197863ef6980889.tar.zst
bun-5f3a6f2bf3b91c6c4fa0ad7f4197863ef6980889.zip
add server scheduleDeinit, ignore logs in test
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/api/server.zig14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig
index f9ca6e881..a8216c689 100644
--- a/src/bun.js/api/server.zig
+++ b/src/bun.js/api/server.zig
@@ -3804,7 +3804,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
listen_callback: JSC.AnyTask = undefined,
allocator: std.mem.Allocator,
poll_ref: JSC.PollRef = .{},
-
+ deinit_scheduled: bool = false,
temporary_url_buffer: std.ArrayListUnmanaged(u8) = .{},
pub const Class = JSC.NewClass(
@@ -4291,7 +4291,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
ws.handler.app = null;
}
this.unref();
- this.deinit();
+ this.scheduleDeinit();
}
}
@@ -4307,6 +4307,16 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
this.deinitIfWeCan();
}
+ pub fn scheduleDeinit(this: *ThisServer) void {
+ if (this.deinit_scheduled)
+ return;
+ this.deinit_scheduled = true;
+ httplog("scheduleDeinit", .{});
+ var task = bun.default_allocator.create(JSC.AnyTask) catch unreachable;
+ task.* = JSC.AnyTask.New(ThisServer, deinit).init(this);
+ this.vm.enqueueTask(JSC.Task.init(task));
+ }
+
pub fn deinit(this: *ThisServer) void {
httplog("deinit", .{});
this.app.destroy();