Skip to content
Snippets Groups Projects
Commit b23278d2 authored by Andreas Traczyk's avatar Andreas Traczyk
Browse files

connectionmngr: prevent deadlock/crash

It seems there are scenarios in which the ConnectionInfo is disposed during the on-ready callback, resulting in the TlsSocketEndpoint's callback mutex being locked twice on the same thread.

Change-Id: I401b3c70ba81708e4a3d4ecf3f099f0292c2ff04
parent 21990ef0
Branches
No related tags found
No related merge requests found
...@@ -749,8 +749,14 @@ ConnectionManager::Impl::connectDeviceOnNegoDone( ...@@ -749,8 +749,14 @@ ConnectionManager::Impl::connectDeviceOnNegoDone(
info->tls_->setOnReady( info->tls_->setOnReady(
[w = weak_from_this(), dinfo, winfo=std::weak_ptr(info), deviceId = std::move(deviceId), vid = std::move(vid), name = std::move(name)]( [w = weak_from_this(), dinfo, winfo=std::weak_ptr(info), deviceId = std::move(deviceId), vid = std::move(vid), name = std::move(name)](
bool ok) { bool ok) {
if (auto shared = w.lock()) if (auto shared = w.lock()) {
shared->onTlsNegotiationDone(dinfo.lock(), winfo.lock(), ok, deviceId, vid, name); if (auto info = winfo.lock()) {
shared->onTlsNegotiationDone(dinfo.lock(), info, ok, deviceId, vid, name);
// Make sure there's another reference to info to avoid destruction when
// we leave this scope (would lead to a deadlock on cbMtx_).
dht::ThreadPool::io().run([info = std::move(info)] {});
}
}
}); });
return true; return true;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment