Skip to content

Commit

Permalink
Fix ZENOH_ROUTER_CHECK_ATTEMPTS which was not respected (#427)
Browse files Browse the repository at this point in the history
* Fix check of connection to a router

* README: update ZENOH_ROUTER_CHECK_ATTEMPTS following default value change in #308

(cherry picked from commit 6f910bf)
  • Loading branch information
JEnoch authored and mergify[bot] committed Jan 17, 2025
1 parent ceb6d28 commit 589993a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,15 @@ The `ZENOH_ROUTER_CHECK_ATTEMPTS` environment variable can be used to configure
The behavior is explained in the table below.


| ZENOH_ROUTER_CHECK_ATTEMPTS | Session behavior |
|:---------------------------:|:----------------------------------------------------------------------------------------------------------------:|
| unset or 0 | Indefinitely waits for connection to a Zenoh router. |
| < 0 | Skips Zenoh router check. |
| ZENOH_ROUTER_CHECK_ATTEMPTS | Session behavior |
|:---------------------------:|:------------------------------------------------------------------------------------------------------------------:|
| 0 | Indefinitely waits for connection to a Zenoh router. |
| < 0 | Skips Zenoh router check. |
| > 0 | Attempts to connect to a Zenoh router in `ZENOH_ROUTER_CHECK_ATTEMPTS` attempts with 1 second wait between checks. |
| unset | Equivalent to `1`: the check is made only once. |

If after the configured number of attempts the Node is still not connected to a `Zenoh router`, the initialisation goes on anyway.
If a `Zenoh router` is started after initialization phase, the Node will automatically connect to it, and autoconnect to other Nodes if gossip scouting is enabled (true with default configuratiuon).

### Session and Router configs
`rmw_zenoh` relies on separate configurations files to configure the `Zenoh router` and `Zenoh session` respectively.
Expand Down
4 changes: 2 additions & 2 deletions rmw_zenoh_cpp/src/detail/rmw_context_impl_s.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ class rmw_context_impl_s::Data final : public std::enable_shared_from_this<Data>
constexpr int64_t ticks_between_print(std::chrono::milliseconds(1000) / sleep_time);
do {
zenoh::ZResult result;
this->session_->get_routers_z_id(&result);
if (result == Z_OK) {
const auto zids = this->session_->get_routers_z_id(&result);
if (result == Z_OK && !zids.empty()) {
break;
}
if ((connection_attempts % ticks_between_print) == 0) {
Expand Down

0 comments on commit 589993a

Please sign in to comment.