Skip to content

Commit

Permalink
Fix collecting disconnecting clients only on exit
Browse files Browse the repository at this point in the history
Collecting clients that were normally being disconnected in
disconnectingClients was wrong and would cause the vector to grow very
large.
  • Loading branch information
halfgaar committed Nov 18, 2024
1 parent 2195ee4 commit 62bcd11
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions threaddata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,16 @@ void ThreadData::sendAllDisconnects()
serverInitiatedDisconnect(c, ReasonCodes::ServerShuttingDown, "");
}

uint64_t one = 1;
check<std::runtime_error>(write(disconnectingAllEventFd, &one, sizeof(uint64_t)));
auto queued_collect_disconnecting_clients = [clientsFound, this](){
for (const std::shared_ptr<Client> &c : clientsFound)
{
this->disconnectingClients.push_back(c);
}

uint64_t one = 1;
check<std::runtime_error>(write(disconnectingAllEventFd, &one, sizeof(uint64_t)));
};
addImmediateTask(queued_collect_disconnecting_clients);
}

void ThreadData::removeQueuedClients()
Expand Down Expand Up @@ -1029,8 +1037,6 @@ void ThreadData::serverInitiatedDisconnect(const std::shared_ptr<Client> &client
client->setDisconnectStage(DisconnectStage::Now);
removeClientQueued(client);
}

disconnectingClients.push_back(client);
};

addImmediateTask(f);
Expand Down

0 comments on commit 62bcd11

Please sign in to comment.