Skip to content

Commit

Permalink
Fix typo and liveliness subscriber undeclaration
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc committed Nov 14, 2024
1 parent 2865860 commit aed3ac1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions include/zenoh-pico/api/liveliness.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions src/api/liveliness.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions src/net/liveliness.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit aed3ac1

Please sign in to comment.