From 5f69162e7e0efa7ba525c2f8fef4020957ee13c2 Mon Sep 17 00:00:00 2001 From: Xiaoxi Chen Date: Tue, 24 Sep 2024 22:36:38 +0800 Subject: [PATCH] change map key from cshared to raw ptr Signed-off-by: Xiaoxi Chen --- src/lib/replication/service/raft_repl_service.cpp | 8 ++++---- src/lib/replication/service/raft_repl_service.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/replication/service/raft_repl_service.cpp b/src/lib/replication/service/raft_repl_service.cpp index 0dd7f0b4c..974984ca3 100644 --- a/src/lib/replication/service/raft_repl_service.cpp +++ b/src/lib/replication/service/raft_repl_service.cpp @@ -448,12 +448,12 @@ void RaftReplService::flush_durable_commit_lsn() { } ///////////////////// RaftReplService CP Callbacks ///////////////////////////// -int ReplSvcCPContext::add_repl_dev_ctx(cshared< ReplDev > dev, cshared< ReplDevCPContext > dev_ctx) { +int ReplSvcCPContext::add_repl_dev_ctx(ReplDev* dev, cshared< ReplDevCPContext > dev_ctx) { m_cp_ctx_map.emplace(dev, dev_ctx); return 0; } -cshared< ReplDevCPContext > ReplSvcCPContext::get_repl_dev_ctx(cshared< ReplDev > dev) { +cshared< ReplDevCPContext > ReplSvcCPContext::get_repl_dev_ctx(ReplDev* dev) { if (m_cp_ctx_map.count(dev) == 0) { // it is possible if a repl dev added during the cp flush return std::make_shared< ReplDevCPContext >(); @@ -472,7 +472,7 @@ std::unique_ptr< CPContext > RaftReplServiceCPHandler::on_switchover_cp(CP* cur_ // There is no dirty buffers accumulated to new_cp yet, as the cp_mgr ensure replication_svc // is the first one being called during cp switchover. auto dev_ctx = std::static_pointer_cast< RaftReplDev >(repl_dev)->get_cp_ctx(cur_cp); - cur_cp_ctx->add_repl_dev_ctx(repl_dev, std::move(dev_ctx)); + cur_cp_ctx->add_repl_dev_ctx(repl_dev.get(), std::move(dev_ctx)); }); } // create new ctx @@ -483,7 +483,7 @@ std::unique_ptr< CPContext > RaftReplServiceCPHandler::on_switchover_cp(CP* cur_ folly::Future< bool > RaftReplServiceCPHandler::cp_flush(CP* cp) { auto cp_ctx = s_cast< ReplSvcCPContext* >(cp->context(cp_consumer_t::REPLICATION_SVC)); repl_service().iterate_repl_devs([cp, cp_ctx](cshared< ReplDev >& repl_dev) { - auto dev_ctx = cp_ctx->get_repl_dev_ctx(repl_dev); + auto dev_ctx = cp_ctx->get_repl_dev_ctx(repl_dev.get()); std::static_pointer_cast< RaftReplDev >(repl_dev)->cp_flush(cp, dev_ctx); }); return folly::makeFuture< bool >(true); diff --git a/src/lib/replication/service/raft_repl_service.h b/src/lib/replication/service/raft_repl_service.h index 476d2d28f..4985d4eea 100644 --- a/src/lib/replication/service/raft_repl_service.h +++ b/src/lib/replication/service/raft_repl_service.h @@ -91,12 +91,12 @@ struct ReplDevCPContext; class ReplSvcCPContext : public CPContext { std::shared_mutex m_cp_map_mtx; - std::map< cshared< ReplDev >, cshared > m_cp_ctx_map; + std::map< ReplDev*, cshared > m_cp_ctx_map; public: ReplSvcCPContext(CP* cp) : CPContext(cp){}; virtual ~ReplSvcCPContext() = default; - int add_repl_dev_ctx(cshared dev, cshared dev_ctx); - cshared get_repl_dev_ctx(cshared dev); + int add_repl_dev_ctx(ReplDev* dev, cshared dev_ctx); + cshared get_repl_dev_ctx(ReplDev* dev); }; class RaftReplServiceCPHandler : public CPCallbacks {