Skip to content

Commit 3bc654b

Browse files
authored
Merge pull request #890 from lightpanda-io/xhr_cant_block_sync_requests
Always make sure we have 1 free http state available for synchronous …
2 parents d35a3ea + 4f8a3fe commit 3bc654b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/http/client.zig

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,12 @@ const AsyncQueue = struct {
287287

288288
fn _check(self: *AsyncQueue, repeat_delay: *?u63) !void {
289289
const client = self.client;
290+
if (client.freeSlotCount() == 1) {
291+
// always leave 1 free connection for sync requests
292+
repeat_delay.* = 10 * std.time.ns_per_ms;
293+
return;
294+
}
295+
290296
const state = client.state_pool.acquireOrNull() orelse {
291297
// re-run this function in 10 milliseconds
292298
repeat_delay.* = 10 * std.time.ns_per_ms;
@@ -3802,7 +3808,7 @@ const TestContext = struct {
38023808
errdefer loop.deinit();
38033809

38043810
var o = opts;
3805-
o.max_concurrent = 1;
3811+
o.max_concurrent = 2;
38063812

38073813
const client = try Client.init(testing.allocator, loop, o);
38083814
errdefer client.deinit();

0 commit comments

Comments
 (0)