diff --git a/src/jamidht/server_account_manager.cpp b/src/jamidht/server_account_manager.cpp index 370e64641e801354b194c5d14ee88a7fa39060a4..056f78e22e76c6c85c97aa8e1ca50964a0ab7d5c 100644 --- a/src/jamidht/server_account_manager.cpp +++ b/src/jamidht/server_account_manager.cpp @@ -283,10 +283,14 @@ ServerAccountManager::sendRequest(const std::shared_ptr<dht::http::Request>& req void ServerAccountManager::clearRequest(const std::weak_ptr<dht::http::Request>& request) { - if (auto req = request.lock()) { - std::lock_guard lock(requestLock_); - requests_.erase(req); - } + Manager::instance().ioContext()->post([w=weak_from_this(), request] { + if (auto this_ = std::static_pointer_cast<ServerAccountManager>(w.lock())) { + if (auto req = request.lock()) { + std::lock_guard lock(this_->requestLock_); + this_->requests_.erase(req); + } + } + }); } void