Skip to content
Snippets Groups Projects
Unverified Commit ad16157b authored by Sébastien Blin's avatar Sébastien Blin
Browse files

connectionmanager: avoid deadlock on cinfo->mtx_

cinfo->mtx_ MUST be locked before socketsMutex, so it SHOULD never
be locked in a callback. Retrigger the lock in its own thread avoid
a deadlock there.

GitLab: #20
Change-Id: If17af7db81d8ca2b990629446b5d78dc11a785b1
parent 41848a2c
No related branches found
No related tags found
No related merge requests found
...@@ -1062,10 +1062,13 @@ ConnectionManager::Impl::sendChannelRequest(const std::weak_ptr<DeviceInfo>& din ...@@ -1062,10 +1062,13 @@ ConnectionManager::Impl::sendChannelRequest(const std::weak_ptr<DeviceInfo>& din
[dinfow, cinfow, wSock = std::weak_ptr(channelSock), name, vid](bool accepted) { [dinfow, cinfow, wSock = std::weak_ptr(channelSock), name, vid](bool accepted) {
if (auto dinfo = dinfow.lock()) { if (auto dinfo = dinfow.lock()) {
dinfo->executePendingOperations(vid, accepted ? wSock.lock() : nullptr, accepted); dinfo->executePendingOperations(vid, accepted ? wSock.lock() : nullptr, accepted);
// Always lock top-down cinfo->mutex
dht::ThreadPool::io().run([cinfow, vid]() {
if (auto cinfo = cinfow.lock()) { if (auto cinfo = cinfow.lock()) {
std::lock_guard<std::mutex> lk(cinfo->mutex_); std::lock_guard<std::mutex> lk(cinfo->mutex_);
cinfo->cbIds_.erase(vid); cinfo->cbIds_.erase(vid);
} }
});
} }
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment