mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
Close all cdp clients on shutdown
This commit is contained in:
@@ -64,17 +64,17 @@ pub fn init(app: *App, address: net.Address) !*Server {
|
||||
return self;
|
||||
}
|
||||
|
||||
pub fn deinit(self: *Server) void {
|
||||
// Stop all active clients
|
||||
{
|
||||
self.client_mutex.lock();
|
||||
defer self.client_mutex.unlock();
|
||||
pub fn shutdown(self: *Server) void {
|
||||
self.client_mutex.lock();
|
||||
defer self.client_mutex.unlock();
|
||||
|
||||
for (self.clients.items) |client| {
|
||||
client.stop();
|
||||
}
|
||||
for (self.clients.items) |client| {
|
||||
client.stop();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn deinit(self: *Server) void {
|
||||
self.shutdown();
|
||||
self.joinThreads();
|
||||
self.clients.deinit(self.allocator);
|
||||
self.clients_pool.deinit();
|
||||
|
||||
@@ -115,6 +115,8 @@ fn run(allocator: Allocator, main_arena: Allocator) !void {
|
||||
};
|
||||
defer server.deinit();
|
||||
|
||||
try sighandler.on(lp.Server.shutdown, .{server});
|
||||
|
||||
app.network.run();
|
||||
},
|
||||
.fetch => |opts| {
|
||||
|
||||
@@ -491,7 +491,7 @@ fn acceptConnections(self: *Runtime) void {
|
||||
error.ConnectionAborted => {
|
||||
lp.log.warn(.app, "accept connection aborted", .{});
|
||||
continue;
|
||||
},
|
||||
},
|
||||
else => {
|
||||
lp.log.err(.app, "accept error", .{ .err = err });
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user