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

ConversationModule: avoid deadlock if callback is called synchronously

Change-Id: I7aedd81b133985210cf817d2c524ef3415a219c0
parent a4418d3e
Branches
No related tags found
No related merge requests found
......@@ -568,25 +568,27 @@ ConversationModule::Impl::fetchNewCommits(const std::string& peer,
onNeedSocket_(
conversationId,
deviceId,
[this,
[w = weak(),
conv,
conversationId = std::move(conversationId),
peer = std::move(peer),
deviceId = std::move(deviceId),
commitId = std::move(commitId)](const auto& channel) {
std::lock_guard lk(conv->mtx);
// auto conversation = conversations_.find(conversationId);
auto acc = account_.lock();
if (!channel || !acc || !conv->conversation) {
auto sthis = w.lock();
auto acc = sthis ? sthis->account_.lock() : nullptr;
std::unique_lock lk(conv->mtx);
auto conversation = conv->conversation;
if (!channel || !acc || !conversation) {
conv->stopFetch(deviceId);
syncCnt.fetch_sub(1);
if (sthis) sthis->syncCnt.fetch_sub(1);
return false;
}
conv->conversation->addGitSocket(channel->deviceId(), channel);
conv->conversation->sync(
conversation->addGitSocket(channel->deviceId(), channel);
lk.unlock();
conversation->sync(
peer,
deviceId,
[w = weak(),
[w,
conv,
conversationId = std::move(conversationId),
peer = std::move(peer),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment