From eb1e7cf5b5e90a4df5768a3661e60b527cde2f85 Mon Sep 17 00:00:00 2001 From: Jean-Roland Gosse Date: Tue, 19 Nov 2024 16:42:11 +0100 Subject: [PATCH] Add corrections on 1.1 (#791) * Update closure handlers documentaion (#736) * Rename closure callback/dropper types (#739) * Remove legacy z_zint_t from public API (#741) * Add `export "C"` for all header files (#740) * Add `export "C"` for proper closures callbacks export * Add `export "C"` for all headers * add serialize from substr functions (#742) * Rename z_loaned_hello_handler_t to z_closure_hello_callback_t (#743) * Mark z_reply_replier_id as unstable (#745) * Add documentation about logging (#744) * Update README.md (#746) * hardcode clang-format runner to Ubuntu24.04 (#748) * fix build granularity (#747) * fix: badly named constant (#750) * fix packages * fix: update debian packaging - include libzenohpico.so in debian package - change the package name to libzenohpico in line with libzenohc - set correct debian version for pre releases - fix wrong version used in Release mode * fix: debian dev package name * fix: package version for releases (#753) * fix: debian_version for official releases otherwise they would be undefined * fix: align cpack version with zenoh-c * chore: review comments move cpack version closer to where it's used * build shared lib for packages instead of static one (#757) * Fix z_task cleanup for platforms with pthread support (#759) * Fix read/lease task cleanup (#760) * Align ID string representation with zenoh (lowercase) (#761) * Remove default parameters from z_closure (#755) * build both libraries:shared and static when packaging; (#766) add static library to dev package; * Publish debian packages (#769) * fix: add workflow to release debian packages * fix: align with zenoh-c - update package names - set version string in the same way - set DEBARCH/RPMARCH - set CPACK_PACKAGE_FILE_NAME - add -j to zip archive to not include parent folder * fix: use CPACK_PACKAGE_NAME * fix: pass package name to all build targets * fix: Don't tag release branch during dry-run * Replace exit with return in zephyr examples (#774) * Add platform_common.c to zephyr CMakeLists.txt file * Rework Zenoh ID conversion * chore: Update org secrets (#782) As per eclipse-zenoh/.eclipsefdn#18, secrets were updated to follow eclipse foundation naming convention. * Implement liveliness support (#632) * Mark liveliness API as unstable and disable by default * Fix typo (#787) * fix: correct 1.1 issues * feat: add zp_batch_flush * fix: switch to #if 0 to deactivate tcp function --------- Co-authored-by: Alexander Bushnev Co-authored-by: DenisBiryukov91 <155981813+DenisBiryukov91@users.noreply.github.com> Co-authored-by: Denis Biryukov Co-authored-by: Diogo Mendes Matsubara Co-authored-by: Luca Cominardi --- CMakeLists.txt | 8 +++++++- docs/api.rst | 2 +- include/zenoh-pico/api/liveliness.h | 2 +- include/zenoh-pico/api/primitives.h | 19 +++++++++++++++---- include/zenoh-pico/config.h | 6 +++--- include/zenoh-pico/net/primitives.h | 4 ---- src/api/api.c | 9 +++++++++ src/transport/multicast/rx.c | 2 -- src/transport/unicast/rx.c | 2 -- src/transport/unicast/transport.c | 12 ++++++++++++ 10 files changed, 48 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7920bdc68..ba8f552b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,7 +216,7 @@ set(Z_FEATURE_PUBLICATION 1 CACHE STRING "Toggle publication feature") set(Z_FEATURE_SUBSCRIPTION 1 CACHE STRING "Toggle subscription feature") set(Z_FEATURE_QUERY 1 CACHE STRING "Toggle query feature") set(Z_FEATURE_QUERYABLE 1 CACHE STRING "Toggle queryable feature") -set(Z_FEATURE_LIVELINESS 1 CACHE STRING "Toggle liveliness feature") +set(Z_FEATURE_LIVELINESS 0 CACHE STRING "Toggle liveliness feature") set(Z_FEATURE_INTEREST 1 CACHE STRING "Toggle interests") set(Z_FEATURE_FRAGMENTATION 1 CACHE STRING "Toggle fragmentation") set(Z_FEATURE_ENCODING_VALUES 1 CACHE STRING "Toggle encoding values") @@ -239,6 +239,12 @@ set(Z_FEATURE_PUBLISHER_SESSION_CHECK 1 CACHE STRING "Toggle publisher session c set(Z_FEATURE_BATCHING 1 CACHE STRING "Toggle batching") set(Z_FEATURE_RX_CACHE 0 CACHE STRING "Toggle RX_CACHE") +# Add a warning message if someone tries to enable Z_FEATURE_LIVELINESS directly +if(Z_FEATURE_LIVELINESS AND NOT Z_FEATURE_UNSTABLE_API) + message(WARNING "Z_FEATURE_LIVELINESS can only be enabled when Z_FEATURE_UNSTABLE_API is also enabled. Disabling Z_FEATURE_LIVELINESS.") + set(Z_FEATURE_LIVELINESS 0 CACHE STRING "Toggle liveliness feature" FORCE) +endif() + add_compile_definitions("Z_BUILD_DEBUG=$") message(STATUS "Building with feature confing:\n\ * UNSTABLE_API: ${Z_FEATURE_UNSTABLE_API}\n\ diff --git a/docs/api.rst b/docs/api.rst index 7271209eb..1a3893a0b 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -1289,7 +1289,7 @@ See details at :ref:`owned_types_concept` Functions --------- -.. autocfunction:: liveliness.h::z_liveliness_token_options_t_default +.. autocfunction:: liveliness.h::z_liveliness_token_options_default .. autocfunction:: liveliness.h::z_liveliness_declare_token .. autocfunction:: liveliness.h::z_liveliness_undeclare_token .. autocfunction:: liveliness.h::z_liveliness_subscriber_options_default diff --git a/include/zenoh-pico/api/liveliness.h b/include/zenoh-pico/api/liveliness.h index 43e3012fc..d3751bc4f 100644 --- a/include/zenoh-pico/api/liveliness.h +++ b/include/zenoh-pico/api/liveliness.h @@ -48,7 +48,7 @@ typedef struct z_liveliness_token_options_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 *options); +z_result_t z_liveliness_token_options_default(z_liveliness_token_options_t *options); /** * Constructs and declares a liveliness token on the network. diff --git a/include/zenoh-pico/api/primitives.h b/include/zenoh-pico/api/primitives.h index b28f3ec6c..3da9ab8f0 100644 --- a/include/zenoh-pico/api/primitives.h +++ b/include/zenoh-pico/api/primitives.h @@ -2063,9 +2063,9 @@ const z_loaned_keyexpr_t *z_subscriber_keyexpr(const z_loaned_subscriber_t *subs #ifdef Z_FEATURE_UNSTABLE_API #if Z_FEATURE_BATCHING == 1 /** - * Activate the batching mechanism. - * Any message that would have been sent on the network by a subsequent api call (e.g z_put, z_get) - * will be instead stored until the batch is full or batching is stopped with :c:func:`zp_batch_stop`. + * Activate the batching mechanism, any message that would have been sent on the network by a subsequent api call (e.g + * z_put, z_get) will be instead stored until the batch is full, flushed with :c:func:`zp_batch_flush` or batching is + * stopped with :c:func:`zp_batch_stop`. * * Parameters: * zs: Pointer to a :c:type:`z_loaned_session_t` that will start batching messages. @@ -2076,7 +2076,18 @@ const z_loaned_keyexpr_t *z_subscriber_keyexpr(const z_loaned_subscriber_t *subs z_result_t zp_batch_start(const z_loaned_session_t *zs); /** - * Deactivate the batching mechanism and flush the remaining messages. + * Send the currently batched messages on the network. + * + * Parameters: + * zs: Pointer to a :c:type:`z_loaned_session_t` that will send its batched messages. + * + * Return: + * ``0`` if batch successfully sent, ``negative value`` otherwise. + */ +z_result_t zp_batch_flush(const z_loaned_session_t *zs); + +/** + * Deactivate the batching mechanism and send the currently batched on the network. * * Parameters: * zs: Pointer to a :c:type:`z_loaned_session_t` that will stop batching messages. diff --git a/include/zenoh-pico/config.h b/include/zenoh-pico/config.h index 4e4ae9f99..840dff4ee 100644 --- a/include/zenoh-pico/config.h +++ b/include/zenoh-pico/config.h @@ -27,7 +27,7 @@ #define Z_FEATURE_SUBSCRIPTION 1 #define Z_FEATURE_QUERY 1 #define Z_FEATURE_QUERYABLE 1 -#define Z_FEATURE_LIVELINESS 1 +#define Z_FEATURE_LIVELINESS 0 #define Z_FEATURE_RAWETH_TRANSPORT 0 #define Z_FEATURE_INTEREST 1 #define Z_FEATURE_DYNAMIC_MEMORY_ALLOCATION 0 @@ -44,9 +44,9 @@ #define Z_FEATURE_ENCODING_VALUES 1 #define Z_FEATURE_TCP_NODELAY 1 #define Z_FEATURE_LOCAL_SUBSCRIBER 0 -#define Z_FEATURE_PUBLISHER_SESSION_CHECK 0 +#define Z_FEATURE_PUBLISHER_SESSION_CHECK 1 #define Z_FEATURE_BATCHING 1 -#define Z_FEATURE_RX_CACHE 1 +#define Z_FEATURE_RX_CACHE 0 // End of CMake generation /*------------------ Runtime configuration properties ------------------*/ diff --git a/include/zenoh-pico/net/primitives.h b/include/zenoh-pico/net/primitives.h index 53db370e1..b53a8f4e4 100644 --- a/include/zenoh-pico/net/primitives.h +++ b/include/zenoh-pico/net/primitives.h @@ -29,10 +29,6 @@ extern "C" { #endif -#ifdef __cplusplus -extern "C" { -#endif - /*------------------ Discovery ------------------*/ /** diff --git a/src/api/api.c b/src/api/api.c index 40f3e5ed3..c4b827209 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -1432,6 +1432,15 @@ z_result_t zp_batch_start(const z_loaned_session_t *zs) { return _z_transport_start_batching(&session->_tp) ? _Z_RES_OK : _Z_ERR_GENERIC; } +z_result_t zp_batch_flush(const z_loaned_session_t *zs) { + _z_session_t *session = _Z_RC_IN_VAL(zs); + if (_Z_RC_IS_NULL(zs)) { + return _Z_ERR_SESSION_CLOSED; + } + // Send current batch + return _z_send_n_batch(session, Z_CONGESTION_CONTROL_DEFAULT); +} + z_result_t zp_batch_stop(const z_loaned_session_t *zs) { _z_session_t *session = _Z_RC_IN_VAL(zs); if (_Z_RC_IS_NULL(zs)) { diff --git a/src/transport/multicast/rx.c b/src/transport/multicast/rx.c index 1ab13f161..dc64460e4 100644 --- a/src/transport/multicast/rx.c +++ b/src/transport/multicast/rx.c @@ -252,8 +252,6 @@ z_result_t _z_multicast_handle_transport_message(_z_transport_multicast_t *ztm, _Z_INFO("Failed to decode defragmented message"); ret = _Z_ERR_MESSAGE_DESERIALIZATION_FAILED; } - // Fragmented messages must be cleared. Non-fragmented messages are released with their transport. - _z_msg_clear(&zm); // Free the decoding buffer _z_zbuf_clear(&zbf); *dbuf_state = _Z_DBUF_STATE_NULL; diff --git a/src/transport/unicast/rx.c b/src/transport/unicast/rx.c index 628f2815d..d90b59f38 100644 --- a/src/transport/unicast/rx.c +++ b/src/transport/unicast/rx.c @@ -204,8 +204,6 @@ z_result_t _z_unicast_handle_transport_message(_z_transport_unicast_t *ztu, _z_t _Z_INFO("Failed to decode defragmented message"); ret = _Z_ERR_MESSAGE_DESERIALIZATION_FAILED; } - // Fragmented messages must be cleared. Non-fragmented messages are released with their transport. - _z_msg_clear(&zm); // Free the decoding buffer _z_zbuf_clear(&zbf); *dbuf_state = _Z_DBUF_STATE_NULL; diff --git a/src/transport/unicast/transport.c b/src/transport/unicast/transport.c index 9ae20a38c..64a1d6540 100644 --- a/src/transport/unicast/transport.c +++ b/src/transport/unicast/transport.c @@ -217,6 +217,8 @@ static z_result_t _z_unicast_handshake_client(_z_transport_unicast_establish_par return _Z_RES_OK; } +// TODO: Activate if we add peer unicast support +#if 0 static z_result_t _z_unicast_handshake_listener(_z_transport_unicast_establish_param_t *param, const _z_link_t *zl, const _z_id_t *local_zid, enum z_whatami_t whatami) { // Read t message from link @@ -293,6 +295,16 @@ static z_result_t _z_unicast_handshake_listener(_z_transport_unicast_establish_p // Handshake finished return _Z_RES_OK; } +#else +static z_result_t _z_unicast_handshake_listener(_z_transport_unicast_establish_param_t *param, const _z_link_t *zl, + const _z_id_t *local_zid, enum z_whatami_t whatami) { + _ZP_UNUSED(param); + _ZP_UNUSED(zl); + _ZP_UNUSED(local_zid); + _ZP_UNUSED(whatami); + return _Z_ERR_TRANSPORT_OPEN_FAILED; +} +#endif z_result_t _z_unicast_open_client(_z_transport_unicast_establish_param_t *param, const _z_link_t *zl, const _z_id_t *local_zid) {