Commit c046a5e 1 parent afe1ff9 commit c046a5e Copy full SHA for c046a5e
File tree 1 file changed +7
-11
lines changed
1 file changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -96,8 +96,6 @@ class rmw_context_impl_s::Data final
96
96
throw std::runtime_error (" Error setting up zenoh session. " );
97
97
}
98
98
99
- rmw_ret_t ret = RMW_RET_ERROR;
100
-
101
99
// Verify if the zenoh router is running if configured.
102
100
const std::optional<uint64_t > configured_connection_attempts =
103
101
rmw_zenoh_cpp::zenoh_router_check_attempts ();
@@ -106,25 +104,23 @@ class rmw_context_impl_s::Data final
106
104
// Retry until the connection is successful.
107
105
constexpr std::chrono::milliseconds sleep_time (1000 );
108
106
constexpr int64_t ticks_between_print (std::chrono::milliseconds (1000 ) / sleep_time);
109
- while (ret != RMW_RET_OK && connection_attempts < configured_connection_attempts.value ()) {
107
+ do {
108
+ zenoh::ZResult result;
109
+ this ->session_ ->get_routers_z_id (&result);
110
+ if (result == Z_OK) {
111
+ break ;
112
+ }
110
113
if ((connection_attempts % ticks_between_print) == 0 ) {
111
114
RMW_ZENOH_LOG_WARN_NAMED (
112
115
" rmw_zenoh_cpp" ,
113
116
" Unable to connect to a Zenoh router. "
114
117
" Have you started a router with `ros2 run rmw_zenoh_cpp rmw_zenohd`?" );
115
118
}
116
- zenoh::ZResult result;
117
- this ->session_ ->get_routers_z_id (&result);
118
- if (result != Z_OK) {
119
- ++connection_attempts;
120
- } else {
121
- ret = RMW_RET_OK;
122
- }
123
119
if (++connection_attempts >= configured_connection_attempts.value ()) {
124
120
break ;
125
121
}
126
122
std::this_thread::sleep_for (sleep_time);
127
- }
123
+ } while (connection_attempts < configured_connection_attempts. value ());
128
124
}
129
125
130
126
// Initialize the graph cache.
You can’t perform that action at this time.
0 commit comments