Skip to content

Commit

Permalink
Use weak_from_this
Browse files Browse the repository at this point in the history
  • Loading branch information
szmyd committed Oct 2, 2023
1 parent 62b38e3 commit 2c2948e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/lib/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,15 @@ bool msg_service::raftStep(const sisl::AsyncRpcDataPtr< Messaging, RaftGroupMsg,
response.set_group_name(group_name);
if (server) {
/// TODO replace this ugly hack
//if (auto offload = _get_process_offload(request.group_type()); nullptr != offload) {
// offload([rpc_data, server]() {
// auto& request = rpc_data->request();
// auto& response = rpc_data->response();
// rpc_data->set_status(server->step(request.msg(), *response.mutable_msg()));
// rpc_data->send_response();
// });
// return false;
//}
// if (auto offload = _get_process_offload(request.group_type()); nullptr != offload) {
// offload([rpc_data, server]() {
// auto& request = rpc_data->request();
// auto& response = rpc_data->response();
// rpc_data->set_status(server->step(request.msg(), *response.mutable_msg()));
// rpc_data->send_response();
// });
// return false;
// }
try {
rpc_data->set_status(server->step(request.msg(), *response.mutable_msg()));
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/tests/MessagingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ constexpr auto elect_to_high = elect_to_low * 2;

namespace nuraft_mesg {

class TestApplication : public MessagingApplication, std::enable_shared_from_this< TestApplication > {
class TestApplication : public MessagingApplication, public std::enable_shared_from_this< TestApplication > {
public:
std::string name_;
uint32_t port_;
Expand Down Expand Up @@ -81,7 +81,7 @@ class TestApplication : public MessagingApplication, std::enable_shared_from_thi
params.server_uuid_ = id_;
params.mesg_port_ = port_;
params.default_group_type_ = "test_type";
instance_ = init_messaging(params, shared_from_this(), false);
instance_ = init_messaging(params, weak_from_this(), false);
auto r_params = nuraft::raft_params()
.with_election_timeout_lower(elect_to_low)
.with_election_timeout_upper(elect_to_high)
Expand Down

0 comments on commit 2c2948e

Please sign in to comment.