mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
Fix memory leaks
This commit is contained in:
@@ -306,7 +306,7 @@ pub const Request = struct {
|
|||||||
fn destroyConnection(self: *Request, connection: *Connection) void {
|
fn destroyConnection(self: *Request, connection: *Connection) void {
|
||||||
const client = self._client;
|
const client = self._client;
|
||||||
connection.deinit(client.allocator);
|
connection.deinit(client.allocator);
|
||||||
errdefer client.connection_pool.destroy(connection);
|
client.connection_pool.destroy(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
const AddHeaderOpts = struct {
|
const AddHeaderOpts = struct {
|
||||||
@@ -2153,6 +2153,7 @@ const IdleConnections = struct {
|
|||||||
|
|
||||||
fn get(self: *IdleConnections, secure: bool, host: []const u8, port: u16, blocking: bool) ?*Connection {
|
fn get(self: *IdleConnections, secure: bool, host: []const u8, port: u16, blocking: bool) ?*Connection {
|
||||||
self.mutex.lock();
|
self.mutex.lock();
|
||||||
|
defer self.mutex.unlock();
|
||||||
|
|
||||||
var node = self.idle.first;
|
var node = self.idle.first;
|
||||||
while (node) |n| {
|
while (node) |n| {
|
||||||
@@ -2161,12 +2162,10 @@ const IdleConnections = struct {
|
|||||||
self.count -= 1;
|
self.count -= 1;
|
||||||
self.idle.remove(n);
|
self.idle.remove(n);
|
||||||
self.node_pool.destroy(n);
|
self.node_pool.destroy(n);
|
||||||
self.mutex.unlock();
|
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
node = n.next;
|
node = n.next;
|
||||||
}
|
}
|
||||||
self.mutex.unlock();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2178,6 +2177,7 @@ const IdleConnections = struct {
|
|||||||
if (self.count == self.max) {
|
if (self.count == self.max) {
|
||||||
const oldest = self.idle.popFirst() orelse {
|
const oldest = self.idle.popFirst() orelse {
|
||||||
std.debug.assert(self.max == 0);
|
std.debug.assert(self.max == 0);
|
||||||
|
connection.deinit(self.allocator);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
oldest.data.deinit(self.allocator);
|
oldest.data.deinit(self.allocator);
|
||||||
|
|||||||
@@ -534,9 +534,6 @@ fn serveHTTPS(address: std.net.Address) !void {
|
|||||||
var listener = try address.listen(.{ .reuse_address = true });
|
var listener = try address.listen(.{ .reuse_address = true });
|
||||||
defer listener.deinit();
|
defer listener.deinit();
|
||||||
|
|
||||||
var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
|
|
||||||
defer arena.deinit();
|
|
||||||
|
|
||||||
test_wg.finish();
|
test_wg.finish();
|
||||||
|
|
||||||
var seed: u64 = undefined;
|
var seed: u64 = undefined;
|
||||||
@@ -546,9 +543,6 @@ fn serveHTTPS(address: std.net.Address) !void {
|
|||||||
|
|
||||||
var read_buffer: [1024]u8 = undefined;
|
var read_buffer: [1024]u8 = undefined;
|
||||||
while (true) {
|
while (true) {
|
||||||
// defer _ = arena.reset(.{ .retain_with_limit = 1024 });
|
|
||||||
// const aa = arena.allocator();
|
|
||||||
|
|
||||||
const stream = blk: {
|
const stream = blk: {
|
||||||
const conn = try listener.accept();
|
const conn = try listener.accept();
|
||||||
break :blk conn.stream;
|
break :blk conn.stream;
|
||||||
|
|||||||
Reference in New Issue
Block a user