Partition: add client list

For efficient traversal within one partition, e.g. for distributing
partition-local idle events.
This commit is contained in:
Max Kellermann
2020-01-20 13:16:13 +01:00
parent 77271ebc1f
commit 56eaf000a4
6 changed files with 19 additions and 10 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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();