diff --git a/docs/api.rst b/docs/api.rst index 28d981f89..7271209eb 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -1275,7 +1275,7 @@ Liveliness ======================== Types ----- -.. autoctype:: liveliness.h::z_liveliness_token_options_t_t +.. autoctype:: liveliness.h::z_liveliness_token_options_t .. autoctype:: liveliness.h::z_liveliness_subscriber_options_t .. autoctype:: liveliness.h::z_liveliness_get_options_t diff --git a/include/zenoh-pico/api/liveliness.h b/include/zenoh-pico/api/liveliness.h index 4fa62bb46..43e3012fc 100644 --- a/include/zenoh-pico/api/liveliness.h +++ b/include/zenoh-pico/api/liveliness.h @@ -41,14 +41,14 @@ _Z_OWNED_FUNCTIONS_DEF(liveliness_token) /** * The options for :c:func:`z_liveliness_declare_token()`. */ -typedef struct z_liveliness_token_options_t_t { +typedef struct z_liveliness_token_options_t { uint8_t __dummy; -} z_liveliness_token_options_t_t; +} z_liveliness_token_options_t; /** - * Constructs default value for :c:type:`z_liveliness_token_options_t_t`. + * Constructs default value for :c:type:`z_liveliness_token_options_t`. */ -z_result_t z_liveliness_token_options_t_default(z_liveliness_token_options_t_t *options); +z_result_t z_liveliness_token_options_t_default(z_liveliness_token_options_t *options); /** * Constructs and declares a liveliness token on the network. @@ -66,7 +66,7 @@ z_result_t z_liveliness_token_options_t_default(z_liveliness_token_options_t_t * * ``0`` if put operation is successful, ``negative value`` otherwise. */ z_result_t z_liveliness_declare_token(const z_loaned_session_t *zs, z_owned_liveliness_token_t *token, - const z_loaned_keyexpr_t *keyexpr, const z_liveliness_token_options_t_t *options); + const z_loaned_keyexpr_t *keyexpr, const z_liveliness_token_options_t *options); /** * Undeclare a liveliness token, notifying subscribers of its destruction. diff --git a/src/api/liveliness.c b/src/api/liveliness.c index 3dcbac5f1..4f4139396 100644 --- a/src/api/liveliness.c +++ b/src/api/liveliness.c @@ -48,14 +48,13 @@ void _z_liveliness_token_clear(_z_liveliness_token_t *token) { _Z_OWNED_FUNCTIONS_VALUE_NO_COPY_IMPL(_z_liveliness_token_t, liveliness_token, _z_liveliness_token_check, _z_liveliness_token_null, _z_liveliness_token_clear) -z_result_t z_liveliness_token_options_t_default(z_liveliness_token_options_t_t *options) { +z_result_t z_liveliness_token_options_t_default(z_liveliness_token_options_t *options) { options->__dummy = 0; return _Z_RES_OK; } z_result_t z_liveliness_declare_token(const z_loaned_session_t *zs, z_owned_liveliness_token_t *token, - const z_loaned_keyexpr_t *keyexpr, - const z_liveliness_token_options_t_t *options) { + const z_loaned_keyexpr_t *keyexpr, const z_liveliness_token_options_t *options) { (void)options; _z_keyexpr_t key = _z_update_keyexpr_to_declared(_Z_RC_IN_VAL(zs), *keyexpr); diff --git a/src/net/liveliness.c b/src/net/liveliness.c index ae8ed05ad..19dbfb8f9 100644 --- a/src/net/liveliness.c +++ b/src/net/liveliness.c @@ -13,6 +13,8 @@ #include "zenoh-pico/api/liveliness.h" +#include "zenoh-pico/net/primitives.h" +#include "zenoh-pico/protocol/definitions/interest.h" #include "zenoh-pico/protocol/definitions/network.h" #include "zenoh-pico/protocol/keyexpr.h" #include "zenoh-pico/session/resource.h" @@ -112,6 +114,15 @@ z_result_t _z_undeclare_liveliness_subscriber(_z_subscriber_t *sub) { return _Z_ERR_ENTITY_UNKNOWN; } + _z_interest_t interest = _z_make_interest(NULL, s->_val->_id, 0); + _z_network_message_t n_msg = _z_n_msg_make_interest(interest); + if (_z_send_n_msg(_Z_RC_IN_VAL(&sub->_zn), &n_msg, Z_RELIABILITY_RELIABLE, Z_CONGESTION_CONTROL_BLOCK) != + _Z_RES_OK) { + return _Z_ERR_TRANSPORT_TX_FAILED; + } + _z_n_msg_clear(&n_msg); + + _z_undeclare_resource(_Z_RC_IN_VAL(&sub->_zn), _Z_RC_IN_VAL(s)->_key_id); _z_unregister_subscription(_Z_RC_IN_VAL(&sub->_zn), _Z_SUBSCRIBER_KIND_LIVELINESS_SUBSCRIBER, s); return _Z_RES_OK; }