From 49ccc2f2f69347e5d7f59fc69039a94ee38cc5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Thu, 4 May 2023 09:54:09 -0400 Subject: [PATCH] conversation: speed up shutdown by cancelling boostrap operations Change-Id: I600651eb9ac15fc081768e14c3bb95c18f44ede5 --- src/jamidht/conversation.cpp | 3 ++- src/jamidht/conversation.h | 6 +++++- src/jamidht/conversation_module.cpp | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/jamidht/conversation.cpp b/src/jamidht/conversation.cpp index 085da87bc1..b3f5e5db19 100644 --- a/src/jamidht/conversation.cpp +++ b/src/jamidht/conversation.cpp @@ -860,8 +860,9 @@ Conversation::removeGitSocket(const DeviceId& deviceId) } void -Conversation::removeGitSockets() +Conversation::shutdownConnections() { + pimpl_->fallbackTimer_->cancel(); pimpl_->gitSocketList_.clear(); pimpl_->swarmManager_->shutdown(); pimpl_->checkedMembers_.clear(); diff --git a/src/jamidht/conversation.h b/src/jamidht/conversation.h index 227afeb9dc..5b468745e8 100644 --- a/src/jamidht/conversation.h +++ b/src/jamidht/conversation.h @@ -510,7 +510,11 @@ public: std::shared_ptr<ChannelSocket> gitSocket(const DeviceId& deviceId) const; void addGitSocket(const DeviceId& deviceId, const std::shared_ptr<ChannelSocket>& socket); void removeGitSocket(const DeviceId& deviceId); - void removeGitSockets(); + + /** + * Stop SwarmManager, bootstrap and gitSockets + */ + void shutdownConnections(); /** * Used to avoid multiple connections, we just check if we got a swarm channel with a specific * device diff --git a/src/jamidht/conversation_module.cpp b/src/jamidht/conversation_module.cpp index 097e8267b0..d779c41c6f 100644 --- a/src/jamidht/conversation_module.cpp +++ b/src/jamidht/conversation_module.cpp @@ -2712,7 +2712,7 @@ ConversationModule::shutdownConnections() { std::lock_guard<std::mutex> lk(pimpl_->conversationsMtx_); for (auto& [k, conversation] : pimpl_->conversations_) - conversation->removeGitSockets(); + conversation->shutdownConnections(); } { std::lock_guard<std::mutex> lk(pimpl_->pendingConversationsFetchMtx_); -- GitLab