From c9dba51ccf7788c6830ee2f4527e44105748b2a8 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Mon, 11 Mar 2024 17:42:05 +0100 Subject: [PATCH] feat: remove ke from unicast undecl sub --- src/net/primitives.c | 7 ++++++- src/protocol/definitions/declarations.c | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/net/primitives.c b/src/net/primitives.c index 87d138d47..3e279ae3c 100644 --- a/src/net/primitives.c +++ b/src/net/primitives.c @@ -237,7 +237,12 @@ int8_t _z_undeclare_subscriber(_z_subscriber_t *sub) { return _Z_ERR_ENTITY_UNKNOWN; } // Build the declare message to send on the wire - _z_declaration_t declaration = _z_make_undecl_subscriber(sub->_entity_id, &s->in->val._key); + _z_declaration_t declaration; + if (sub->_zn.in->val._tp._type == _Z_TRANSPORT_UNICAST_TYPE) { + declaration = _z_make_undecl_subscriber(sub->_entity_id, NULL); + } else { + declaration = _z_make_undecl_subscriber(sub->_entity_id, &s->in->val._key); + } _z_network_message_t n_msg = _z_n_msg_make_declare(declaration); if (_z_send_n_msg(&sub->_zn.in->val, &n_msg, Z_RELIABILITY_RELIABLE, Z_CONGESTION_CONTROL_BLOCK) != _Z_RES_OK) { return _Z_ERR_TRANSPORT_TX_FAILED; diff --git a/src/protocol/definitions/declarations.c b/src/protocol/definitions/declarations.c index 9f1973077..61d6eef82 100644 --- a/src/protocol/definitions/declarations.c +++ b/src/protocol/definitions/declarations.c @@ -76,10 +76,14 @@ _z_declaration_t _z_make_decl_subscriber(_Z_MOVE(_z_keyexpr_t) key, uint32_t id, ._keyexpr = _z_keyexpr_steal(key), ._ext_subinfo = {._pull_mode = pull_mode, ._reliable = reliable}}}}; } + _z_declaration_t _z_make_undecl_subscriber(uint32_t id, _Z_OPTIONAL const _z_keyexpr_t *key) { - return (_z_declaration_t){._tag = _Z_UNDECL_SUBSCRIBER, - ._body = {._undecl_subscriber = {._id = id, ._ext_keyexpr = _z_keyexpr_duplicate(*key)}}}; + return (_z_declaration_t){ + ._tag = _Z_UNDECL_SUBSCRIBER, + ._body = {._undecl_subscriber = { + ._id = id, ._ext_keyexpr = (key == NULL) ? _z_keyexpr_null() : _z_keyexpr_duplicate(*key)}}}; } + _z_declaration_t _z_make_decl_queryable(_Z_MOVE(_z_keyexpr_t) key, uint32_t id, uint32_t distance, uint8_t complete) { return (_z_declaration_t){ ._tag = _Z_DECL_QUERYABLE,