diff --git a/examples/z_delete.c b/examples/z_delete.c index 67c0f083a..04970ab99 100644 --- a/examples/z_delete.c +++ b/examples/z_delete.c @@ -30,7 +30,7 @@ int main(int argc, char** argv) { printf("Opening session...\n"); z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { printf("Unable to open session!\n"); exit(-1); } @@ -43,7 +43,7 @@ int main(int argc, char** argv) { printf("Delete failed...\n"); } - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } diff --git a/examples/z_get.c b/examples/z_get.c index c26b9cbb9..af3092273 100644 --- a/examples/z_get.c +++ b/examples/z_get.c @@ -38,7 +38,7 @@ int main(int argc, char** argv) { printf("Opening session...\n"); z_owned_session_t s; - if (z_open(&s, z_move(config))) { + if (z_open(&s, z_move(config), NULL)) { printf("Unable to open session!\n"); exit(-1); } @@ -80,7 +80,7 @@ int main(int argc, char** argv) { } z_drop(z_move(handler)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } diff --git a/examples/z_get_liveliness.c b/examples/z_get_liveliness.c index 60e101416..b74e4d066 100644 --- a/examples/z_get_liveliness.c +++ b/examples/z_get_liveliness.c @@ -36,7 +36,7 @@ int main(int argc, char** argv) { z_owned_session_t s; printf("Opening session...\n"); - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { printf("Unable to open session!\n"); exit(-1); } @@ -60,7 +60,7 @@ int main(int argc, char** argv) { z_drop(z_move(reply)); z_drop(z_move(handler)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } diff --git a/examples/z_get_shm.c b/examples/z_get_shm.c index c0846f6a4..430ab3f77 100644 --- a/examples/z_get_shm.c +++ b/examples/z_get_shm.c @@ -52,7 +52,7 @@ int main(int argc, char** argv) { printf("Opening session...\n"); z_owned_session_t s; - if (z_open(&s, z_move(config))) { + if (z_open(&s, z_move(config), NULL)) { printf("Unable to open session!\n"); exit(-1); } @@ -119,7 +119,7 @@ int main(int argc, char** argv) { } z_drop(z_move(handler)); - z_close(z_move(s)); + z_close(z_move(s), NULL); z_drop(z_move(shm)); z_drop(z_move(provider)); diff --git a/examples/z_info.c b/examples/z_info.c index 629a47314..eed270823 100644 --- a/examples/z_info.c +++ b/examples/z_info.c @@ -31,7 +31,7 @@ int main(int argc, char** argv) { printf("Opening session...\n"); z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { printf("Unable to open session!\n"); exit(-1); } @@ -52,7 +52,7 @@ int main(int argc, char** argv) { z_closure(&callback2, print_zid, NULL, NULL); z_info_peers_zid(z_loan(s), z_move(callback2)); - z_close(z_move(s)); + z_close(z_move(s), NULL); } void print_help() { diff --git a/examples/z_liveliness.c b/examples/z_liveliness.c index de0dd95db..44a8db2fc 100644 --- a/examples/z_liveliness.c +++ b/examples/z_liveliness.c @@ -36,7 +36,7 @@ int main(int argc, char** argv) { printf("Opening session...\n"); z_owned_session_t s; - if (z_open(&s, z_move(config))) { + if (z_open(&s, z_move(config), NULL)) { printf("Unable to open session!\n"); exit(-1); } @@ -58,7 +58,7 @@ int main(int argc, char** argv) { printf("Undeclaring liveliness token...\n"); z_drop(z_move(token)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } diff --git a/examples/z_non_blocking_get.c b/examples/z_non_blocking_get.c index 1f834d769..818378fdc 100644 --- a/examples/z_non_blocking_get.c +++ b/examples/z_non_blocking_get.c @@ -36,7 +36,7 @@ int main(int argc, char** argv) { printf("Opening session...\n"); z_owned_session_t s; - if (z_open(&s, z_move(config))) { + if (z_open(&s, z_move(config), NULL)) { printf("Unable to open session!\n"); exit(-1); } @@ -72,7 +72,7 @@ int main(int argc, char** argv) { } z_drop(z_move(reply)); z_drop(z_move(handler)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } diff --git a/examples/z_ping.c b/examples/z_ping.c index 436feeb6d..72d983236 100644 --- a/examples/z_ping.c +++ b/examples/z_ping.c @@ -38,7 +38,7 @@ int main(int argc, char** argv) { z_mutex_init(&mutex); z_condvar_init(&cond); z_owned_session_t session; - z_open(&session, z_move(config)); + z_open(&session, z_move(config), NULL); z_view_keyexpr_t ping; z_view_keyexpr_from_str_unchecked(&ping, "test/ping"); z_view_keyexpr_t pong; @@ -91,7 +91,7 @@ int main(int argc, char** argv) { z_undeclare_subscriber(z_move(sub)); z_undeclare_publisher(z_move(pub)); z_drop(z_move(mutex)); - z_close(z_move(session)); + z_close(z_move(session), NULL); } void print_help() { diff --git a/examples/z_ping_shm.c b/examples/z_ping_shm.c index 5457def13..10482a6c2 100644 --- a/examples/z_ping_shm.c +++ b/examples/z_ping_shm.c @@ -55,7 +55,7 @@ int main(int argc, char** argv) { } z_owned_session_t session; - z_open(&session, z_move(config)); + z_open(&session, z_move(config), NULL); z_view_keyexpr_t ping; z_view_keyexpr_from_str_unchecked(&ping, "test/ping"); z_view_keyexpr_t pong; @@ -133,7 +133,7 @@ int main(int argc, char** argv) { z_undeclare_subscriber(z_move(sub)); z_undeclare_publisher(z_move(pub)); z_drop(z_move(mutex)); - z_close(z_move(session)); + z_close(z_move(session), NULL); z_drop(z_move(shm)); z_drop(z_move(provider)); diff --git a/examples/z_pong.c b/examples/z_pong.c index f58a3fe96..d7eda1bb9 100644 --- a/examples/z_pong.c +++ b/examples/z_pong.c @@ -26,7 +26,7 @@ int main(int argc, char** argv) { parse_args(argc, argv, &config); z_owned_session_t session; - z_open(&session, z_move(config)); + z_open(&session, z_move(config), NULL); z_view_keyexpr_t ping; z_view_keyexpr_from_str_unchecked(&ping, "test/ping"); z_view_keyexpr_t pong; @@ -42,7 +42,7 @@ int main(int argc, char** argv) { z_sleep_s(1); } z_undeclare_subscriber(z_move(sub)); - z_close(z_move(session)); + z_close(z_move(session), NULL); } void print_help() { diff --git a/examples/z_pub.c b/examples/z_pub.c index 6aa478a30..6969014ef 100644 --- a/examples/z_pub.c +++ b/examples/z_pub.c @@ -43,7 +43,7 @@ int main(int argc, char** argv) { printf("Opening session...\n"); z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { printf("Unable to open session!\n"); exit(-1); } @@ -92,7 +92,7 @@ int main(int argc, char** argv) { #endif z_undeclare_publisher(z_move(pub)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } diff --git a/examples/z_pub_attachment.c b/examples/z_pub_attachment.c index ed947262b..734770d05 100644 --- a/examples/z_pub_attachment.c +++ b/examples/z_pub_attachment.c @@ -55,7 +55,7 @@ int main(int argc, char** argv) { printf("Opening session...\n"); z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { printf("Unable to open session!\n"); exit(-1); } @@ -101,7 +101,7 @@ int main(int argc, char** argv) { z_undeclare_publisher(z_move(pub)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } diff --git a/examples/z_pub_cache.c b/examples/z_pub_cache.c index e2de9caf9..65e6e4026 100644 --- a/examples/z_pub_cache.c +++ b/examples/z_pub_cache.c @@ -39,7 +39,7 @@ int main(int argc, char** argv) { printf("Opening session...\n"); z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { printf("Unable to open session!\n"); exit(-1); } @@ -72,7 +72,7 @@ int main(int argc, char** argv) { } ze_undeclare_publication_cache(z_move(pub_cache)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } diff --git a/examples/z_pub_shm.c b/examples/z_pub_shm.c index cd259cceb..0fc896380 100644 --- a/examples/z_pub_shm.c +++ b/examples/z_pub_shm.c @@ -44,7 +44,7 @@ int main(int argc, char** argv) { printf("Opening session...\n"); z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { printf("Unable to open session!\n"); exit(-1); } @@ -114,7 +114,7 @@ int main(int argc, char** argv) { #endif z_undeclare_publisher(z_move(pub)); - z_close(z_move(s)); + z_close(z_move(s), NULL); z_drop(z_move(provider)); z_drop(z_move(layout)); diff --git a/examples/z_pub_shm_thr.c b/examples/z_pub_shm_thr.c index d91a18e46..1945d2b45 100644 --- a/examples/z_pub_shm_thr.c +++ b/examples/z_pub_shm_thr.c @@ -39,7 +39,7 @@ int main(int argc, char **argv) { } z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { printf("Unable to open session!\n"); exit(-1); } @@ -87,7 +87,7 @@ int main(int argc, char **argv) { } z_undeclare_publisher(z_move(pub)); - z_close(z_move(s)); + z_close(z_move(s), NULL); z_drop(z_move(shm)); z_drop(z_move(provider)); diff --git a/examples/z_pub_thr.c b/examples/z_pub_thr.c index ebd1d7f0f..79768f4b4 100644 --- a/examples/z_pub_thr.c +++ b/examples/z_pub_thr.c @@ -31,7 +31,7 @@ int main(int argc, char** argv) { memset(value, 1, args.size); z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { printf("Unable to open session!\n"); exit(-1); } @@ -56,7 +56,7 @@ int main(int argc, char** argv) { } z_undeclare_publisher(z_move(pub)); - z_close(z_move(s)); + z_close(z_move(s), NULL); } void print_help() { diff --git a/examples/z_pull.c b/examples/z_pull.c index 40930f363..179be9c90 100644 --- a/examples/z_pull.c +++ b/examples/z_pull.c @@ -43,7 +43,7 @@ int main(int argc, char** argv) { printf("Opening session...\n"); z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { printf("Unable to open session!\n"); exit(-1); } @@ -79,7 +79,7 @@ int main(int argc, char** argv) { } } z_undeclare_subscriber(z_move(sub)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } diff --git a/examples/z_put.c b/examples/z_put.c index 9117be365..f78821c3f 100644 --- a/examples/z_put.c +++ b/examples/z_put.c @@ -32,7 +32,7 @@ int main(int argc, char** argv) { printf("Opening session...\n"); z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { printf("Unable to open session!\n"); exit(-1); } @@ -60,7 +60,7 @@ int main(int argc, char** argv) { printf("Put failed...\n"); } - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } diff --git a/examples/z_query_sub.c b/examples/z_query_sub.c index e17a48b43..96ac2049f 100644 --- a/examples/z_query_sub.c +++ b/examples/z_query_sub.c @@ -43,7 +43,7 @@ int main(int argc, char** argv) { printf("Opening session...\n"); z_owned_session_t s; - if (z_open(&s, z_move(config))) { + if (z_open(&s, z_move(config), NULL)) { printf("Unable to open session!\n"); exit(-1); } @@ -68,7 +68,7 @@ int main(int argc, char** argv) { } ze_undeclare_querying_subscriber(z_move(sub)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } diff --git a/examples/z_queryable.c b/examples/z_queryable.c index 5f5f48b71..45e073069 100644 --- a/examples/z_queryable.c +++ b/examples/z_queryable.c @@ -69,7 +69,7 @@ int main(int argc, char **argv) { printf("Opening session...\n"); z_owned_session_t s; - if (z_open(&s, z_move(config))) { + if (z_open(&s, z_move(config), NULL)) { printf("Unable to open session!\n"); exit(-1); } @@ -95,7 +95,7 @@ int main(int argc, char **argv) { } z_undeclare_queryable(z_move(qable)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } diff --git a/examples/z_queryable_shm.c b/examples/z_queryable_shm.c index 1e4fab53f..b70b9a843 100644 --- a/examples/z_queryable_shm.c +++ b/examples/z_queryable_shm.c @@ -93,7 +93,7 @@ int main(int argc, char **argv) { printf("Opening session...\n"); z_owned_session_t s; - if (z_open(&s, z_move(config))) { + if (z_open(&s, z_move(config), NULL)) { printf("Unable to open session!\n"); exit(-1); } @@ -131,7 +131,7 @@ int main(int argc, char **argv) { } z_undeclare_queryable(z_move(qable)); - z_close(z_move(s)); + z_close(z_move(s), NULL); z_drop(z_move(layout)); z_drop(z_move(provider)); return 0; diff --git a/examples/z_queryable_with_channels.c b/examples/z_queryable_with_channels.c index 4e8b6b856..97b530595 100644 --- a/examples/z_queryable_with_channels.c +++ b/examples/z_queryable_with_channels.c @@ -34,7 +34,7 @@ int main(int argc, char** argv) { printf("Opening session...\n"); z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { printf("Unable to open session!\n"); exit(-1); } @@ -90,7 +90,7 @@ int main(int argc, char** argv) { z_undeclare_queryable(z_move(qable)); z_drop(z_move(handler)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } diff --git a/examples/z_sub.c b/examples/z_sub.c index 41dfdeff5..ebb4e6a6b 100644 --- a/examples/z_sub.c +++ b/examples/z_sub.c @@ -59,7 +59,7 @@ int main(int argc, char **argv) { printf("Opening session...\n"); z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { printf("Unable to open session!\n"); exit(-1); } @@ -79,7 +79,7 @@ int main(int argc, char **argv) { } z_undeclare_subscriber(z_move(sub)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } diff --git a/examples/z_sub_attachment.c b/examples/z_sub_attachment.c index 20cef431e..43a67b303 100644 --- a/examples/z_sub_attachment.c +++ b/examples/z_sub_attachment.c @@ -70,7 +70,7 @@ int main(int argc, char** argv) { printf("Opening session...\n"); z_owned_session_t s; - if (z_open(&s, z_move(config))) { + if (z_open(&s, z_move(config), NULL)) { printf("Unable to open session!\n"); exit(-1); } @@ -90,7 +90,7 @@ int main(int argc, char** argv) { } z_undeclare_subscriber(z_move(sub)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } diff --git a/examples/z_sub_liveliness.c b/examples/z_sub_liveliness.c index bb2d4fc0f..b67a2d8b9 100644 --- a/examples/z_sub_liveliness.c +++ b/examples/z_sub_liveliness.c @@ -49,7 +49,7 @@ int main(int argc, char** argv) { printf("Opening session...\n"); z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { printf("Unable to open session!\n"); exit(-1); } @@ -69,7 +69,7 @@ int main(int argc, char** argv) { } z_undeclare_subscriber(z_move(sub)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } diff --git a/examples/z_sub_shm.c b/examples/z_sub_shm.c index 8d9006846..f6a6fad7e 100644 --- a/examples/z_sub_shm.c +++ b/examples/z_sub_shm.c @@ -76,7 +76,7 @@ int main(int argc, char **argv) { printf("Opening session...\n"); z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { printf("Unable to open session!\n"); exit(-1); } @@ -100,7 +100,7 @@ int main(int argc, char **argv) { } z_undeclare_subscriber(z_move(sub)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } diff --git a/examples/z_sub_thr.c b/examples/z_sub_thr.c index 75367f065..1a8d8e3f5 100644 --- a/examples/z_sub_thr.c +++ b/examples/z_sub_thr.c @@ -80,7 +80,7 @@ int main(int argc, char **argv) { z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { printf("Unable to open session!\n"); exit(-1); } @@ -106,7 +106,7 @@ int main(int argc, char **argv) { z_undeclare_subscriber(z_move(sub)); z_undeclare_keyexpr(z_move(declared_ke), z_loan(s)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } diff --git a/include/zenoh_commons.h b/include/zenoh_commons.h index fa55be71d..22c5b52c3 100644 --- a/include/zenoh_commons.h +++ b/include/zenoh_commons.h @@ -436,6 +436,12 @@ typedef struct z_clock_t { typedef struct z_moved_session_t { struct z_owned_session_t _this; } z_moved_session_t; +/** + * Options passed to the `z_close()` function. + */ +typedef struct z_close_options_t { + uint8_t _dummy; +} z_close_options_t; /** * A closure is a structure that contains all the elements for stateful, memory-leak-free callbacks: * @@ -783,6 +789,12 @@ typedef struct z_moved_keyexpr_t { typedef struct z_moved_mutex_t { struct z_owned_mutex_t _this; } z_moved_mutex_t; +/** + * Options passed to the `z_open()` function. + */ +typedef struct z_open_options_t { + uint8_t _dummy; +} z_open_options_t; /** * Represents the set of options that can be applied to the delete operation by a previously declared publisher, * whenever issued via `z_publisher_delete()`. @@ -1842,7 +1854,12 @@ ZENOHC_API struct z_clock_t z_clock_now(void); * the remaining reference count (number of shallow copies) of the session otherwise, saturating at i8::MAX. */ ZENOHC_API -z_result_t z_close(struct z_moved_session_t *session); +z_result_t z_close(struct z_moved_session_t *session, + const struct z_close_options_t *_options); +/** + * Constructs the default value for `z_close_options_t`. + */ +ZENOHC_API void z_close_options_default(struct z_close_options_t *this_); /** * Calls the closure. Calling an uninitialized closure is a no-op. */ @@ -3368,7 +3385,12 @@ z_result_t z_mutex_unlock(struct z_loaned_mutex_t *this_); */ ZENOHC_API z_result_t z_open(struct z_owned_session_t *this_, - struct z_moved_config_t *config); + struct z_moved_config_t *config, + const struct z_open_options_t *_options); +/** + * Constructs the default value for `z_open_options_t`. + */ +ZENOHC_API void z_open_options_default(struct z_open_options_t *this_); /** * @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. * @brief Constructs and opens a new Zenoh session with specified client storage. diff --git a/src/session.rs b/src/session.rs index fc1130d11..75ab844d9 100644 --- a/src/session.rs +++ b/src/session.rs @@ -47,6 +47,18 @@ pub extern "C" fn z_internal_session_null(this_: &mut MaybeUninit) { + this_.write(z_open_options_t { _dummy: 0 }); +} + /// Constructs and opens a new Zenoh session. /// /// @return 0 in case of success, negative error code otherwise (in this case the session will be in its gravestone state). @@ -55,6 +67,7 @@ pub extern "C" fn z_internal_session_null(this_: &mut MaybeUninit, config: &mut z_moved_config_t, + _options: Option<&z_open_options_t>, ) -> result::z_result_t { let this = this.as_rust_type_mut_uninit(); if cfg!(feature = "logger-autoinit") { @@ -122,12 +135,27 @@ pub extern "C" fn z_internal_session_check(this_: &z_owned_session_t) -> bool { this_.as_rust_type_ref().is_some() } +/// Options passed to the `z_close()` function. +#[repr(C)] +pub struct z_close_options_t { + _dummy: u8, +} + +/// Constructs the default value for `z_close_options_t`. +#[no_mangle] +pub extern "C" fn z_close_options_default(this_: &mut MaybeUninit) { + this_.write(z_close_options_t { _dummy: 0 }); +} + /// Closes a zenoh session. This alos drops and invalidates `session`. /// /// @return 0 in case of success, a negative value if an error occured while closing the session, /// the remaining reference count (number of shallow copies) of the session otherwise, saturating at i8::MAX. #[no_mangle] -pub extern "C" fn z_close(session: &mut z_moved_session_t) -> result::z_result_t { +pub extern "C" fn z_close( + session: &mut z_moved_session_t, + _options: Option<&z_close_options_t>, +) -> result::z_result_t { let Some(s) = session.take_rust_type() else { return result::Z_EINVAL; }; diff --git a/tests/z_api_alignment_test.c b/tests/z_api_alignment_test.c index 8af3e2a3c..a8ce64e89 100644 --- a/tests/z_api_alignment_test.c +++ b/tests/z_api_alignment_test.c @@ -198,7 +198,7 @@ int main(int argc, char **argv) { z_sleep_s(SLEEP); z_owned_session_t s1; - assert(0 == z_open(&s1, z_move(_ret_config))); + assert(0 == z_open(&s1, z_move(_ret_config), NULL)); assert(z_internal_check(s1)); #ifdef UNSTABLE @@ -242,7 +242,7 @@ int main(int argc, char **argv) { #endif z_owned_session_t s2; - assert(0 == z_open(&s2, z_move(_ret_config))); + assert(0 == z_open(&s2, z_move(_ret_config), NULL)); assert(z_internal_check(s2)); #ifdef UNSTABLE @@ -346,14 +346,14 @@ int main(int argc, char **argv) { zp_stop_lease_task(z_loan(s1)); #endif - _ret_int8 = z_close(z_move(s1)); + _ret_int8 = z_close(z_move(s1), NULL); assert(_ret_int8 == 0); #ifdef ZENOH_PICO zp_stop_read_task(z_loan(s2)); zp_stop_lease_task(z_loan(s2)); #endif - _ret_int8 = z_close(z_move(s2)); + _ret_int8 = z_close(z_move(s2), NULL); assert(_ret_int8 == 0); z_sleep_s(SLEEP * 5); diff --git a/tests/z_api_double_drop_test.c b/tests/z_api_double_drop_test.c index 9fa82c40c..2323ceca2 100644 --- a/tests/z_api_double_drop_test.c +++ b/tests/z_api_double_drop_test.c @@ -27,11 +27,11 @@ void test_session() { z_config_default(&config); assert(z_internal_check(config)); z_owned_session_t session; - z_open(&session, z_move(config)); + z_open(&session, z_move(config), NULL); assert(z_internal_check(session)); - z_close(z_move(session)); + z_close(z_move(session), NULL); assert(!z_internal_check(session)); - z_close(z_move(session)); + z_close(z_move(session), NULL); assert(!z_internal_check(session)); } @@ -39,7 +39,7 @@ void test_publisher() { z_owned_config_t config; z_config_default(&config); z_owned_session_t s; - z_open(&s, z_move(config)); + z_open(&s, z_move(config), NULL); z_owned_keyexpr_t keyexpr; z_keyexpr_from_str(&keyexpr, URL); @@ -51,7 +51,7 @@ void test_publisher() { assert(!z_internal_check(pub)); z_undeclare_publisher(z_move(pub)); assert(!z_internal_check(pub)); - z_close(z_move(s)); + z_close(z_move(s), NULL); } void test_keyexpr() { @@ -81,7 +81,7 @@ void test_subscriber() { z_owned_config_t config; z_config_default(&config); z_owned_session_t s; - z_open(&s, z_move(config)); + z_open(&s, z_move(config), NULL); z_owned_closure_sample_t callback; z_closure(&callback, data_handler, NULL, NULL); @@ -94,7 +94,7 @@ void test_subscriber() { assert(!z_internal_check(sub)); z_undeclare_subscriber(z_move(sub)); assert(!z_internal_check(sub)); - z_close(z_move(s)); + z_close(z_move(s), NULL); } void query_handler(const z_loaned_query_t *query, void *context) {} @@ -103,7 +103,7 @@ void test_queryable() { z_owned_config_t config; z_config_default(&config); z_owned_session_t s; - z_open(&s, z_move(config)); + z_open(&s, z_move(config), NULL); z_owned_closure_query_t callback; z_closure(&callback, query_handler, NULL, NULL); @@ -116,7 +116,7 @@ void test_queryable() { assert(!z_internal_check(queryable)); z_undeclare_queryable(z_move(queryable)); assert(!z_internal_check(queryable)); - z_close(z_move(s)); + z_close(z_move(s), NULL); } int main(int argc, char **argv) { diff --git a/tests/z_api_drop_options.c b/tests/z_api_drop_options.c index b8ce3bd9d..c886f4cc9 100644 --- a/tests/z_api_drop_options.c +++ b/tests/z_api_drop_options.c @@ -26,7 +26,7 @@ void put() { z_config_default(&config); z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { perror("Unable to open session!"); exit(-1); } @@ -42,7 +42,7 @@ void put() { z_put(z_loan(s), z_loan(ke), z_move(payload), &opts); assert(!z_internal_check(payload)); assert(!z_internal_check(attachment)); - z_close(z_move(s)); + z_close(z_move(s), NULL); } void get() { @@ -50,7 +50,7 @@ void get() { z_config_default(&config); z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { perror("Unable to open session!"); exit(-1); } @@ -70,7 +70,7 @@ void get() { z_get(z_loan(s), z_loan(ke), "", z_move(closure), &opts); assert(!z_internal_check(payload)); assert(!z_internal_check(attachment)); - z_close(z_move(s)); + z_close(z_move(s), NULL); } int main(int argc, char **argv) { diff --git a/tests/z_api_keyexpr_drop_test.c b/tests/z_api_keyexpr_drop_test.c index a24eb68ee..0dbc05618 100644 --- a/tests/z_api_keyexpr_drop_test.c +++ b/tests/z_api_keyexpr_drop_test.c @@ -24,7 +24,7 @@ void test_publisher() { z_owned_config_t config; z_config_default(&config); z_owned_session_t s; - z_open(&s, z_move(config)); + z_open(&s, z_move(config), NULL); assert(z_internal_check(s)); char keyexpr[256]; strncpy(keyexpr, "foo/bar", 256); @@ -40,7 +40,7 @@ void test_publisher() { assert(strncmp(z_string_data(z_loan(pub_keyexpr)), "foo/bar", z_string_len(z_loan(pub_keyexpr))) == 0); // Check that publisher keeps the correct keyexpr z_undeclare_publisher(z_move(pub)); - z_close(z_move(s)); + z_close(z_move(s), NULL); } void data_handler(const z_loaned_sample_t *sample, void *arg) {} @@ -49,7 +49,7 @@ void test_subscriber() { z_owned_config_t config; z_config_default(&config); z_owned_session_t s; - z_open(&s, z_move(config)); + z_open(&s, z_move(config), NULL); z_owned_closure_sample_t callback; z_closure(&callback, data_handler, NULL, NULL); char keyexpr[256]; @@ -66,7 +66,7 @@ void test_subscriber() { assert(strncmp(z_string_data(z_loan(sub_keyexpr)), "foo/bar", z_string_len(z_loan(sub_keyexpr))) == 0); // Check that subscriber keeps the correct keyexpr z_undeclare_subscriber(z_move(sub)); - z_close(z_move(s)); + z_close(z_move(s), NULL); } int main(int argc, char **argv) { diff --git a/tests/z_api_keyexpr_test.c b/tests/z_api_keyexpr_test.c index f6f61004e..f7cf4d98b 100644 --- a/tests/z_api_keyexpr_test.c +++ b/tests/z_api_keyexpr_test.c @@ -86,7 +86,7 @@ void undeclare() { z_owned_config_t config; z_config_default(&config); z_owned_session_t s; - z_open(&s, z_move(config)); + z_open(&s, z_move(config), NULL); z_view_keyexpr_t view_ke; z_view_keyexpr_from_str(&view_ke, "test/thr"); diff --git a/tests/z_api_liveliness.c b/tests/z_api_liveliness.c index c9f57df70..7fe13dc6c 100644 --- a/tests/z_api_liveliness.c +++ b/tests/z_api_liveliness.c @@ -63,8 +63,8 @@ void test_liveliness_sub() { z_view_keyexpr_from_str(&k1, token1_expr); z_view_keyexpr_from_str(&k2, token2_expr); - z_open(&s1, z_move(c1)); - z_open(&s2, z_move(c2)); + z_open(&s1, z_move(c1), NULL); + z_open(&s2, z_move(c2), NULL); z_owned_closure_sample_t closure; context_t context = {false, false, false, false}; @@ -105,8 +105,8 @@ void test_liveliness_get() { z_view_keyexpr_from_str(&k, expr); z_view_keyexpr_from_str(&k1, token1_expr); - z_open(&s1, z_move(c1)); - z_open(&s2, z_move(c2)); + z_open(&s1, z_move(c1), NULL); + z_open(&s2, z_move(c2), NULL); z_sleep_s(1); zc_owned_liveliness_token_t t1; diff --git a/tests/z_int_pub_cache_query_sub_test.c b/tests/z_int_pub_cache_query_sub_test.c index e97aa3aba..ea2babd1f 100644 --- a/tests/z_int_pub_cache_query_sub_test.c +++ b/tests/z_int_pub_cache_query_sub_test.c @@ -39,7 +39,7 @@ int run_publisher() { } z_owned_session_t s; - if (z_open(&s, z_move(config)), 0) { + if (z_open(&s, z_move(config), NULL), 0) { perror("Unable to open session!"); return -1; } @@ -86,7 +86,7 @@ int run_publisher() { ze_undeclare_publication_cache(z_move(pub_cache)); z_undeclare_publisher(z_move(pub)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } @@ -123,7 +123,7 @@ int run_subscriber() { z_config_default(&config); z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { perror("Unable to open session!"); return -1; } @@ -144,7 +144,7 @@ int run_subscriber() { z_sleep_s(10); ze_undeclare_querying_subscriber(z_move(sub)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return -1; } diff --git a/tests/z_int_pub_sub_attachment_test.c b/tests/z_int_pub_sub_attachment_test.c index 6d49f34cf..21d9fe9f3 100644 --- a/tests/z_int_pub_sub_attachment_test.c +++ b/tests/z_int_pub_sub_attachment_test.c @@ -94,7 +94,7 @@ int run_publisher() { z_owned_config_t config; z_config_default(&config); z_owned_session_t s; - if (z_open(&s, z_move(config))) { + if (z_open(&s, z_move(config), NULL)) { perror("Unable to open session!"); return -1; } @@ -127,7 +127,7 @@ int run_publisher() { } z_undeclare_publisher(z_move(pub)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } @@ -172,7 +172,7 @@ int run_subscriber() { z_config_default(&config); z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { perror("Unable to open session!"); return -1; } @@ -193,7 +193,7 @@ int run_subscriber() { z_sleep_s(10); z_undeclare_subscriber(z_move(sub)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return -1; } diff --git a/tests/z_int_pub_sub_test.c b/tests/z_int_pub_sub_test.c index 3195b53b3..d5bc39500 100644 --- a/tests/z_int_pub_sub_test.c +++ b/tests/z_int_pub_sub_test.c @@ -37,7 +37,7 @@ int run_publisher() { z_owned_config_t config; z_config_default(&config); z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { perror("Unable to open session!"); return -1; } @@ -76,7 +76,7 @@ int run_publisher() { } z_undeclare_publisher(z_move(pub)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } @@ -145,7 +145,7 @@ int run_subscriber() { z_config_default(&config); z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { perror("Unable to open session!"); return -1; } @@ -165,7 +165,7 @@ int run_subscriber() { sleep(10); z_undeclare_subscriber(z_move(sub)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return -1; } diff --git a/tests/z_int_queryable_attachment_test.c b/tests/z_int_queryable_attachment_test.c index 461179216..375391d1b 100644 --- a/tests/z_int_queryable_attachment_test.c +++ b/tests/z_int_queryable_attachment_test.c @@ -131,7 +131,7 @@ int run_queryable() { z_owned_config_t config; z_config_default(&config); z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { perror("Unable to open session!"); return -1; } @@ -152,7 +152,7 @@ int run_queryable() { z_sleep_s(10); z_undeclare_queryable(z_move(qable)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } @@ -162,7 +162,7 @@ int run_get() { z_owned_config_t config; z_config_default(&config); z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { perror("Unable to open session!"); return -1; } @@ -220,7 +220,7 @@ int run_get() { z_drop(z_move(reply)); z_drop(z_move(handler)); } - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } diff --git a/tests/z_int_queryable_test.c b/tests/z_int_queryable_test.c index a62875b1c..27d9308cf 100644 --- a/tests/z_int_queryable_test.c +++ b/tests/z_int_queryable_test.c @@ -63,7 +63,7 @@ int run_queryable() { z_owned_config_t config; z_config_default(&config); z_owned_session_t s; - if (z_open(&s, z_move(config)) < 0) { + if (z_open(&s, z_move(config), NULL) < 0) { perror("Unable to open session!"); return -1; } @@ -83,7 +83,7 @@ int run_queryable() { z_sleep_s(10); z_undeclare_queryable(z_move(qable)); - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } @@ -93,7 +93,7 @@ int run_get() { z_owned_config_t config; z_config_default(&config); z_owned_session_t s; - if (z_open(&s, z_move(config))) { + if (z_open(&s, z_move(config), NULL)) { perror("Unable to open session!"); return -1; } @@ -163,7 +163,7 @@ int run_get() { } z_drop(z_move(handler)); } - z_close(z_move(s)); + z_close(z_move(s), NULL); return 0; } diff --git a/tests/z_leak_pub_sub_test.c b/tests/z_leak_pub_sub_test.c index 231d8b39e..ae9bf54c4 100644 --- a/tests/z_leak_pub_sub_test.c +++ b/tests/z_leak_pub_sub_test.c @@ -48,7 +48,7 @@ int main(int argc, char **argv) { z_config_default(&pub_config); z_owned_session_t pub_session; - z_open(&pub_session, z_move(pub_config)); + z_open(&pub_session, z_move(pub_config), NULL); z_owned_publisher_t publisher; z_declare_publisher(&publisher, z_loan(pub_session), z_loan(pub_keyexpr), NULL); @@ -62,7 +62,7 @@ int main(int argc, char **argv) { z_config_default(&sub_config); z_owned_session_t sub_session; - z_open(&sub_session, z_move(sub_config)); + z_open(&sub_session, z_move(sub_config), NULL); z_owned_closure_sample_t callback; z_closure(&callback, data_handler, NULL, NULL); @@ -88,8 +88,8 @@ int main(int argc, char **argv) { z_undeclare_publisher(z_move(publisher)); z_undeclare_subscriber(z_move(subscriber)); - z_close(z_move(pub_session)); - z_close(z_move(sub_session)); + z_close(z_move(pub_session), NULL); + z_close(z_move(sub_session), NULL); z_drop(z_move(pub_keyexpr)); zc_stop_z_runtime(); diff --git a/tests/z_leak_queryable_get_test.c b/tests/z_leak_queryable_get_test.c index 58f755950..af1960f7a 100644 --- a/tests/z_leak_queryable_get_test.c +++ b/tests/z_leak_queryable_get_test.c @@ -60,7 +60,7 @@ int main(int argc, char **argv) { z_config_default(&queryable_config); z_owned_session_t queryable_session; - z_open(&queryable_session, z_move(queryable_config)); + z_open(&queryable_session, z_move(queryable_config), NULL); z_owned_closure_query_t callback; z_closure(&callback, query_handler, NULL, NULL); @@ -74,7 +74,7 @@ int main(int argc, char **argv) { z_config_default(&get_config); z_owned_session_t get_session; - z_open(&get_session, z_move(get_config)); + z_open(&get_session, z_move(get_config), NULL); z_sleep_s(1); @@ -121,8 +121,8 @@ int main(int argc, char **argv) { assert(received_replies == 5); z_undeclare_queryable(z_move(queryable)); - z_close(z_move(get_session)); - z_close(z_move(queryable_session)); + z_close(z_move(get_session), NULL); + z_close(z_move(queryable_session), NULL); z_drop(z_move(queryable_keyexpr)); zc_stop_z_runtime();