From b0bbb8b693d846c2710ec84bfa79dcaa3a21729a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 16 Jan 2013 21:39:40 +0100 Subject: Client: use TimeoutMonitor to track connection timeout Don't use a global loop over the whole client list. --- src/ClientInternal.hxx | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'src/ClientInternal.hxx') diff --git a/src/ClientInternal.hxx b/src/ClientInternal.hxx index 9384b84ee..097029f0b 100644 --- a/src/ClientInternal.hxx +++ b/src/ClientInternal.hxx @@ -25,6 +25,7 @@ #include "ClientMessage.hxx" #include "CommandListBuilder.hxx" #include "event/BufferedSocket.hxx" +#include "event/TimeoutMonitor.hxx" #include "command.h" #include @@ -43,7 +44,7 @@ enum { struct Partition; -class Client final : private BufferedSocket { +class Client final : private BufferedSocket, TimeoutMonitor { public: Partition &partition; struct playlist &playlist; @@ -54,11 +55,6 @@ public: /** the uid of the client process, or -1 if unknown */ int uid; - /** - * How long since the last activity from this client? - */ - GTimer *last_activity; - CommandListBuilder cmd_list; unsigned int num; /* client number */ @@ -91,7 +87,6 @@ public: Client(EventLoop &loop, Partition &partition, int fd, int uid, int num); - ~Client(); bool IsConnected() const { return BufferedSocket::IsDefined(); @@ -125,6 +120,9 @@ private: size_t length) override; virtual void OnSocketError(GError *error) override; virtual void OnSocketClosed() override; + + /* virtual methods from class TimeoutMonitor */ + virtual bool OnTimeout() override; }; extern unsigned int client_max_connections; @@ -132,19 +130,6 @@ extern int client_timeout; extern size_t client_max_command_list_size; extern size_t client_max_output_buffer_size; -/** - * Schedule an "expired" check for all clients: permanently delete - * clients which have been set "expired" with client_set_expired(). - */ -void -client_schedule_expire(void); - -/** - * Removes a scheduled "expired" check. - */ -void -client_deinit_expire(void); - enum command_return client_read(Client *client); -- cgit v1.2.3