Skip to content
Snippets Groups Projects
Commit d8e666dc authored by Adrien Béraud's avatar Adrien Béraud
Browse files

MultiplexedSocket: lock in getChannelList

Change-Id: I377ca001dbc1821b3b22dfc83d7b2677cc344477
parent 67a24fcb
Branches
No related tags found
No related merge requests found
...@@ -1214,17 +1214,15 @@ ChannelSocket::getRemoteAddress() const ...@@ -1214,17 +1214,15 @@ ChannelSocket::getRemoteAddress() const
std::vector<std::map<std::string, std::string>> std::vector<std::map<std::string, std::string>>
MultiplexedSocket::getChannelList() const MultiplexedSocket::getChannelList() const
{ {
std::lock_guard<std::mutex> lkSockets(pimpl_->socketsMutex);
std::vector<std::map<std::string, std::string>> channelsList; std::vector<std::map<std::string, std::string>> channelsList;
channelsList.reserve(pimpl_->sockets.size());
for (const auto& [_, channel] : pimpl_->sockets) { for (const auto& [_, channel] : pimpl_->sockets) {
if (channel) { channelsList.emplace_back(std::map<std::string, std::string> {
std::map<std::string, std::string> channelMap; {"id", fmt::format("{:x}", channel->channel())},
channelMap["channel"] = std::to_string(channel->channel()); {"name", channel->name()},
channelMap["channelName"]= channel->name(); });
channelsList.emplace_back(std::move(channelMap));
}
} }
return channelsList; return channelsList;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment