diff --git a/src/tcp/Server.zig b/src/tcp/Server.zig index 4df05b65c..2b13e9d34 100644 --- a/src/tcp/Server.zig +++ b/src/tcp/Server.zig @@ -67,10 +67,12 @@ pub fn init( /// Deinitializes the server pub fn deinit(self: *Server) void { self.close(); + log.info("closing server socket", .{}); + log.info("deinitializing server", .{}); + self.loop.deinit(); self.comp_pool.deinit(); self.sock_pool.deinit(); self.buf_pool.deinit(); - self.loop.deinit(); } /// Starts the timer which tries to accept connections @@ -81,16 +83,13 @@ pub fn start(self: *Server) !void { try connections.startAccepting(self); log.info("bound server to socket={any}", .{self.socket}); - // TODO: Stop flag? Only necessary if we support signaling the server + // TODO(tale): Stop flag? Only necessary if we support signaling the server // from the main thread on an event, ie. configuration reloading. - while (true) { - try self.loop.run(.until_done); - } + try self.loop.run(.until_done); } /// Closes the server socket pub fn close(self: *Server) void { - log.info("closing server socket", .{}); var c: xev.Completion = undefined; self.socket.close(&self.loop, &c, bool, null, (struct { fn callback( diff --git a/src/tcp/Thread.zig b/src/tcp/Thread.zig index bafa80ad5..113d85e5a 100644 --- a/src/tcp/Thread.zig +++ b/src/tcp/Thread.zig @@ -20,7 +20,9 @@ server: ?Server, /// up all the internal state necessary prior to starting the thread. It /// is up to the caller to start the thread with the threadMain entrypoint. pub fn init(alloc: Allocator, mailbox: *App.Mailbox.Queue) !Thread { - const config = try Config.load(alloc); + var config = try Config.load(alloc); + defer config.deinit(); + const max_clients = config.@"remote-max-connections"; const addr = config.@"remote-tcp-socket";