mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-12 22:09:25 +08:00
ConversationModule: avoid deadlock if callback is called synchronously
Change-Id: I7aedd81b133985210cf817d2c524ef3415a219c0
This commit is contained in:
@ -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),
|
||||
|
Reference in New Issue
Block a user