diff --git a/conanfile.py b/conanfile.py index e616576..a62ca3c 100644 --- a/conanfile.py +++ b/conanfile.py @@ -10,7 +10,7 @@ class NuRaftMesgConan(ConanFile): name = "nuraft_mesg" - version = "3.7.0" + version = "3.7.1" homepage = "https://github.com/eBay/nuraft_mesg" description = "A gRPC service for NuRAFT" diff --git a/include/nuraft_mesg/mesg_state_mgr.hpp b/include/nuraft_mesg/mesg_state_mgr.hpp index 8e835d2..a5b9d9f 100644 --- a/include/nuraft_mesg/mesg_state_mgr.hpp +++ b/include/nuraft_mesg/mesg_state_mgr.hpp @@ -79,9 +79,14 @@ class mesg_state_mgr : public nuraft::state_mgr { virtual void permanent_destroy() = 0; virtual void leave() = 0; - virtual std::pair< bool, nuraft::cb_func::ReturnCode > handle_raft_event(nuraft::cb_func::Type, - nuraft::cb_func::Param*) { - return std::pair(false, nuraft::cb_func::ReturnCode::Ok); + /// TODO: Deprecated DO NOT USE + virtual std::pair< bool, nuraft::cb_func::ReturnCode > handle_raft_event(nuraft::cb_func::Type t, + nuraft::cb_func::Param* p) { + return std::pair(false, raft_event(t, p)); + } + + virtual nuraft::cb_func::ReturnCode raft_event(nuraft::cb_func::Type, nuraft::cb_func::Param*) { + return nuraft::cb_func::ReturnCode::Ok; } nuraft::cb_func::ReturnCode internal_raft_event_handler(group_id_t const& group_id, nuraft::cb_func::Type type, diff --git a/src/lib/manager_impl.cpp b/src/lib/manager_impl.cpp index b77208b..ded9ab7 100644 --- a/src/lib/manager_impl.cpp +++ b/src/lib/manager_impl.cpp @@ -125,9 +125,9 @@ void ManagerImpl::register_mgr_type(group_type_t const& group_type, group_params if (_state_mgr_types.end() == it) { LOGE("Could not register [group_type={}]", group_type); } } -nuraft::cb_func::ReturnCode ManagerImpl::generic_raft_event_handler(group_id_t const& group_id, - nuraft::cb_func::Type type, - nuraft::cb_func::Param* param) { +void ManagerImpl::generic_raft_event_handler(group_id_t const& group_id, + nuraft::cb_func::Type type, + nuraft::cb_func::Param* param) { auto const& my_id = param->myId; auto const& leader_id = param->leaderId; switch (type) { @@ -171,7 +171,6 @@ nuraft::cb_func::ReturnCode ManagerImpl::generic_raft_event_handler(group_id_t c default: break; }; - return nuraft::cb_func::ReturnCode::Ok; } void ManagerImpl::exit_group(group_id_t const& group_id) { @@ -388,9 +387,12 @@ void mesg_state_mgr::make_repl_ctx(grpc_server* server, std::shared_ptr< mesg_fa nuraft::cb_func::ReturnCode mesg_state_mgr::internal_raft_event_handler(group_id_t const& group_id, nuraft::cb_func::Type type, nuraft::cb_func::Param* param) { - if (auto const [handled, ret] = handle_raft_event(type, param); handled) { return ret; } - if (auto sp = m_manager.lock(); sp) { return sp->generic_raft_event_handler(group_id, type, param); } - return nuraft::cb_func::Ok; + // Have we shutdown? + if (auto sp = m_manager.lock(); sp) + sp->generic_raft_event_handler(group_id, type, param); + else + return nuraft::cb_func::ReturnNull; + return handle_raft_event(type, param).second; } std::shared_ptr< Manager > init_messaging(Manager::Params const& p, std::weak_ptr< MessagingApplication > w, diff --git a/src/lib/manager_impl.hpp b/src/lib/manager_impl.hpp index 3d65983..9adeee0 100644 --- a/src/lib/manager_impl.hpp +++ b/src/lib/manager_impl.hpp @@ -92,8 +92,8 @@ class ManagerImpl : public Manager, public std::enable_shared_from_this< Manager nuraft::cmd_result_code group_init(int32_t const srv_id, group_id_t const& group_id, group_type_t const& group_type, nuraft::context*& ctx, std::shared_ptr< group_metrics > metrics); void start(bool and_data_svc); - nuraft::cb_func::ReturnCode generic_raft_event_handler(group_id_t const& group_id, nuraft::cb_func::Type type, - nuraft::cb_func::Param* param); + void generic_raft_event_handler(group_id_t const& group_id, nuraft::cb_func::Type type, + nuraft::cb_func::Param* param); // };