Skip to content

Commit

Permalink
change map key from cshared to raw ptr
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaoxi Chen <[email protected]>
  • Loading branch information
xiaoxichen committed Sep 28, 2024
1 parent fc7b272 commit 5f69162
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/lib/replication/service/raft_repl_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 >();
Expand All @@ -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
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/lib/replication/service/raft_repl_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ struct ReplDevCPContext;

class ReplSvcCPContext : public CPContext {
std::shared_mutex m_cp_map_mtx;
std::map< cshared< ReplDev >, cshared<ReplDevCPContext> > m_cp_ctx_map;
std::map< ReplDev*, cshared<ReplDevCPContext> > m_cp_ctx_map;
public:
ReplSvcCPContext(CP* cp) : CPContext(cp){};
virtual ~ReplSvcCPContext() = default;
int add_repl_dev_ctx(cshared<ReplDev > dev, cshared<ReplDevCPContext> dev_ctx);
cshared<ReplDevCPContext> get_repl_dev_ctx(cshared<ReplDev > dev);
int add_repl_dev_ctx(ReplDev* dev, cshared<ReplDevCPContext> dev_ctx);
cshared<ReplDevCPContext> get_repl_dev_ctx(ReplDev* dev);
};

class RaftReplServiceCPHandler : public CPCallbacks {
Expand Down

0 comments on commit 5f69162

Please sign in to comment.