diff --git a/src/http/client.zig b/src/http/client.zig index eccd811a..5bbec07b 100644 --- a/src/http/client.zig +++ b/src/http/client.zig @@ -306,7 +306,7 @@ pub const Request = struct { fn destroyConnection(self: *Request, connection: *Connection) void { const client = self._client; connection.deinit(client.allocator); - errdefer client.connection_pool.destroy(connection); + client.connection_pool.destroy(connection); } const AddHeaderOpts = struct { @@ -2153,6 +2153,7 @@ const IdleConnections = struct { fn get(self: *IdleConnections, secure: bool, host: []const u8, port: u16, blocking: bool) ?*Connection { self.mutex.lock(); + defer self.mutex.unlock(); var node = self.idle.first; while (node) |n| { @@ -2161,12 +2162,10 @@ const IdleConnections = struct { self.count -= 1; self.idle.remove(n); self.node_pool.destroy(n); - self.mutex.unlock(); return connection; } node = n.next; } - self.mutex.unlock(); return null; } @@ -2178,6 +2177,7 @@ const IdleConnections = struct { if (self.count == self.max) { const oldest = self.idle.popFirst() orelse { std.debug.assert(self.max == 0); + connection.deinit(self.allocator); return; }; oldest.data.deinit(self.allocator); diff --git a/src/main.zig b/src/main.zig index 48463cfe..c6c163d5 100644 --- a/src/main.zig +++ b/src/main.zig @@ -534,9 +534,6 @@ fn serveHTTPS(address: std.net.Address) !void { var listener = try address.listen(.{ .reuse_address = true }); defer listener.deinit(); - var arena = std.heap.ArenaAllocator.init(std.testing.allocator); - defer arena.deinit(); - test_wg.finish(); var seed: u64 = undefined; @@ -546,9 +543,6 @@ fn serveHTTPS(address: std.net.Address) !void { var read_buffer: [1024]u8 = undefined; while (true) { - // defer _ = arena.reset(.{ .retain_with_limit = 1024 }); - // const aa = arena.allocator(); - const stream = blk: { const conn = try listener.accept(); break :blk conn.stream;