Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make z_drop on zenoh entities call actual drop instead of undeclare #641

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions include/zenoh_commons.h
Original file line number Diff line number Diff line change
Expand Up @@ -3247,7 +3247,7 @@ z_result_t z_publisher_delete(const struct z_loaned_publisher_t *publisher,
*/
ZENOHC_API void z_publisher_delete_options_default(struct z_publisher_delete_options_t *this_);
/**
* Frees memory and resets publisher to its gravestone state. Also attempts undeclare publisher.
* Frees memory and resets publisher to its gravestone state.
*/
ZENOHC_API void z_publisher_drop(struct z_moved_publisher_t *this_);
/**
Expand Down Expand Up @@ -3466,7 +3466,7 @@ ZENOHC_API void z_query_reply_options_default(struct z_query_reply_options_t *th
*/
ZENOHC_API enum z_query_target_t z_query_target_default(void);
/**
* Frees memory and resets it to its gravesztone state. Will also attempt to undeclare queryable.
* Frees memory and resets queryable to its gravestone state.
*/
ZENOHC_API void z_queryable_drop(struct z_moved_queryable_t *this_);
ZENOHC_API
Expand Down Expand Up @@ -4188,7 +4188,7 @@ ZENOHC_API size_t z_string_len(const struct z_loaned_string_t *this_);
*/
ZENOHC_API const struct z_loaned_string_t *z_string_loan(const struct z_owned_string_t *this_);
/**
* Drops subscriber and resets it to its gravestone state. Also attempts to undeclare it.
* Drops subscriber and resets it to its gravestone state.
*/
ZENOHC_API void z_subscriber_drop(struct z_moved_subscriber_t *this_);
/**
Expand Down Expand Up @@ -4871,7 +4871,7 @@ ZENOHC_API bool ze_internal_querying_subscriber_check(const ze_owned_querying_su
ZENOHC_API void ze_internal_querying_subscriber_null(ze_owned_querying_subscriber_t *this_);
#endif
/**
* Drops publication cache. Also attempts to undeclare it.
* Drops publication cache and resets it to its gravestone state.
*/
#if defined(UNSTABLE)
ZENOHC_API void ze_publication_cache_drop(ze_moved_publication_cache_t *this_);
Expand All @@ -4883,7 +4883,7 @@ ZENOHC_API void ze_publication_cache_drop(ze_moved_publication_cache_t *this_);
ZENOHC_API void ze_publication_cache_options_default(struct ze_publication_cache_options_t *this_);
#endif
/**
* Drops querying subscriber. Also attempts to undeclare it.
* Drops querying subscriber.
*/
#if defined(UNSTABLE)
ZENOHC_API void ze_querying_subscriber_drop(ze_moved_querying_subscriber_t *this_);
Expand Down Expand Up @@ -4926,5 +4926,5 @@ ZENOHC_API z_result_t ze_undeclare_publication_cache(ze_moved_publication_cache_
* @return 0 in case of success, negative error code otherwise.
*/
#if defined(UNSTABLE)
ZENOHC_API z_result_t ze_undeclare_querying_subscriber(ze_moved_querying_subscriber_t *_this);
ZENOHC_API z_result_t ze_undeclare_querying_subscriber(ze_moved_querying_subscriber_t *this_);
#endif
6 changes: 3 additions & 3 deletions src/publication_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ pub extern "C" fn ze_undeclare_publication_cache(
result::Z_OK
}

/// Drops publication cache. Also attempts to undeclare it.
/// Drops publication cache and resets it to its gravestone state.
#[no_mangle]
#[allow(clippy::missing_safety_doc)]
pub extern "C" fn ze_publication_cache_drop(this_: &mut ze_moved_publication_cache_t) {
ze_undeclare_publication_cache(this_);
pub extern "C" fn ze_publication_cache_drop(this: &mut ze_moved_publication_cache_t) {
std::mem::drop(this.take_rust_type())
}
6 changes: 3 additions & 3 deletions src/publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,9 @@ pub extern "C" fn z_undeclare_publisher(this_: &mut z_moved_publisher_t) -> resu
result::Z_OK
}

/// Frees memory and resets publisher to its gravestone state. Also attempts undeclare publisher.
/// Frees memory and resets publisher to its gravestone state.
#[no_mangle]
#[allow(clippy::missing_safety_doc)]
pub extern "C" fn z_publisher_drop(this_: &mut z_moved_publisher_t) {
z_undeclare_publisher(this_);
pub extern "C" fn z_publisher_drop(this: &mut z_moved_publisher_t) {
std::mem::drop(this.take_rust_type())
}
4 changes: 2 additions & 2 deletions src/queryable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,11 @@ pub extern "C" fn z_undeclare_queryable(this_: &mut z_moved_queryable_t) -> resu
result::Z_OK
}

/// Frees memory and resets it to its gravesztone state. Will also attempt to undeclare queryable.
/// Frees memory and resets queryable to its gravestone state.
#[allow(clippy::missing_safety_doc)]
#[no_mangle]
pub extern "C" fn z_queryable_drop(this_: &mut z_moved_queryable_t) {
z_undeclare_queryable(this_);
std::mem::drop(this_.take_rust_type())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be undeclared before the drop then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. The drop automatically undeclares currently. With eclipse-zenoh/zenoh#1334 drop and undeclare will intentionally have different behavior.

}

/// Returns ``true`` if queryable is valid, ``false`` otherwise.
Expand Down
8 changes: 4 additions & 4 deletions src/querying_subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ pub unsafe extern "C" fn ze_querying_subscriber_get(
/// @return 0 in case of success, negative error code otherwise.
#[no_mangle]
pub extern "C" fn ze_undeclare_querying_subscriber(
_this: &mut ze_moved_querying_subscriber_t,
this_: &mut ze_moved_querying_subscriber_t,
) -> result::z_result_t {
if let Some(s) = _this.take_rust_type() {
if let Some(s) = this_.take_rust_type() {
if let Err(e) = s.0.undeclare().wait() {
tracing::error!("{}", e);
return result::Z_EGENERIC;
Expand All @@ -232,10 +232,10 @@ pub extern "C" fn ze_undeclare_querying_subscriber(
result::Z_OK
}

/// Drops querying subscriber. Also attempts to undeclare it.
/// Drops querying subscriber.
#[no_mangle]
pub extern "C" fn ze_querying_subscriber_drop(this_: &mut ze_moved_querying_subscriber_t) {
ze_undeclare_querying_subscriber(this_);
std::mem::drop(this_.take_rust_type())
}

/// Returns ``true`` if querying subscriber is valid, ``false`` otherwise.
Expand Down
4 changes: 2 additions & 2 deletions src/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ pub extern "C" fn z_undeclare_subscriber(this_: &mut z_moved_subscriber_t) -> re
result::Z_OK
}

/// Drops subscriber and resets it to its gravestone state. Also attempts to undeclare it.
/// Drops subscriber and resets it to its gravestone state.
#[no_mangle]
pub extern "C" fn z_subscriber_drop(this_: &mut z_moved_subscriber_t) {
let _ = this_.take_rust_type();
std::mem::drop(this_.take_rust_type())
}

/// Returns ``true`` if subscriber is valid, ``false`` otherwise.
Expand Down
Loading