From 403717911fe795f080f617804ffea370939d3386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Tue, 17 Oct 2023 14:39:16 -0400 Subject: [PATCH] MultiplexedSocket: consider unknown state as REFUSE Allows to better handle new states in the future. Change-Id: Ie8b28f9776d2c4ce8a45eb02f5af323a2ea37ffd --- src/multiplexed_socket.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/multiplexed_socket.cpp b/src/multiplexed_socket.cpp index 2471256..db4b0cb 100644 --- a/src/multiplexed_socket.cpp +++ b/src/multiplexed_socket.cpp @@ -460,9 +460,13 @@ MultiplexedSocket::Impl::handleControlPacket(std::vector<uint8_t>&& pkt) if (pimpl.handleProtocolMsg(object)) continue; auto req = object.as<ChannelRequest>(); - if (req.state == ChannelRequestState::ACCEPT) { + if (req.state == ChannelRequestState::REQUEST) { + pimpl.onRequest(req.name, req.channel); + } + else if (req.state == ChannelRequestState::ACCEPT) { pimpl.onAccept(req.name, req.channel); - } else if (req.state == ChannelRequestState::DECLINE) { + } else { + // DECLINE or unknown std::lock_guard<std::mutex> lkSockets(pimpl.socketsMutex); auto channel = pimpl.sockets.find(req.channel); if (channel != pimpl.sockets.end()) { @@ -470,8 +474,6 @@ MultiplexedSocket::Impl::handleControlPacket(std::vector<uint8_t>&& pkt) channel->second->stop(); pimpl.sockets.erase(channel); } - } else if (pimpl.onRequest_) { - pimpl.onRequest(req.name, req.channel); } } } catch (const std::exception& e) { -- GitLab