Skip to content

Commit

Permalink
Fix to the wrong example in calc_state_machine.hxx (#514)
Browse files Browse the repository at this point in the history
* Once reading snapshot request fails, the state machine should return
a negative number, not 0.
  • Loading branch information
greensky00 authored Jun 12, 2024
1 parent 32502e4 commit ad102a4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion examples/calculator/calc_state_machine.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,14 @@ public:
auto entry = snapshots_.find(s.get_last_log_idx());
if (entry == snapshots_.end()) {
// Snapshot doesn't exist.
//
// NOTE:
// This should not happen in real use cases.
// The below code is an example about how to handle
// this case without aborting the server.
data_out = nullptr;
is_last_obj = true;
return 0;
return -1;
}
ctx = entry->second;
}
Expand Down

0 comments on commit ad102a4

Please sign in to comment.