Skip to content
Snippets Groups Projects
Commit 67c38a17 authored by Sébastien Blin's avatar Sébastien Blin Committed by Adrien Béraud
Browse files

multiplexed_socket: lock callback while accessed

Change-Id: I9b3bc097fd3be9899316133ac0f5161170b44281
parent aac51adb
Branches
No related tags found
No related merge requests found
......@@ -290,15 +290,18 @@ MultiplexedSocket::Impl::handleChannelPacket(uint16_t channel, const std::vector
std::lock_guard<std::mutex> lkSockets(socketsMutex);
sockets.erase(sockIt);
} else {
std::unique_lock<std::mutex> lk(channelCbsMtx_);
auto cb = channelCbs_.find(channel);
if (cb != channelCbs_.end()) {
lk.unlock();
if (cb->second)
cb->second(&pkt[0], pkt.size());
GenericSocket<uint8_t>::RecvCb cb;
{
std::lock_guard<std::mutex> lk(channelCbsMtx_);
auto cbIt = channelCbs_.find(channel);
if (cbIt != channelCbs_.end()) {
cb = cbIt->second;
}
}
if (cb) {
cb(&pkt[0], pkt.size());
return;
}
lk.unlock();
dataIt->second->buf.insert(dataIt->second->buf.end(),
std::make_move_iterator(pkt.begin()),
std::make_move_iterator(pkt.end()));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment