From 88433678bc06eeffa4cffe91a9fdaf09bcb54b87 Mon Sep 17 00:00:00 2001 From: DenisBiryukov91 <155981813+DenisBiryukov91@users.noreply.github.com> Date: Thu, 11 Jul 2024 17:12:07 +0200 Subject: [PATCH] Fix session close not to close session independently of refcount (#529) * Fix session drop to account for ref count; Automatically stop read/lease task on session drop; * add check for multi-thread support --- examples/espidf/z_get.c | 3 --- examples/espidf/z_pub.c | 4 ---- examples/espidf/z_pull.c | 4 ---- examples/espidf/z_queryable.c | 4 ---- examples/espidf/z_sub.c | 4 ---- examples/freertos_plus_tcp/z_get.c | 4 ---- examples/freertos_plus_tcp/z_pub.c | 2 -- examples/freertos_plus_tcp/z_pull.c | 4 ---- examples/freertos_plus_tcp/z_put.c | 4 ---- examples/freertos_plus_tcp/z_queryable.c | 4 ---- examples/freertos_plus_tcp/z_sub.c | 4 ---- examples/mbed/z_get.cpp | 3 --- examples/mbed/z_pub.cpp | 4 ---- examples/mbed/z_pull.cpp | 4 ---- examples/mbed/z_queryable.cpp | 4 ---- examples/mbed/z_sub.cpp | 4 ---- examples/unix/c11/z_get.c | 4 ---- examples/unix/c11/z_get_attachment.c | 4 ---- examples/unix/c11/z_get_channel.c | 4 ---- examples/unix/c11/z_info.c | 4 ---- examples/unix/c11/z_ping.c | 3 --- examples/unix/c11/z_pong.c | 3 --- examples/unix/c11/z_pub.c | 2 -- examples/unix/c11/z_pub_attachment.c | 2 -- examples/unix/c11/z_pub_thr.c | 2 -- examples/unix/c11/z_pull.c | 4 ---- examples/unix/c11/z_put.c | 5 ----- examples/unix/c11/z_queryable.c | 4 ---- examples/unix/c11/z_queryable_attachment.c | 4 ---- examples/unix/c11/z_queryable_channel.c | 4 ---- examples/unix/c11/z_sub.c | 2 -- examples/unix/c11/z_sub_attachment.c | 2 -- examples/unix/c11/z_sub_channel.c | 4 ---- examples/unix/c11/z_sub_thr.c | 2 -- examples/unix/c99/z_get.c | 4 ---- examples/unix/c99/z_info.c | 4 ---- examples/unix/c99/z_ping.c | 3 --- examples/unix/c99/z_pong.c | 3 --- examples/unix/c99/z_pub.c | 2 -- examples/unix/c99/z_pull.c | 4 ---- examples/unix/c99/z_put.c | 4 ---- examples/unix/c99/z_queryable.c | 4 ---- examples/unix/c99/z_sub.c | 4 ---- examples/windows/z_get.c | 4 ---- examples/windows/z_info.c | 4 ---- examples/windows/z_ping.c | 3 --- examples/windows/z_pong.c | 3 --- examples/windows/z_pull.c | 4 ---- examples/windows/z_put.c | 4 ---- examples/windows/z_queryable.c | 4 ---- examples/windows/z_sub.c | 4 ---- examples/zephyr/z_get.c | 3 --- examples/zephyr/z_pub.c | 4 ---- examples/zephyr/z_pull.c | 4 ---- examples/zephyr/z_queryable.c | 4 ---- examples/zephyr/z_sub.c | 4 ---- src/api/api.c | 1 - src/session/utils.c | 6 +++++- tests/z_client_test.c | 9 --------- tests/z_peer_multicast_test.c | 9 --------- tests/z_perf_rx.c | 2 -- tests/z_perf_tx.c | 2 -- tests/z_session_test.c | 4 ---- tests/z_test_fragment_rx.c | 2 -- tests/z_test_fragment_tx.c | 2 -- zenohpico.pc | 2 +- 66 files changed, 6 insertions(+), 233 deletions(-) diff --git a/examples/espidf/z_get.c b/examples/espidf/z_get.c index d33e3d2c9..966c7e421 100644 --- a/examples/espidf/z_get.c +++ b/examples/espidf/z_get.c @@ -178,9 +178,6 @@ void app_main() { } printf("Closing Zenoh Session..."); - // Stop the receive and the session lease loop for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); z_close(z_move(s)); printf("OK!\n"); diff --git a/examples/espidf/z_pub.c b/examples/espidf/z_pub.c index 28638c565..df5bc7def 100644 --- a/examples/espidf/z_pub.c +++ b/examples/espidf/z_pub.c @@ -165,10 +165,6 @@ void app_main() { printf("Closing Zenoh Session..."); z_undeclare_publisher(z_move(pub)); - // Stop the receive and the session lease loop for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); printf("OK!\n"); } diff --git a/examples/espidf/z_pull.c b/examples/espidf/z_pull.c index 999dffdf0..c00064347 100644 --- a/examples/espidf/z_pull.c +++ b/examples/espidf/z_pull.c @@ -171,10 +171,6 @@ void app_main() { // z_undeclare_pull_subscriber(z_move(sub)); printf("Pull Subscriber not supported... exiting\n"); - // Stop the receive and the session lease loop for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); printf("OK!\n"); } diff --git a/examples/espidf/z_queryable.c b/examples/espidf/z_queryable.c index 1c9d79068..e62525dd3 100644 --- a/examples/espidf/z_queryable.c +++ b/examples/espidf/z_queryable.c @@ -186,10 +186,6 @@ void app_main() { printf("Closing Zenoh Session..."); z_undeclare_queryable(z_move(qable)); - // Stop the receive and the session lease loop for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); printf("OK!\n"); } diff --git a/examples/espidf/z_sub.c b/examples/espidf/z_sub.c index 2fbec348a..cc9299ff0 100644 --- a/examples/espidf/z_sub.c +++ b/examples/espidf/z_sub.c @@ -167,10 +167,6 @@ void app_main() { printf("Closing Zenoh Session..."); z_undeclare_subscriber(z_move(sub)); - // Stop the receive and the session lease loop for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); printf("OK!\n"); } diff --git a/examples/freertos_plus_tcp/z_get.c b/examples/freertos_plus_tcp/z_get.c index 7ea823074..5f02fe5cc 100644 --- a/examples/freertos_plus_tcp/z_get.c +++ b/examples/freertos_plus_tcp/z_get.c @@ -99,10 +99,6 @@ void app_main(void) { } } - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); } #else diff --git a/examples/freertos_plus_tcp/z_pub.c b/examples/freertos_plus_tcp/z_pub.c index d649bf9e7..886d309db 100644 --- a/examples/freertos_plus_tcp/z_pub.c +++ b/examples/freertos_plus_tcp/z_pub.c @@ -108,8 +108,6 @@ void app_main(void) { // Clean-up z_undeclare_publisher(z_move(pub)); - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); z_close(z_move(s)); } #else diff --git a/examples/freertos_plus_tcp/z_pull.c b/examples/freertos_plus_tcp/z_pull.c index f43bdb685..a4bd42660 100644 --- a/examples/freertos_plus_tcp/z_pull.c +++ b/examples/freertos_plus_tcp/z_pull.c @@ -81,10 +81,6 @@ void app_main(void) { // z_undeclare_pull_subscriber(z_move(sub)); printf("Pull Subscriber not supported... exiting\n"); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); } #else diff --git a/examples/freertos_plus_tcp/z_put.c b/examples/freertos_plus_tcp/z_put.c index 459077ae9..ff27f10c4 100644 --- a/examples/freertos_plus_tcp/z_put.c +++ b/examples/freertos_plus_tcp/z_put.c @@ -57,8 +57,6 @@ void app_main(void) { z_view_keyexpr_from_str_unchecked(&vke, KEYEXPR); if (z_declare_keyexpr(&ke, z_loan(s), z_loan(vke)) < 0) { printf("Unable to declare key expression!\n"); - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); z_close(z_move(s)); return; } @@ -81,8 +79,6 @@ void app_main(void) { // Clean up z_undeclare_keyexpr(z_move(ke), z_loan(s)); - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); z_close(z_move(s)); } #else diff --git a/examples/freertos_plus_tcp/z_queryable.c b/examples/freertos_plus_tcp/z_queryable.c index 06fb4e89f..e53bca42f 100644 --- a/examples/freertos_plus_tcp/z_queryable.c +++ b/examples/freertos_plus_tcp/z_queryable.c @@ -97,10 +97,6 @@ void app_main(void) { z_undeclare_queryable(z_move(qable)); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); } #else diff --git a/examples/freertos_plus_tcp/z_sub.c b/examples/freertos_plus_tcp/z_sub.c index b4a212258..2279e322b 100644 --- a/examples/freertos_plus_tcp/z_sub.c +++ b/examples/freertos_plus_tcp/z_sub.c @@ -77,10 +77,6 @@ void app_main(void) { z_undeclare_subscriber(z_move(sub)); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); } #else diff --git a/examples/mbed/z_get.cpp b/examples/mbed/z_get.cpp index 5ed3824e2..96f2826a4 100644 --- a/examples/mbed/z_get.cpp +++ b/examples/mbed/z_get.cpp @@ -99,9 +99,6 @@ int main(int argc, char **argv) { } printf("Closing Zenoh Session..."); - // Stop the receive and the session lease loop for zenoh-pico - zp_stop_read_task(z_session_loan_mut(&s)); - zp_stop_lease_task(z_session_loan_mut(&s)); z_close(z_session_move(&s)); printf("OK!\n"); diff --git a/examples/mbed/z_pub.cpp b/examples/mbed/z_pub.cpp index 7671e5ded..eb8e3edc6 100644 --- a/examples/mbed/z_pub.cpp +++ b/examples/mbed/z_pub.cpp @@ -85,10 +85,6 @@ int main(int argc, char **argv) { printf("Closing Zenoh Session..."); z_undeclare_publisher(z_publisher_move(&pub)); - // Stop the receive and the session lease loop for zenoh-pico - zp_stop_read_task(z_session_loan_mut(&s)); - zp_stop_lease_task(z_session_loan_mut(&s)); - z_close(z_session_move(&s)); printf("OK!\n"); diff --git a/examples/mbed/z_pull.cpp b/examples/mbed/z_pull.cpp index 35e4c39c4..657fd677c 100644 --- a/examples/mbed/z_pull.cpp +++ b/examples/mbed/z_pull.cpp @@ -90,10 +90,6 @@ int main(int argc, char **argv) { // z_undeclare_pull_subscriber(z_pull_subscriber_move(&sub)); printf("Pull Subscriber not supported... exiting\n"); - // Stop the receive and the session lease loop for zenoh-pico - zp_stop_read_task(z_session_loan_mut(&s)); - zp_stop_lease_task(z_session_loan_mut(&s)); - z_close(z_session_move(&s)); printf("OK!\n"); diff --git a/examples/mbed/z_queryable.cpp b/examples/mbed/z_queryable.cpp index 8aa221f7d..1193d8001 100644 --- a/examples/mbed/z_queryable.cpp +++ b/examples/mbed/z_queryable.cpp @@ -104,10 +104,6 @@ int main(int argc, char **argv) { printf("Closing Zenoh Session..."); z_undeclare_queryable(z_queryable_move(&qable)); - // Stop the receive and the session lease loop for zenoh-pico - zp_stop_read_task(z_session_loan_mut(&s)); - zp_stop_lease_task(z_session_loan_mut(&s)); - z_close(z_session_move(&s)); printf("OK!\n"); diff --git a/examples/mbed/z_sub.cpp b/examples/mbed/z_sub.cpp index b93287274..fefba9aa6 100644 --- a/examples/mbed/z_sub.cpp +++ b/examples/mbed/z_sub.cpp @@ -88,10 +88,6 @@ int main(int argc, char **argv) { printf("Closing Zenoh Session..."); z_undeclare_subscriber(z_subscriber_move(&sub)); - // Stop the receive and the session lease loop for zenoh-pico - zp_stop_read_task(z_session_loan_mut(&s)); - zp_stop_lease_task(z_session_loan_mut(&s)); - z_close(z_session_move(&s)); printf("OK!\n"); diff --git a/examples/unix/c11/z_get.c b/examples/unix/c11/z_get.c index 242482b40..06f5cb005 100644 --- a/examples/unix/c11/z_get.c +++ b/examples/unix/c11/z_get.c @@ -142,10 +142,6 @@ int main(int argc, char **argv) { z_condvar_wait(z_loan_mut(cond), z_loan_mut(mutex)); z_mutex_unlock(z_loan_mut(mutex)); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); return 0; } diff --git a/examples/unix/c11/z_get_attachment.c b/examples/unix/c11/z_get_attachment.c index 06c49ca3a..d2f0cb299 100644 --- a/examples/unix/c11/z_get_attachment.c +++ b/examples/unix/c11/z_get_attachment.c @@ -231,10 +231,6 @@ int main(int argc, char **argv) { z_condvar_wait(z_loan_mut(cond), z_loan_mut(mutex)); z_mutex_unlock(z_loan_mut(mutex)); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); return 0; } diff --git a/examples/unix/c11/z_get_channel.c b/examples/unix/c11/z_get_channel.c index fd4d6ba94..db8fd1400 100644 --- a/examples/unix/c11/z_get_channel.c +++ b/examples/unix/c11/z_get_channel.c @@ -123,10 +123,6 @@ int main(int argc, char **argv) { z_drop(z_move(handler)); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); return 0; diff --git a/examples/unix/c11/z_info.c b/examples/unix/c11/z_info.c index d70d1c55e..5b0fa48c6 100644 --- a/examples/unix/c11/z_info.c +++ b/examples/unix/c11/z_info.c @@ -96,9 +96,5 @@ int main(int argc, char **argv) { z_closure(&callback2, print_zid); z_info_peers_zid(z_loan(s), z_move(callback2)); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); } diff --git a/examples/unix/c11/z_ping.c b/examples/unix/c11/z_ping.c index e399a88b2..10c75cd15 100644 --- a/examples/unix/c11/z_ping.c +++ b/examples/unix/c11/z_ping.c @@ -135,9 +135,6 @@ int main(int argc, char** argv) { z_drop(z_move(pub)); z_drop(z_move(sub)); - zp_stop_read_task(z_loan_mut(session)); - zp_stop_lease_task(z_loan_mut(session)); - z_close(z_move(session)); } diff --git a/examples/unix/c11/z_pong.c b/examples/unix/c11/z_pong.c index b0be398e1..d3787b358 100644 --- a/examples/unix/c11/z_pong.c +++ b/examples/unix/c11/z_pong.c @@ -74,9 +74,6 @@ int main(int argc, char** argv) { z_drop(z_move(sub)); - zp_stop_read_task(z_loan_mut(session)); - zp_stop_lease_task(z_loan_mut(session)); - z_close(z_move(session)); } #else diff --git a/examples/unix/c11/z_pub.c b/examples/unix/c11/z_pub.c index 53ae46b05..55ae68745 100644 --- a/examples/unix/c11/z_pub.c +++ b/examples/unix/c11/z_pub.c @@ -120,8 +120,6 @@ int main(int argc, char **argv) { } // Clean up z_undeclare_publisher(z_move(pub)); - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); z_close(z_move(s)); return 0; } diff --git a/examples/unix/c11/z_pub_attachment.c b/examples/unix/c11/z_pub_attachment.c index a55e1cf98..1ab241ca9 100644 --- a/examples/unix/c11/z_pub_attachment.c +++ b/examples/unix/c11/z_pub_attachment.c @@ -171,8 +171,6 @@ int main(int argc, char **argv) { } // Clean up z_undeclare_publisher(z_move(pub)); - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); z_close(z_move(s)); return 0; } diff --git a/examples/unix/c11/z_pub_thr.c b/examples/unix/c11/z_pub_thr.c index f9247c5a8..6384dd2ed 100644 --- a/examples/unix/c11/z_pub_thr.c +++ b/examples/unix/c11/z_pub_thr.c @@ -69,8 +69,6 @@ int main(int argc, char **argv) { } // Clean up z_undeclare_publisher(z_move(pub)); - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); z_close(z_move(s)); z_free(value); exit(0); diff --git a/examples/unix/c11/z_pull.c b/examples/unix/c11/z_pull.c index 95e275518..5f64c9a1a 100644 --- a/examples/unix/c11/z_pull.c +++ b/examples/unix/c11/z_pull.c @@ -105,10 +105,6 @@ int main(int argc, char **argv) { z_undeclare_subscriber(z_move(sub)); z_drop(z_move(handler)); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); return 0; diff --git a/examples/unix/c11/z_put.c b/examples/unix/c11/z_put.c index e0f012047..e65c8e974 100644 --- a/examples/unix/c11/z_put.c +++ b/examples/unix/c11/z_put.c @@ -90,9 +90,6 @@ int main(int argc, char **argv) { z_view_keyexpr_from_str(&vke, keyexpr); z_owned_keyexpr_t ke; if (z_declare_keyexpr(&ke, z_loan(s), z_loan(vke)) < 0) { - printf("Unable to declare key expression!\n"); - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); z_close(z_move(s)); return -1; } @@ -107,8 +104,6 @@ int main(int argc, char **argv) { } // Clean up z_undeclare_keyexpr(z_move(ke), z_loan(s)); - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); z_close(z_move(s)); return 0; } diff --git a/examples/unix/c11/z_queryable.c b/examples/unix/c11/z_queryable.c index 2039231b7..a9a7893ce 100644 --- a/examples/unix/c11/z_queryable.c +++ b/examples/unix/c11/z_queryable.c @@ -162,10 +162,6 @@ int main(int argc, char **argv) { z_undeclare_queryable(z_move(qable)); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); return 0; diff --git a/examples/unix/c11/z_queryable_attachment.c b/examples/unix/c11/z_queryable_attachment.c index 11c6a469e..59293e4b0 100644 --- a/examples/unix/c11/z_queryable_attachment.c +++ b/examples/unix/c11/z_queryable_attachment.c @@ -246,10 +246,6 @@ int main(int argc, char **argv) { z_undeclare_queryable(z_move(qable)); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); return 0; diff --git a/examples/unix/c11/z_queryable_channel.c b/examples/unix/c11/z_queryable_channel.c index 3c9c5a047..4af3bf16b 100644 --- a/examples/unix/c11/z_queryable_channel.c +++ b/examples/unix/c11/z_queryable_channel.c @@ -128,10 +128,6 @@ int main(int argc, char **argv) { z_drop(z_move(handler)); z_undeclare_queryable(z_move(qable)); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); return 0; diff --git a/examples/unix/c11/z_sub.c b/examples/unix/c11/z_sub.c index ce3880fb1..9d37f5075 100644 --- a/examples/unix/c11/z_sub.c +++ b/examples/unix/c11/z_sub.c @@ -116,8 +116,6 @@ int main(int argc, char **argv) { } // Clean up z_undeclare_subscriber(z_move(sub)); - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); z_close(z_move(s)); return 0; } diff --git a/examples/unix/c11/z_sub_attachment.c b/examples/unix/c11/z_sub_attachment.c index 5ef7d9717..0323384b8 100644 --- a/examples/unix/c11/z_sub_attachment.c +++ b/examples/unix/c11/z_sub_attachment.c @@ -172,8 +172,6 @@ int main(int argc, char **argv) { } // Clean up z_undeclare_subscriber(z_move(sub)); - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); z_close(z_move(s)); return 0; } diff --git a/examples/unix/c11/z_sub_channel.c b/examples/unix/c11/z_sub_channel.c index da197dc6e..41ff0c5ff 100644 --- a/examples/unix/c11/z_sub_channel.c +++ b/examples/unix/c11/z_sub_channel.c @@ -93,10 +93,6 @@ int main(int argc, char **argv) { z_undeclare_subscriber(z_move(sub)); z_drop(z_move(handler)); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); return 0; diff --git a/examples/unix/c11/z_sub_thr.c b/examples/unix/c11/z_sub_thr.c index abfadfc32..8c9941451 100644 --- a/examples/unix/c11/z_sub_thr.c +++ b/examples/unix/c11/z_sub_thr.c @@ -110,8 +110,6 @@ int main(int argc, char **argv) { // Clean up z_undeclare_subscriber(z_move(sub)); - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); z_close(z_move(s)); exit(0); } diff --git a/examples/unix/c99/z_get.c b/examples/unix/c99/z_get.c index 5200fa19f..1af5aff4c 100644 --- a/examples/unix/c99/z_get.c +++ b/examples/unix/c99/z_get.c @@ -135,10 +135,6 @@ int main(int argc, char **argv) { z_condvar_wait(z_condvar_loan_mut(&cond), z_mutex_loan_mut(&mutex)); z_mutex_unlock(z_mutex_loan_mut(&mutex)); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_session_loan_mut(&s)); - zp_stop_lease_task(z_session_loan_mut(&s)); - z_close(z_session_move(&s)); return 0; diff --git a/examples/unix/c99/z_info.c b/examples/unix/c99/z_info.c index ba531e63f..b19a2dfae 100644 --- a/examples/unix/c99/z_info.c +++ b/examples/unix/c99/z_info.c @@ -96,9 +96,5 @@ int main(int argc, char **argv) { z_closure_zid(&callback2, print_zid, NULL, NULL); z_info_peers_zid(z_session_loan(&s), z_closure_zid_move(&callback2)); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_session_loan_mut(&s)); - zp_stop_lease_task(z_session_loan_mut(&s)); - z_close(z_session_move(&s)); } diff --git a/examples/unix/c99/z_ping.c b/examples/unix/c99/z_ping.c index 57189c826..c43d89d98 100644 --- a/examples/unix/c99/z_ping.c +++ b/examples/unix/c99/z_ping.c @@ -139,9 +139,6 @@ int main(int argc, char** argv) { z_undeclare_subscriber(z_subscriber_move(&sub)); z_undeclare_publisher(z_publisher_move(&pub)); - zp_stop_read_task(z_session_loan_mut(&session)); - zp_stop_lease_task(z_session_loan_mut(&session)); - z_close(z_session_move(&session)); } diff --git a/examples/unix/c99/z_pong.c b/examples/unix/c99/z_pong.c index b061b5fa6..0a6784cf2 100644 --- a/examples/unix/c99/z_pong.c +++ b/examples/unix/c99/z_pong.c @@ -81,9 +81,6 @@ int main(int argc, char** argv) { z_undeclare_subscriber(z_subscriber_move(&sub)); - zp_stop_read_task(z_session_loan_mut(&session)); - zp_stop_lease_task(z_session_loan_mut(&session)); - z_close(z_session_move(&session)); } #else diff --git a/examples/unix/c99/z_pub.c b/examples/unix/c99/z_pub.c index 5519afe08..e2e8fd2c9 100644 --- a/examples/unix/c99/z_pub.c +++ b/examples/unix/c99/z_pub.c @@ -110,8 +110,6 @@ int main(int argc, char **argv) { } // Clean up z_undeclare_publisher(z_publisher_move(&pub)); - zp_stop_read_task(z_session_loan_mut(&s)); - zp_stop_lease_task(z_session_loan_mut(&s)); z_close(z_session_move(&s)); return 0; } diff --git a/examples/unix/c99/z_pull.c b/examples/unix/c99/z_pull.c index fb5d89356..d06d00021 100644 --- a/examples/unix/c99/z_pull.c +++ b/examples/unix/c99/z_pull.c @@ -101,10 +101,6 @@ int main(int argc, char **argv) { // z_undeclare_pull_subscriber(z_pull_subscriber_move(&sub)); printf("Pull Subscriber not supported... exiting\n"); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_session_loan_mut(&s)); - zp_stop_lease_task(z_session_loan_mut(&s)); - z_close(z_session_move(&s)); return 0; diff --git a/examples/unix/c99/z_put.c b/examples/unix/c99/z_put.c index 9ccde511c..55d3875b6 100644 --- a/examples/unix/c99/z_put.c +++ b/examples/unix/c99/z_put.c @@ -87,8 +87,6 @@ int main(int argc, char **argv) { z_owned_keyexpr_t ke; if (z_declare_keyexpr(&ke, z_session_loan(&s), z_view_keyexpr_loan(&vke)) < 0) { printf("Unable to declare key expression!\n"); - zp_stop_read_task(z_session_loan_mut(&s)); - zp_stop_lease_task(z_session_loan_mut(&s)); z_close(z_session_move(&s)); return -1; } @@ -104,8 +102,6 @@ int main(int argc, char **argv) { // Clean up z_undeclare_keyexpr(z_keyexpr_move(&ke), z_session_loan(&s)); - zp_stop_read_task(z_session_loan_mut(&s)); - zp_stop_lease_task(z_session_loan_mut(&s)); z_close(z_session_move(&s)); return 0; } diff --git a/examples/unix/c99/z_queryable.c b/examples/unix/c99/z_queryable.c index 5649c2ca5..fdc0f0597 100644 --- a/examples/unix/c99/z_queryable.c +++ b/examples/unix/c99/z_queryable.c @@ -128,10 +128,6 @@ int main(int argc, char **argv) { z_undeclare_queryable(z_queryable_move(&qable)); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_session_loan_mut(&s)); - zp_stop_lease_task(z_session_loan_mut(&s)); - z_close(z_session_move(&s)); return 0; diff --git a/examples/unix/c99/z_sub.c b/examples/unix/c99/z_sub.c index d3958e919..2813f2959 100644 --- a/examples/unix/c99/z_sub.c +++ b/examples/unix/c99/z_sub.c @@ -108,10 +108,6 @@ int main(int argc, char **argv) { z_undeclare_subscriber(z_subscriber_move(&sub)); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_session_loan_mut(&s)); - zp_stop_lease_task(z_session_loan_mut(&s)); - z_close(z_session_move(&s)); return 0; diff --git a/examples/windows/z_get.c b/examples/windows/z_get.c index 9437b927e..b3d564c26 100644 --- a/examples/windows/z_get.c +++ b/examples/windows/z_get.c @@ -99,10 +99,6 @@ int main(int argc, char **argv) { z_condvar_wait(z_loan_mut(cond), z_loan_mut(mutex)); z_mutex_unlock(z_loan_mut(mutex)); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); return 0; diff --git a/examples/windows/z_info.c b/examples/windows/z_info.c index 0a8151e62..c560d0248 100644 --- a/examples/windows/z_info.c +++ b/examples/windows/z_info.c @@ -69,9 +69,5 @@ int main(int argc, char **argv) { z_closure(&callback2, print_zid); z_info_peers_zid(z_loan(s), z_move(callback2)); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); } diff --git a/examples/windows/z_ping.c b/examples/windows/z_ping.c index 725cfde17..bd9a99043 100644 --- a/examples/windows/z_ping.c +++ b/examples/windows/z_ping.c @@ -135,9 +135,6 @@ int main(int argc, char** argv) { z_drop(z_move(pub)); z_drop(z_move(sub)); - zp_stop_read_task(z_loan_mut(session)); - zp_stop_lease_task(z_loan_mut(session)); - z_close(z_move(session)); } diff --git a/examples/windows/z_pong.c b/examples/windows/z_pong.c index fb6931296..57ff1c684 100644 --- a/examples/windows/z_pong.c +++ b/examples/windows/z_pong.c @@ -77,9 +77,6 @@ int main(int argc, char** argv) { z_drop(z_move(sub)); - zp_stop_read_task(z_loan_mut(session)); - zp_stop_lease_task(z_loan_mut(session)); - z_close(z_move(session)); } #else diff --git a/examples/windows/z_pull.c b/examples/windows/z_pull.c index 70378b7e5..c6473bcbe 100644 --- a/examples/windows/z_pull.c +++ b/examples/windows/z_pull.c @@ -78,10 +78,6 @@ int main(int argc, char **argv) { // z_undeclare_pull_subscriber(z_move(sub)); printf("Pull Subscriber not supported... exiting\n"); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); return 0; diff --git a/examples/windows/z_put.c b/examples/windows/z_put.c index 65287dbfa..fba9b759b 100644 --- a/examples/windows/z_put.c +++ b/examples/windows/z_put.c @@ -54,8 +54,6 @@ int main(int argc, char **argv) { z_owned_keyexpr_t ke; if (z_declare_keyexpr(&ke, z_loan(s), z_loan(vke)) < 0) { printf("Unable to declare key expression!\n"); - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); z_close(z_move(s)); return -1; } @@ -71,8 +69,6 @@ int main(int argc, char **argv) { // Clean up z_undeclare_keyexpr(z_move(ke), z_loan(s)); - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); z_close(z_move(s)); return 0; } diff --git a/examples/windows/z_queryable.c b/examples/windows/z_queryable.c index acb60d680..1b5c8faed 100644 --- a/examples/windows/z_queryable.c +++ b/examples/windows/z_queryable.c @@ -92,10 +92,6 @@ int main(int argc, char **argv) { z_undeclare_queryable(z_move(qable)); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); return 0; diff --git a/examples/windows/z_sub.c b/examples/windows/z_sub.c index b1861728f..f7ab3d356 100644 --- a/examples/windows/z_sub.c +++ b/examples/windows/z_sub.c @@ -75,10 +75,6 @@ int main(int argc, char **argv) { z_undeclare_subscriber(z_move(sub)); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); return 0; diff --git a/examples/zephyr/z_get.c b/examples/zephyr/z_get.c index 380efa1c5..a792a7cbb 100644 --- a/examples/zephyr/z_get.c +++ b/examples/zephyr/z_get.c @@ -96,9 +96,6 @@ int main(int argc, char **argv) { } printf("Closing Zenoh Session..."); - // Stop the receive and the session lease loop for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); z_close(z_move(s)); printf("OK!\n"); diff --git a/examples/zephyr/z_pub.c b/examples/zephyr/z_pub.c index 31c9ce394..5ef9b5166 100644 --- a/examples/zephyr/z_pub.c +++ b/examples/zephyr/z_pub.c @@ -82,10 +82,6 @@ int main(int argc, char **argv) { printf("Closing Zenoh Session..."); z_undeclare_publisher(z_move(pub)); - // Stop the receive and the session lease loop for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); printf("OK!\n"); diff --git a/examples/zephyr/z_pull.c b/examples/zephyr/z_pull.c index c0e9d4b9a..7c8868b15 100644 --- a/examples/zephyr/z_pull.c +++ b/examples/zephyr/z_pull.c @@ -84,10 +84,6 @@ int main(int argc, char **argv) { // z_undeclare_pull_subscriber(z_move(sub)); printf("Pull Subscriber not supported... exiting\n"); - // Stop the receive and the session lease loop for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); printf("OK!\n"); diff --git a/examples/zephyr/z_queryable.c b/examples/zephyr/z_queryable.c index d30daea95..4f6e51d23 100644 --- a/examples/zephyr/z_queryable.c +++ b/examples/zephyr/z_queryable.c @@ -99,10 +99,6 @@ int main(int argc, char **argv) { printf("Closing Zenoh Session..."); z_undeclare_queryable(z_move(qable)); - // Stop the receive and the session lease loop for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); printf("OK!\n"); diff --git a/examples/zephyr/z_sub.c b/examples/zephyr/z_sub.c index e1e278343..5f974ab2c 100644 --- a/examples/zephyr/z_sub.c +++ b/examples/zephyr/z_sub.c @@ -82,10 +82,6 @@ int main(int argc, char **argv) { printf("Closing Zenoh Session..."); z_undeclare_subscriber(z_move(sub)); - // Stop the receive and the session lease loop for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - z_close(z_move(s)); printf("OK!\n"); diff --git a/src/api/api.c b/src/api/api.c index 6ab280187..40eeff8c5 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -893,7 +893,6 @@ int8_t z_close(z_owned_session_t *zs) { if (zs == NULL || !z_session_check(zs)) { return _Z_RES_OK; } - _z_close(&_Z_OWNED_RC_IN_VAL(zs)); z_session_drop(zs); return _Z_RES_OK; } diff --git a/src/session/utils.c b/src/session/utils.c index deb615ed7..bfed7ef50 100644 --- a/src/session/utils.c +++ b/src/session/utils.c @@ -101,8 +101,12 @@ int8_t _z_session_init(_z_session_rc_t *zsrc, _z_id_t *zid) { } void _z_session_clear(_z_session_t *zn) { +#if Z_FEATURE_MULTI_THREAD == 1 + _zp_stop_read_task(zn); + _zp_stop_lease_task(zn); +#endif + _z_close(zn); // Clear Zenoh PID - // Clean up transports _z_transport_clear(&zn->_tp); diff --git a/tests/z_client_test.c b/tests/z_client_test.c index 68ad15f65..3ad3fd406 100644 --- a/tests/z_client_test.c +++ b/tests/z_client_test.c @@ -388,15 +388,6 @@ int main(int argc, char **argv) { z_sleep_s(SLEEP); - // Stop both sessions - printf("Stopping threads on session 1\n"); - zp_stop_read_task(z_loan_mut(s1)); - zp_stop_lease_task(z_loan_mut(s1)); - - printf("Stopping threads on session 2\n"); - zp_stop_read_task(z_loan_mut(s2)); - zp_stop_lease_task(z_loan_mut(s2)); - // Close both sessions printf("Closing session 1\n"); z_close(z_move(s1)); diff --git a/tests/z_peer_multicast_test.c b/tests/z_peer_multicast_test.c index fec2764ac..23897fde9 100644 --- a/tests/z_peer_multicast_test.c +++ b/tests/z_peer_multicast_test.c @@ -177,15 +177,6 @@ int main(int argc, char **argv) { z_sleep_s(SLEEP); - // Stop both sessions - printf("Stopping threads on session 1\n"); - zp_stop_read_task(z_loan_mut(s1)); - zp_stop_lease_task(z_loan_mut(s1)); - - printf("Stopping threads on session 2\n"); - zp_stop_read_task(z_loan_mut(s2)); - zp_stop_lease_task(z_loan_mut(s2)); - // Close both sessions printf("Closing session 1\n"); z_close(z_move(s1)); diff --git a/tests/z_perf_rx.c b/tests/z_perf_rx.c index 7f0ac6864..b46feb136 100644 --- a/tests/z_perf_rx.c +++ b/tests/z_perf_rx.c @@ -120,8 +120,6 @@ int main(int argc, char **argv) { z_sleep_s(1); // Clean up z_undeclare_subscriber(z_move(sub)); - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); z_close(z_move(s)); exit(0); } diff --git a/tests/z_perf_tx.c b/tests/z_perf_tx.c index ee59e495b..1e9dc259b 100644 --- a/tests/z_perf_tx.c +++ b/tests/z_perf_tx.c @@ -108,8 +108,6 @@ int main(int argc, char **argv) { z_publisher_put(z_loan(pub), z_move(payload), NULL); // Clean up z_undeclare_publisher(z_move(pub)); - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); z_close(z_move(s)); free(value); exit(0); diff --git a/tests/z_session_test.c b/tests/z_session_test.c index dcb55e097..a78f89a3f 100644 --- a/tests/z_session_test.c +++ b/tests/z_session_test.c @@ -43,10 +43,6 @@ int main(void) { // Commented out wait for 1 second. Stopping should work without it. // z_sleep_ms(1000); - // Stop read and lease tasks for zenoh-pico - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); - // Immediately close the session z_close(&s); } diff --git a/tests/z_test_fragment_rx.c b/tests/z_test_fragment_rx.c index b0fb8395f..8edaa5a96 100644 --- a/tests/z_test_fragment_rx.c +++ b/tests/z_test_fragment_rx.c @@ -96,8 +96,6 @@ int main(int argc, char **argv) { } // Clean up z_undeclare_subscriber(z_move(sub)); - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); z_close(z_move(s)); return 0; } diff --git a/tests/z_test_fragment_tx.c b/tests/z_test_fragment_tx.c index 6bca1264e..17defeb10 100644 --- a/tests/z_test_fragment_tx.c +++ b/tests/z_test_fragment_tx.c @@ -89,8 +89,6 @@ int main(int argc, char **argv) { z_sleep_s(1); } // Clean up - zp_stop_read_task(z_loan_mut(s)); - zp_stop_lease_task(z_loan_mut(s)); z_close(z_move(s)); free(value); return 0; diff --git a/zenohpico.pc b/zenohpico.pc index cad278917..6171fd0b5 100644 --- a/zenohpico.pc +++ b/zenohpico.pc @@ -3,6 +3,6 @@ prefix=/usr/local Name: zenohpico Description: URL: -Version: 1.0.20240710dev +Version: 1.0.20240711dev Cflags: -I${prefix}/include Libs: -L${prefix}/lib -lzenohpico