From 020ef6048f78eda1cc1f9f1885b64bbb2a85af5e Mon Sep 17 00:00:00 2001 From: "Ravi Akella email = raakella@ebay.com" Date: Wed, 5 Jul 2023 15:46:04 -0700 Subject: [PATCH] add completion callback as part of the rpc data --- src/lib/state_machine/replica_set.cpp | 6 +----- src/lib/state_machine/state_machine.cpp | 4 ++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/state_machine/replica_set.cpp b/src/lib/state_machine/replica_set.cpp index 335513b..da30f19 100644 --- a/src/lib/state_machine/replica_set.cpp +++ b/src/lib/state_machine/replica_set.cpp @@ -49,8 +49,7 @@ bool ReplicaSet::register_data_service_apis(std::shared_ptr< nuraft_mesg::consen SEND_DATA, m_group_id, [this](sisl::io_blob const& incoming_buf, boost::intrusive_ptr< sisl::GenericRpcData >& rpc_data) { m_state_machine->on_data_received(incoming_buf, rpc_data); - }, - nullptr); + }); !resp) { // LOG ERROR return false; @@ -60,9 +59,6 @@ bool ReplicaSet::register_data_service_apis(std::shared_ptr< nuraft_mesg::consen FETCH_DATA, m_group_id, [this](sisl::io_blob const& incoming_buf, boost::intrusive_ptr< sisl::GenericRpcData >& rpc_data) { m_state_machine->on_fetch_data_request(incoming_buf, rpc_data); - }, - [this](boost::intrusive_ptr< sisl::GenericRpcData >& rpc_data) { - m_state_machine->on_fetch_data_completed(rpc_data); }); !resp) { // LOG ERROR diff --git a/src/lib/state_machine/state_machine.cpp b/src/lib/state_machine/state_machine.cpp index 2fe34a3..3a97496 100644 --- a/src/lib/state_machine/state_machine.cpp +++ b/src/lib/state_machine/state_machine.cpp @@ -444,6 +444,10 @@ class FetchDataContext : public sisl::GenericRpcContextBase { void ReplicaStateMachine::on_fetch_data_request(sisl::io_blob const& incoming_buf, boost::intrusive_ptr< sisl::GenericRpcData >& rpc_data) { + // set the completion callback + rpc_data->set_comp_cb( + [this](boost::intrusive_ptr< sisl::GenericRpcData >& rpc_data) { on_fetch_data_completed(rpc_data); }); + // get the pbas for which we need to send the data data_channel_rpc_hdr common_header; pba_list_t pbas;