diff options
author | 2023-09-07 17:41:50 -0400 | |
---|---|---|
committer | 2023-09-07 17:41:50 -0400 | |
commit | 0a125c514d8e0cabd2e6a8b1cbf6887f97399b1a (patch) | |
tree | 8e527daa5bec956c2529db3f39d4c1aabdbe0f92 | |
parent | 29c5645f50a0698afb77d33009e602e187946e94 (diff) | |
download | bun-0a125c514d8e0cabd2e6a8b1cbf6887f97399b1a.tar.gz bun-0a125c514d8e0cabd2e6a8b1cbf6887f97399b1a.tar.zst bun-0a125c514d8e0cabd2e6a8b1cbf6887f97399b1a.zip |
only schedule if queue is not empty
-rw-r--r-- | src/bun.js/webcore/response.zig | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/src/bun.js/webcore/response.zig b/src/bun.js/webcore/response.zig index 4766d2a2d..c9dcb668f 100644 --- a/src/bun.js/webcore/response.zig +++ b/src/bun.js/webcore/response.zig @@ -680,7 +680,6 @@ pub const Fetch = struct { response_buffer: MutableString = undefined, // all shedule buffers are stored here when not streaming scheduled_response_buffer: MutableString = undefined, - has_schedule_callback: std.atomic.Atomic(bool) = std.atomic.Atomic(bool).init(false), /// response strong ref response: JSC.Strong = .{}, /// stream strong ref if any is available @@ -1080,17 +1079,10 @@ pub const Fetch = struct { JSC.markBinding(@src()); log("onProgressUpdate", .{}); - var has_more = false; while (this.result_queue.pop()) |result| { defer result.deinit(); - has_more = result.has_more; this.processResult(result); } - - if (has_more) { - this.has_schedule_callback.store(false, .Monotonic); - return; - } } pub fn checkServerIdentity(this: *FetchTasklet, certificate_info: HTTPClient.CertificateInfo, result: *HTTPClientQueueResult) bool { @@ -1522,14 +1514,12 @@ pub const Fetch = struct { .body = MutableString.initCopy(bun.default_allocator, result.body.?.*.list.items) catch @panic("OOM"), }; task.size_hint = item.getSizeHint(); + const is_empty = task.result_queue.isEmpty(); task.result_queue.push(item); task.response_buffer.reset(); - if (task.has_schedule_callback.compareAndSwap(false, true, .Acquire, .Monotonic)) |has_schedule_callback| { - if (has_schedule_callback) { - return; - } + if (is_empty) { + task.javascript_vm.eventLoop().enqueueTaskConcurrent(task.concurrent_task.from(task, .manual_deinit)); } - task.javascript_vm.eventLoop().enqueueTaskConcurrent(task.concurrent_task.from(task, .manual_deinit)); } }; |