mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-22 14:19:57 +08:00
fix(zenoh): fail the topic setup when a declaration fails (#29924)
A subscriber that could not be declared called exit(-1). That ended the module task but left the zenoh-pico tasks running, so the session stayed up with nothing bridged and `zenoh status` still reported it as connected. Return the error instead, and fail the topic setup when a subscriber or publisher declaration fails. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Leonardo Cencetti <cencetti.leonardo@gmail.com>
This commit is contained in:
1 parent
0e0f3ce8a2
commit
98e747fa3d
2 files changed
+13
-5
No files matched your search
@@ -78,8 +78,8 @@ int Zenoh_Subscriber::declare_subscriber(z_owned_session_t s, const char *keyexp
|
||||
z_view_keyexpr_from_str(&ke, keyexpr);
|
||||
|
||||
if (z_declare_subscriber(z_loan(s), &_sub, z_loan(ke), z_closure_sample_move(&callback), nullptr) < 0) {
|
||||
printf("Unable to declare subscriber.\n");
|
||||
exit(-1);
|
||||
PX4_ERR("Unable to declare subscriber for %s", keyexpr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -392,7 +392,10 @@ int ZENOH::setupTopics(px4_pollfd_struct_t *pfds)
|
||||
|
||||
if (rihs_hash != nullptr && _zenoh_subscribers[i] != nullptr &&
|
||||
generate_rmw_zenoh_topic_keyexpr(topic, rihs_hash, type, keyexpr) > 0) {
|
||||
_zenoh_subscribers[i]->declare_subscriber(_s, keyexpr);
|
||||
if (_zenoh_subscribers[i]->declare_subscriber(_s, keyexpr) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ZENOH_RMW_LIVELINESS
|
||||
|
||||
if (generate_rmw_zenoh_topic_liveliness_keyexpr(&self_id, topic, rihs_hash, type, keyexpr, "MS") > 0) {
|
||||
@@ -473,10 +476,15 @@ int ZENOH::setupTopics(px4_pollfd_struct_t *pfds)
|
||||
if (rihs_hash && _zenoh_publishers[i] != nullptr &&
|
||||
generate_rmw_zenoh_topic_keyexpr(topic, rihs_hash, type, keyexpr) > 0) {
|
||||
#ifdef CONFIG_ZENOH_PUB_OPTION_OVERRIDE
|
||||
_zenoh_publishers[i]->declare_publisher(_s, keyexpr, (uint8_t *)&_px4_guid, &pub_opts);
|
||||
z_publisher_options_t *opts = &pub_opts;
|
||||
#else
|
||||
_zenoh_publishers[i]->declare_publisher(_s, keyexpr, (uint8_t *)&_px4_guid, &global_opts);
|
||||
z_publisher_options_t *opts = &global_opts;
|
||||
#endif
|
||||
|
||||
if (_zenoh_publishers[i]->declare_publisher(_s, keyexpr, (uint8_t *)&_px4_guid, opts) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
_zenoh_publishers[i]->setPollFD(&pfds[i]);
|
||||
#ifdef CONFIG_ZENOH_RMW_LIVELINESS
|
||||
|
||||
|
||||
Reference in new issue
Block a user