Skip to content

Commit

Permalink
Moved scope_exit right after checking session
Browse files Browse the repository at this point in the history
  • Loading branch information
CihatAltiparmak committed Aug 2, 2024
1 parent 0566dc2 commit 35c5ba0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions rmw_zenoh_cpp/src/zenohd/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ int main(int argc, char ** argv)
printf("Unable to open router session!\n");
return 1;
}
auto close_session = rcpputils::make_scope_exit(
[&session]() {
z_close(z_move(session));
});

printf(
"Started Zenoh router with id %s.\n",
rmw_zenoh_cpp::liveliness::zid_to_str(z_info_zid(z_session_loan(&session))).c_str());
Expand All @@ -209,11 +214,6 @@ int main(int argc, char ** argv)
signal(SIGTERM, quit);
#endif

auto close_session = rcpputils::make_scope_exit(
[&session]() {
z_close(z_move(session));
});

KeyboardReader keyreader;

char c = 0;
Expand Down

0 comments on commit 35c5ba0

Please sign in to comment.