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

connectionmanager: do not cancel all waiting channel if first is declined

backport of 22d5417da3023095695d3b9655403b5632f528db in jami-daemon

Change-Id: I1ccf2edfad8b0d69be08e64ab894bb52027088a7
parent 665294f4
Branches
No related tags found
No related merge requests found
...@@ -329,7 +329,7 @@ public: ...@@ -329,7 +329,7 @@ public:
std::map<DeviceId, PendingOperations> pendingOperations_ {}; std::map<DeviceId, PendingOperations> pendingOperations_ {};
void executePendingOperations(const DeviceId& deviceId, const dht::Value::Id& vid, const std::shared_ptr<ChannelSocket>& sock) void executePendingOperations(const DeviceId& deviceId, const dht::Value::Id& vid, const std::shared_ptr<ChannelSocket>& sock, bool accepted = true)
{ {
std::vector<PendingCb> ret; std::vector<PendingCb> ret;
std::unique_lock<std::mutex> lk(connectCbsMtx_); std::unique_lock<std::mutex> lk(connectCbsMtx_);
...@@ -351,7 +351,8 @@ public: ...@@ -351,7 +351,8 @@ public:
} else if (auto n = pendingOperations.connecting.extract(vid)) { } else if (auto n = pendingOperations.connecting.extract(vid)) {
ret.emplace_back(std::move(n.mapped())); ret.emplace_back(std::move(n.mapped()));
// If sock is nullptr, execute if it's the last connecting operation // If sock is nullptr, execute if it's the last connecting operation
if (!sock && pendingOperations.connecting.empty()) { // If accepted is false, it means that underlying socket is ok, but channel is declined
if (!sock && pendingOperations.connecting.empty() && accepted) {
for (auto& [vid, cb] : pendingOperations.waiting) for (auto& [vid, cb] : pendingOperations.waiting)
ret.emplace_back(std::move(cb)); ret.emplace_back(std::move(cb));
pendingOperations.waiting.clear(); pendingOperations.waiting.clear();
...@@ -799,11 +800,11 @@ ConnectionManager::Impl::sendChannelRequest(std::shared_ptr<MultiplexedSocket>& ...@@ -799,11 +800,11 @@ ConnectionManager::Impl::sendChannelRequest(std::shared_ptr<MultiplexedSocket>&
shared->executePendingOperations(deviceId, vid, nullptr); shared->executePendingOperations(deviceId, vid, nullptr);
}); });
channelSock->onReady( channelSock->onReady(
[wSock = std::weak_ptr<ChannelSocket>(channelSock), name, deviceId, vid, w = weak()]() { [wSock = std::weak_ptr<ChannelSocket>(channelSock), name, deviceId, vid, w = weak()](bool accepted) {
auto shared = w.lock(); auto shared = w.lock();
auto channelSock = wSock.lock(); auto channelSock = wSock.lock();
if (shared) if (shared)
shared->executePendingOperations(deviceId, vid, channelSock); shared->executePendingOperations(deviceId, vid, accepted ? channelSock : nullptr, accepted);
}); });
ChannelRequest val; ChannelRequest val;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment