summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2020-01-20 13:16:13 +0100
committerMax Kellermann <max@musicpd.org>2020-01-20 13:16:13 +0100
commit56eaf000a477c609e05504e613dacbe829fbe641 (patch)
tree67b48aceec4896fc97b2c9d07b5b5c5aa5b374d3 /src/client
parent77271ebc1faecb569b6a012752973d9eed9d216f (diff)
Partition: add client list
For efficient traversal within one partition, e.g. for distributing partition-local idle events.
Diffstat (limited to 'src/client')
-rw-r--r--src/client/Client.cxx2
-rw-r--r--src/client/Client.hxx2
-rw-r--r--src/client/New.cxx2
3 files changed, 6 insertions, 0 deletions
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::tag<Partition>,
+ boost::intrusive::link_mode<boost::intrusive::normal_link>>,
public boost::intrusive::list_base_hook<boost::intrusive::link_mode<boost::intrusive::normal_link>> {
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();