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

properly extract publisher keyexpr id for interests #607

Merged
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
2 changes: 1 addition & 1 deletion include/zenoh-pico/protocol/keyexpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ _z_keyexpr_t _z_keyexpr_duplicate(_z_keyexpr_t src);
_z_keyexpr_t _z_keyexpr_alias(_z_keyexpr_t src);
/// Returns either keyexpr defined by id + mapping with null suffix if try_declared is true and id is non-zero,
/// or keyexpr defined by its suffix only, with 0 id and no mapping. This is to be used only when forwarding
/// keyexpr in user api to properly separate declard keyexpr from its suffix.
/// keyexpr in user api to properly separate declared keyexpr from its suffix.
_z_keyexpr_t _z_keyexpr_alias_from_user_defined(_z_keyexpr_t src, _Bool try_declared);
_z_keyexpr_t _z_keyexpr_steal(_Z_MOVE(_z_keyexpr_t) src);
static inline _z_keyexpr_t _z_keyexpr_null(void) {
Expand Down
10 changes: 2 additions & 8 deletions src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1154,10 +1154,7 @@ int8_t z_publisher_put(const z_loaned_publisher_t *pub, z_moved_bytes_t *payload
encoding = _z_encoding_steal(&opt.encoding->_this._val);
}
// Remove potentially redundant ke suffix
_z_keyexpr_t pub_keyexpr = _z_keyexpr_alias(pub->_key);
if (pub_keyexpr._id != Z_RESOURCE_ID_NONE) {
pub_keyexpr._suffix = _z_string_null();
}
_z_keyexpr_t pub_keyexpr = _z_keyexpr_alias_from_user_defined(pub->_key, true);

// Check if write filter is active before writing
if (!_z_write_filter_active(pub)) {
Expand Down Expand Up @@ -1186,10 +1183,7 @@ int8_t z_publisher_delete(const z_loaned_publisher_t *pub, const z_publisher_del
opt.timestamp = options->timestamp;
}
// Remove potentially redundant ke suffix
_z_keyexpr_t pub_keyexpr = _z_keyexpr_alias(pub->_key);
if (pub_keyexpr._id != Z_RESOURCE_ID_NONE) {
pub_keyexpr._suffix = _z_string_null();
}
_z_keyexpr_t pub_keyexpr = _z_keyexpr_alias_from_user_defined(pub->_key, true);

return _z_write(_Z_RC_IN_VAL(&pub->_zn), pub_keyexpr, _z_bytes_null(), NULL, Z_SAMPLE_KIND_DELETE,
pub->_congestion_control, pub->_priority, pub->_is_express, opt.timestamp, _z_bytes_null());
Expand Down
5 changes: 3 additions & 2 deletions src/net/filtering.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ int8_t _z_write_filter_create(_z_publisher_t *pub) {
ctx->decl_id = 0;

pub->_filter.ctx = ctx;
pub->_filter._interest_id = _z_add_interest(_Z_RC_IN_VAL(&pub->_zn), _z_keyexpr_alias(pub->_key),
_z_write_filter_callback, flags, (void *)ctx);
pub->_filter._interest_id =
_z_add_interest(_Z_RC_IN_VAL(&pub->_zn), _z_keyexpr_alias_from_user_defined(pub->_key, true),
_z_write_filter_callback, flags, (void *)ctx);
if (pub->_filter._interest_id == 0) {
z_free(ctx);
return _Z_ERR_GENERIC;
Expand Down
Loading