Skip to content

Commit

Permalink
fix: merge shenanigans
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Nov 15, 2024
1 parent fa12053 commit 2073e6d
Show file tree
Hide file tree
Showing 26 changed files with 116 additions and 163 deletions.
4 changes: 0 additions & 4 deletions include/zenoh-pico/collections/element.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,4 @@ _Z_ELEM_DEFINE(_z_noop, _z_noop_t, _z_noop_size, _z_noop_clear, _z_noop_copy, _z
}
#endif

#ifdef __cplusplus
}
#endif

#endif /* ZENOH_PICO_COLLECTIONS_ELEMENT_H */
6 changes: 3 additions & 3 deletions include/zenoh-pico/net/liveliness.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extern "C" {
#if Z_FEATURE_LIVELINESS == 1

z_result_t _z_declare_liveliness_token(const _z_session_rc_t *zn, _z_liveliness_token_t *ret_token,
_z_keyexpr_t keyexpr);
_z_keyexpr_t *keyexpr);
z_result_t _z_undeclare_liveliness_token(_z_liveliness_token_t *token);

#if Z_FEATURE_SUBSCRIPTION == 1
Expand All @@ -43,7 +43,7 @@ z_result_t _z_undeclare_liveliness_token(_z_liveliness_token_t *token);
* Returns:
* The created :c:type:`_z_subscriber_t` (in null state if the declaration failed).
*/
_z_subscriber_t _z_declare_liveliness_subscriber(const _z_session_rc_t *zn, _z_keyexpr_t keyexpr,
_z_subscriber_t _z_declare_liveliness_subscriber(const _z_session_rc_t *zn, _z_keyexpr_t *keyexpr,
_z_closure_sample_callback_t callback, _z_drop_handler_t dropper,
bool history, void *arg);

Expand Down Expand Up @@ -71,7 +71,7 @@ z_result_t _z_undeclare_liveliness_subscriber(_z_subscriber_t *sub);
* arg: A pointer that will be passed to the **callback** on each call.
* timeout_ms: The timeout value of this query.
*/
z_result_t _z_liveliness_query(_z_session_t *zn, _z_keyexpr_t keyexpr, _z_closure_reply_callback_t callback,
z_result_t _z_liveliness_query(_z_session_t *zn, const _z_keyexpr_t *keyexpr, _z_closure_reply_callback_t callback,
_z_drop_handler_t dropper, void *arg, uint64_t timeout_ms);
#endif // Z_FEATURE_QUERY == 1

Expand Down
4 changes: 0 additions & 4 deletions include/zenoh-pico/net/publish.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,4 @@ void _z_publisher_free(_z_publisher_t **pub);
}
#endif

#ifdef __cplusplus
}
#endif

#endif /* INCLUDE_ZENOH_PICO_NET_PUBLISH_H */
4 changes: 0 additions & 4 deletions include/zenoh-pico/net/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,4 @@ void _z_queryable_free(_z_queryable_t **qbl);
}
#endif

#ifdef __cplusplus
}
#endif

#endif /* ZENOH_PICO_QUERY_NETAPI_H */
2 changes: 1 addition & 1 deletion include/zenoh-pico/net/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#include "zenoh-pico/collections/list.h"
#include "zenoh-pico/config.h"
#include "zenoh-pico/protocol/core.h"
#include "zenoh-pico/session/queryable.h"
#include "zenoh-pico/session/liveliness.h"
#include "zenoh-pico/session/queryable.h"
#include "zenoh-pico/session/session.h"
#include "zenoh-pico/session/subscription.h"
#include "zenoh-pico/utils/config.h"
Expand Down
4 changes: 0 additions & 4 deletions include/zenoh-pico/net/subscribe.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,4 @@ void _z_subscriber_free(_z_subscriber_t **sub);
}
#endif

#ifdef __cplusplus
}
#endif

#endif /* ZENOH_PICO_SUBSCRIBE_NETAPI_H */
4 changes: 0 additions & 4 deletions include/zenoh-pico/protocol/codec/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,4 @@ z_result_t _z_network_message_decode(_z_network_message_t *msg, _z_zbuf_t *zbf,
}
#endif

#ifdef __cplusplus
}
#endif

#endif /* INCLUDE_ZENOH_PICO_PROTOCOL_CODEC_NETWORK_H */
4 changes: 0 additions & 4 deletions include/zenoh-pico/protocol/definitions/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,4 @@ z_result_t _z_n_msg_copy(_z_network_message_t *dst, const _z_network_message_t *
}
#endif

#ifdef __cplusplus
}
#endif

#endif /* INCLUDE_ZENOH_PICO_PROTOCOL_DEFINITIONS_NETWORK_H */
8 changes: 4 additions & 4 deletions include/zenoh-pico/session/liveliness.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ void _z_liveliness_pending_query_copy(_z_liveliness_pending_query_t *dst, const
_z_liveliness_pending_query_t *_z_liveliness_pending_query_clone(const _z_liveliness_pending_query_t *src);

_Z_ELEM_DEFINE(_z_liveliness_pending_query, _z_liveliness_pending_query_t, _z_noop_size,
_z_liveliness_pending_query_clear, _z_liveliness_pending_query_copy)
_z_liveliness_pending_query_clear, _z_liveliness_pending_query_copy, _z_noop_move)
_Z_INT_MAP_DEFINE(_z_liveliness_pending_query, _z_liveliness_pending_query_t)

uint32_t _z_liveliness_get_query_id(_z_session_t *zn);

z_result_t _z_liveliness_register_token(_z_session_t *zn, uint32_t id, const _z_keyexpr_t keyexpr);
z_result_t _z_liveliness_register_token(_z_session_t *zn, uint32_t id, const _z_keyexpr_t *keyexpr);
void _z_liveliness_unregister_token(_z_session_t *zn, uint32_t id);

#if Z_FEATURE_SUBSCRIPTION == 1
z_result_t _z_liveliness_subscription_declare(_z_session_t *zn, uint32_t id, const _z_keyexpr_t keyexpr,
z_result_t _z_liveliness_subscription_declare(_z_session_t *zn, uint32_t id, const _z_keyexpr_t *keyexpr,
const _z_timestamp_t *timestamp);
z_result_t _z_liveliness_subscription_undeclare(_z_session_t *zn, uint32_t id, const _z_timestamp_t *timestamp);
z_result_t _z_liveliness_subscription_trigger_history(_z_session_t *zn, _z_keyexpr_t keyexpr);
z_result_t _z_liveliness_subscription_trigger_history(_z_session_t *zn, const _z_keyexpr_t *keyexpr);
#endif

#if Z_FEATURE_QUERY == 1
Expand Down
2 changes: 1 addition & 1 deletion include/zenoh-pico/session/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ size_t _z_resource_size(_z_resource_t *p);
_Z_ELEM_DEFINE(_z_resource, _z_resource_t, _z_noop_size, _z_resource_clear, _z_resource_copy, _z_noop_move)
_Z_LIST_DEFINE(_z_resource, _z_resource_t)

_Z_ELEM_DEFINE(_z_keyexpr, _z_keyexpr_t, _z_keyexpr_size, _z_keyexpr_clear, _z_keyexpr_copy)
_Z_ELEM_DEFINE(_z_keyexpr, _z_keyexpr_t, _z_keyexpr_size, _z_keyexpr_clear, _z_keyexpr_copy, _z_keyexpr_move)
_Z_INT_MAP_DEFINE(_z_keyexpr, _z_keyexpr_t)

// Forward declaration to avoid cyclical include
Expand Down
2 changes: 1 addition & 1 deletion include/zenoh-pico/session/subscription.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ typedef struct {

/*------------------ Subscription ------------------*/
z_result_t _z_trigger_subscriptions_put(_z_session_t *zn, _z_keyexpr_t *keyexpr, _z_bytes_t *payload,
_z_encoding_t *encoding, const _z_n_qos_t qos, const _z_timestamp_t *timestamp,
_z_encoding_t *encoding, const _z_timestamp_t *timestamp, const _z_n_qos_t qos,
_z_bytes_t *attachment, z_reliability_t reliability);

z_result_t _z_trigger_subscriptions_del(_z_session_t *zn, _z_keyexpr_t *keyexpr, const _z_timestamp_t *timestamp,
Expand Down
4 changes: 0 additions & 4 deletions include/zenoh-pico/session/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,4 @@ static inline void _z_session_mutex_unlock(_z_session_t *zn) { _ZP_UNUSED(zn); }
}
#endif

#ifdef __cplusplus
}
#endif

#endif /* INCLUDE_ZENOH_PICO_SESSION_UTILS_H */
4 changes: 0 additions & 4 deletions include/zenoh-pico/transport/common/tx.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,4 @@ z_result_t _z_send_n_batch(_z_session_t *zn, z_congestion_control_t cong_ctrl);
}
#endif

#ifdef __cplusplus
}
#endif

#endif /* ZENOH_PICO_TRANSPORT_TX_H */
4 changes: 0 additions & 4 deletions include/zenoh-pico/transport/multicast/rx.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,4 @@ z_result_t _z_multicast_update_rx_buffer(_z_transport_multicast_t *ztm);
}
#endif

#ifdef __cplusplus
}
#endif

#endif /* ZENOH_PICO_TRANSPORT_LINK_RX_H */
4 changes: 0 additions & 4 deletions include/zenoh-pico/transport/raweth/rx.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,4 @@ z_result_t _z_raweth_update_rx_buff(_z_transport_multicast_t *ztm);
}
#endif

#ifdef __cplusplus
}
#endif

#endif /* ZENOH_PICO_RAWETH_RX_H */
4 changes: 0 additions & 4 deletions include/zenoh-pico/transport/raweth/tx.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,4 @@ z_result_t _z_raweth_send_t_msg(_z_transport_common_t *ztc, const _z_transport_m
}
#endif

#ifdef __cplusplus
}
#endif

#endif /* ZENOH_PICO_RAWETH_TX_H */
4 changes: 0 additions & 4 deletions include/zenoh-pico/transport/unicast/rx.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,4 @@ z_result_t _z_unicast_update_rx_buffer(_z_transport_unicast_t *ztu);
}
#endif

#ifdef __cplusplus
}
#endif

#endif /* ZENOH_PICO_UNICAST_RX_H */
8 changes: 4 additions & 4 deletions src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -830,9 +830,9 @@ z_result_t z_put(const z_loaned_session_t *zs, const z_loaned_keyexpr_t *keyexpr
_z_timestamp_t local_timestamp = (opt.timestamp != NULL) ? *opt.timestamp : _z_timestamp_null();
_z_encoding_t local_encoding = (opt.encoding != NULL) ? &opt.encoding->_this._val : _z_encoding_null();
_z_trigger_subscriptions_put(
_Z_RC_IN_VAL(zs), &keyexpr_aliased, &payload_bytes, &local_encoding,
_Z_RC_IN_VAL(zs), &keyexpr_aliased, &payload_bytes, &local_encoding, , &local_timestamp,
_z_n_qos_make(opt.is_express, opt.congestion_control == Z_CONGESTION_CONTROL_BLOCK, opt.priority),
&local_timestamp, &attachment_bytes, reliability);
&attachment_bytes, reliability);
#endif
// Clean-up
z_encoding_drop(opt.encoding);
Expand Down Expand Up @@ -977,9 +977,9 @@ z_result_t z_publisher_put(const z_loaned_publisher_t *pub, z_moved_bytes_t *pay
#if Z_FEATURE_LOCAL_SUBSCRIBER == 1
_z_timestamp_t local_timestamp = (opt.timestamp != NULL) ? *opt.timestamp : _z_timestamp_null();
_z_trigger_subscriptions_put(
session, &pub_keyexpr, &payload_bytes, &encoding,
session, &pub_keyexpr, &payload_bytes, &encoding, &local_timestamp,
_z_n_qos_make(pub->_is_express, pub->_congestion_control == Z_CONGESTION_CONTROL_BLOCK, pub->_priority),
&local_timestamp, &attachment_bytes, reliability);
&attachment_bytes, reliability);
#endif
} else {
ret = _Z_ERR_SESSION_CLOSED;
Expand Down
8 changes: 4 additions & 4 deletions src/api/liveliness.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ z_result_t z_liveliness_declare_token(const z_loaned_session_t *zs, z_owned_live

_z_keyexpr_t key = _z_update_keyexpr_to_declared(_Z_RC_IN_VAL(zs), *keyexpr);

return _z_declare_liveliness_token(zs, &token->_val, key);
return _z_declare_liveliness_token(zs, &token->_val, &key);
}

z_result_t z_liveliness_undeclare_token(z_moved_liveliness_token_t *token) {
Expand Down Expand Up @@ -89,7 +89,7 @@ z_result_t z_liveliness_declare_subscriber(const z_loaned_session_t *zs, z_owned

_z_keyexpr_t key = _z_update_keyexpr_to_declared(_Z_RC_IN_VAL(zs), *keyexpr);

_z_subscriber_t int_sub = _z_declare_liveliness_subscriber(zs, key, callback->_this._val.call,
_z_subscriber_t int_sub = _z_declare_liveliness_subscriber(zs, &key, callback->_this._val.call,
callback->_this._val.drop, opt.history, ctx);

z_internal_closure_sample_null(&callback->_this);
Expand All @@ -100,7 +100,7 @@ z_result_t z_liveliness_declare_subscriber(const z_loaned_session_t *zs, z_owned
}

if (opt.history) {
z_result_t ret = _z_liveliness_subscription_trigger_history(_Z_RC_IN_VAL(zs), *keyexpr);
z_result_t ret = _z_liveliness_subscription_trigger_history(_Z_RC_IN_VAL(zs), keyexpr);
if (ret != _Z_RES_OK) {
return ret;
}
Expand Down Expand Up @@ -132,7 +132,7 @@ z_result_t z_liveliness_get(const z_loaned_session_t *zs, const z_loaned_keyexpr
opt = *options;
}

ret = _z_liveliness_query(_Z_RC_IN_VAL(zs), *keyexpr, callback->_this._val.call, callback->_this._val.drop, ctx,
ret = _z_liveliness_query(_Z_RC_IN_VAL(zs), keyexpr, callback->_this._val.call, callback->_this._val.drop, ctx,
opt.timeout_ms);

z_internal_closure_reply_null(
Expand Down
23 changes: 12 additions & 11 deletions src/net/liveliness.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,28 @@
#include "zenoh-pico/session/session.h"
#include "zenoh-pico/session/subscription.h"
#include "zenoh-pico/session/utils.h"
#include "zenoh-pico/transport/common/tx.h"
#include "zenoh-pico/utils/result.h"

#if Z_FEATURE_LIVELINESS == 1

/**************** Liveliness Token ****************/

z_result_t _z_declare_liveliness_token(const _z_session_rc_t *zn, _z_liveliness_token_t *ret_token,
_z_keyexpr_t keyexpr) {
_z_keyexpr_t *keyexpr) {
z_result_t ret;

uint32_t id = _z_get_entity_id(_Z_RC_IN_VAL(zn));

_z_declaration_t declaration = _z_make_decl_token(&keyexpr, id);
_z_declaration_t declaration = _z_make_decl_token(keyexpr, id);
_z_network_message_t n_msg = _z_n_msg_make_declare(declaration, false, 0);
ret = _z_send_n_msg(_Z_RC_IN_VAL(zn), &n_msg, Z_RELIABILITY_RELIABLE, Z_CONGESTION_CONTROL_BLOCK);
_z_n_msg_clear(&n_msg);

_z_liveliness_register_token(_Z_RC_IN_VAL(zn), id, keyexpr);

ret_token->_id = id;
_z_keyexpr_move(&ret_token->_key, &keyexpr);
_z_keyexpr_move(&ret_token->_key, keyexpr);
ret_token->_zn = _z_session_rc_clone_as_weak(zn);
return ret;
}
Expand All @@ -66,13 +67,13 @@ z_result_t _z_undeclare_liveliness_token(_z_liveliness_token_t *token) {
/**************** Liveliness Subscriber ****************/

#if Z_FEATURE_SUBSCRIPTION == 1
_z_subscriber_t _z_declare_liveliness_subscriber(const _z_session_rc_t *zn, _z_keyexpr_t keyexpr,
_z_subscriber_t _z_declare_liveliness_subscriber(const _z_session_rc_t *zn, _z_keyexpr_t *keyexpr,
_z_closure_sample_callback_t callback, _z_drop_handler_t dropper,
bool history, void *arg) {
_z_subscription_t s;
s._id = _z_get_entity_id(_Z_RC_IN_VAL(zn));
s._key_id = keyexpr._id;
s._key = _z_get_expanded_key_from_key(_Z_RC_IN_VAL(zn), &keyexpr);
s._key_id = keyexpr->_id;
s._key = _z_get_expanded_key_from_key(_Z_RC_IN_VAL(zn), keyexpr);
s._callback = callback;
s._dropper = dropper;
s._arg = arg;
Expand All @@ -88,7 +89,7 @@ _z_subscriber_t _z_declare_liveliness_subscriber(const _z_session_rc_t *zn, _z_k
// Build the declare message to send on the wire
uint8_t mode = history ? (_Z_INTEREST_FLAG_CURRENT | _Z_INTEREST_FLAG_FUTURE) : _Z_INTEREST_FLAG_FUTURE;
_z_interest_t interest = _z_make_interest(
&keyexpr, s._id, _Z_INTEREST_FLAG_KEYEXPRS | _Z_INTEREST_FLAG_TOKENS | _Z_INTEREST_FLAG_RESTRICTED | mode);
keyexpr, s._id, _Z_INTEREST_FLAG_KEYEXPRS | _Z_INTEREST_FLAG_TOKENS | _Z_INTEREST_FLAG_RESTRICTED | mode);

_z_network_message_t n_msg = _z_n_msg_make_interest(interest);
if (_z_send_n_msg(_Z_RC_IN_VAL(zn), &n_msg, Z_RELIABILITY_RELIABLE, Z_CONGESTION_CONTROL_BLOCK) != _Z_RES_OK) {
Expand Down Expand Up @@ -131,7 +132,7 @@ z_result_t _z_undeclare_liveliness_subscriber(_z_subscriber_t *sub) {
/**************** Liveliness Query ****************/

#if Z_FEATURE_QUERY == 1
z_result_t _z_liveliness_query(_z_session_t *zn, _z_keyexpr_t keyexpr, _z_closure_reply_callback_t callback,
z_result_t _z_liveliness_query(_z_session_t *zn, const _z_keyexpr_t *keyexpr, _z_closure_reply_callback_t callback,
_z_drop_handler_t dropper, void *arg, uint64_t timeout_ms) {
z_result_t ret = _Z_RES_OK;

Expand All @@ -140,16 +141,16 @@ z_result_t _z_liveliness_query(_z_session_t *zn, _z_keyexpr_t keyexpr, _z_closur
(_z_liveliness_pending_query_t *)z_malloc(sizeof(_z_liveliness_pending_query_t));
if (pq != NULL) {
uint32_t id = _z_liveliness_get_query_id(zn);
pq->_key = _z_get_expanded_key_from_key(zn, &keyexpr);
pq->_key = _z_get_expanded_key_from_key(zn, keyexpr);
pq->_callback = callback;
pq->_dropper = dropper;
pq->_arg = arg;

ret = _z_liveliness_register_pending_query(zn, id, pq);
if (ret == _Z_RES_OK) {
_ZP_UNUSED(timeout_ms); // Current interest in pico don't support timeout

_z_interest_t interest = _z_make_interest(&keyexpr, id,
_z_keyexpr_t key = _z_keyexpr_alias(*keyexpr);
_z_interest_t interest = _z_make_interest(&key, id,
_Z_INTEREST_FLAG_KEYEXPRS | _Z_INTEREST_FLAG_TOKENS |
_Z_INTEREST_FLAG_RESTRICTED | _Z_INTEREST_FLAG_CURRENT);

Expand Down
4 changes: 2 additions & 2 deletions src/session/interest.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ static z_result_t _z_interest_send_decl_queryable(_z_session_t *zn, uint32_t int

#if Z_FEATURE_LIVELINESS == 1
static z_result_t _z_interest_send_decl_token(_z_session_t *zn, uint32_t interest_id) {
_zp_session_lock_mutex(zn);
_z_session_mutex_lock(zn);
_z_keyexpr_intmap_t token_list = _z_keyexpr_intmap_clone(&zn->_local_tokens);
_zp_session_unlock_mutex(zn);
_z_session_mutex_unlock(zn);
_z_keyexpr_intmap_iterator_t iter = _z_keyexpr_intmap_iterator_make(&token_list);
while (_z_keyexpr_intmap_iterator_next(&iter)) {
// Build the declare message to send on the wire
Expand Down
Loading

0 comments on commit 2073e6d

Please sign in to comment.