From efb32d599f359b8266f676ec59d7f0991804ecaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Mon, 21 Apr 2025 22:56:52 -0400 Subject: [PATCH] MultiplexedSocket: unlock during onChannelReady Change-Id: I5c29a6f20ec6a338135f79126a85c0377222bb9b --- src/multiplexed_socket.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/multiplexed_socket.cpp b/src/multiplexed_socket.cpp index 8dbf786..3a130d9 100644 --- a/src/multiplexed_socket.cpp +++ b/src/multiplexed_socket.cpp @@ -284,19 +284,21 @@ MultiplexedSocket::Impl::eventLoop() void MultiplexedSocket::Impl::onAccept(const std::string& name, uint16_t channel) { - std::lock_guard lkSockets(socketsMutex); - auto& socket = sockets[channel]; + std::unique_lock lk(socketsMutex); + auto socket = sockets[channel]; if (!socket) { if (logger_) logger_->error("Receiving an answer for a non existing channel. This is a bug."); return; } + lk.unlock(); onChannelReady_(deviceId, socket); socket->ready(true); // Due to the callbacks that can take some time, onAccept can arrive after // receiving all the data. In this case, the socket should be removed here // as handle by onChannelReady_ + lk.lock(); if (socket->isRemovable()) sockets.erase(channel); else -- GitLab