Skip to content

Commit

Permalink
fix calc_sever print_status npe bug (#387)
Browse files Browse the repository at this point in the history
* fix calc_sever print_status npe bug

* fix: one line is out of limit

Co-authored-by: tianjian <tianjian@ezoodb.com>
  • Loading branch information
tianjian600526 and tianjian authored Nov 23, 2022
1 parent 71c3340 commit fead587
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ nbproject/
*.pdb
*.exe
*.ilk
*.lib
*.lib
.idea
cmake-build*
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ if (NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
if (APPLE)
include_directories(BEFORE /usr/local/opt/openssl/include)
link_directories(/usr/local/opt/openssl/lib)
include_directories(BEFORE
/usr/local/opt/openssl/include
)
link_directories(
/usr/local/opt/openssl/lib
)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
endif ()
Expand Down
6 changes: 4 additions & 2 deletions examples/calculator/calc_server.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@ void print_status(const std::string& cmd,
<< "current term: "
<< stuff.raft_instance_->get_term() << std::endl
<< "last snapshot log index: "
<< stuff.sm_->last_snapshot()->get_last_log_idx() << std::endl
<< (stuff.sm_->last_snapshot()
? stuff.sm_->last_snapshot()->get_last_log_idx() : 0) << std::endl
<< "last snapshot log term: "
<< stuff.sm_->last_snapshot()->get_last_log_term() << std::endl
<< (stuff.sm_->last_snapshot()
? stuff.sm_->last_snapshot()->get_last_log_term() : 0) << std::endl
<< "state machine value: "
<< get_sm()->get_current_value() << std::endl;
}
Expand Down

0 comments on commit fead587

Please sign in to comment.