diff --git a/src/jamidht/conversation.cpp b/src/jamidht/conversation.cpp index 5b25af67aea2c3824b6fbe1afa475828fae9e197..50bf4c1e9a7c9c9f3d3fdd14e9346c23ae40d21a 100644 --- a/src/jamidht/conversation.cpp +++ b/src/jamidht/conversation.cpp @@ -670,6 +670,7 @@ public: /** * Loaded history represents the linearized history to show for clients */ + mutable std::mutex loadingMtx_; mutable History loadedHistory_ {}; std::vector<std::shared_ptr<libjami::SwarmMessage>> addToHistory( const std::vector<std::map<std::string, std::string>>& commits, @@ -878,6 +879,9 @@ Conversation::Impl::loadMessages(const LogOptions& options) std::vector<libjami::SwarmMessage> Conversation::Impl::loadMessages2(const LogOptions& options, History* optHistory) { + + std::lock_guard lk(loadingMtx_); + if (!optHistory) { std::lock_guard lock(historyMtx_); if (!repository_ || isLoadingHistory_) @@ -1712,11 +1716,15 @@ Conversation::loadMessages2(const OnLoadMessages2& cb, const LogOptions& options void Conversation::clearCache() { + std::lock_guard lk(pimpl_->loadingMtx_); pimpl_->loadedHistory_.messageList.clear(); pimpl_->loadedHistory_.quickAccess.clear(); pimpl_->loadedHistory_.pendingEditions.clear(); pimpl_->loadedHistory_.pendingReactions.clear(); - pimpl_->memberToStatus.clear(); + { + std::lock_guard lk(pimpl_->messageStatusMtx_); + pimpl_->memberToStatus.clear(); + } } std::string