From 56eaf000a477c609e05504e613dacbe829fbe641 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 20 Jan 2020 13:16:13 +0100 Subject: Partition: add client list For efficient traversal within one partition, e.g. for distributing partition-local idle events. --- src/client/Client.cxx | 2 ++ src/client/Client.hxx | 2 ++ src/client/New.cxx | 2 ++ 3 files changed, 6 insertions(+) (limited to 'src/client') diff --git a/src/client/Client.cxx b/src/client/Client.cxx index 6c47a0822..21bc83cdb 100644 --- a/src/client/Client.cxx +++ b/src/client/Client.cxx @@ -68,7 +68,9 @@ Client::SetPartition(Partition &new_partition) noexcept if (partition == &new_partition) return; + partition->clients.erase(partition->clients.iterator_to(*this)); partition = &new_partition; + partition->clients.push_back(*this); /* set idle flags for those subsystems which are specific to the current partition to force the client to reload its diff --git a/src/client/Client.hxx b/src/client/Client.hxx index e52a7a18a..c94350b51 100644 --- a/src/client/Client.hxx +++ b/src/client/Client.hxx @@ -52,6 +52,8 @@ class BackgroundCommand; class Client final : FullyBufferedSocket, + public boost::intrusive::list_base_hook, + boost::intrusive::link_mode>, public boost::intrusive::list_base_hook> { TimerEvent timeout_event; diff --git a/src/client/New.cxx b/src/client/New.cxx index b1affda4c..1f92c63c3 100644 --- a/src/client/New.cxx +++ b/src/client/New.cxx @@ -72,6 +72,7 @@ client_new(EventLoop &loop, Partition &partition, num); client_list.Add(*client); + partition.clients.push_back(*client); FormatInfo(client_domain, "[%u] opened from %s", num, remote.c_str()); @@ -81,6 +82,7 @@ void Client::Close() noexcept { partition->instance.client_list->Remove(*this); + partition->clients.erase(partition->clients.iterator_to(*this)); if (FullyBufferedSocket::IsDefined()) FullyBufferedSocket::Close(); -- cgit v1.2.3